// https://syzkaller.appspot.com/bug?id=0e77b741e3a1b835114f0f7f0f3e53e12c9a73bc
// autogenerated by syzkaller (https://github.com/google/syzkaller)

#define _GNU_SOURCE

#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include <linux/loop.h>

#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif

static unsigned long long procid;

static void sleep_ms(uint64_t ms)
{
  usleep(ms * 1000);
}

static uint64_t current_time_ms(void)
{
  struct timespec ts;
  if (clock_gettime(CLOCK_MONOTONIC, &ts))
    exit(1);
  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}

static bool write_file(const char* file, const char* what, ...)
{
  char buf[1024];
  va_list args;
  va_start(args, what);
  vsnprintf(buf, sizeof(buf), what, args);
  va_end(args);
  buf[sizeof(buf) - 1] = 0;
  int len = strlen(buf);
  int fd = open(file, O_WRONLY | O_CLOEXEC);
  if (fd == -1)
    return false;
  if (write(fd, buf, len) != len) {
    int err = errno;
    close(fd);
    errno = err;
    return false;
  }
  close(fd);
  return true;
}

//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:

//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty.  In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//%    claim that you wrote the original software. If you use this software
//%    in a product, an acknowledgment in the product documentation would be
//%    appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//%    misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler    madler@alumni.caltech.edu

//% BEGIN CODE DERIVED FROM puff.{c,h}

#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288

struct puff_state {
  unsigned char* out;
  unsigned long outlen;
  unsigned long outcnt;
  const unsigned char* in;
  unsigned long inlen;
  unsigned long incnt;
  int bitbuf;
  int bitcnt;
  jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
  long val = s->bitbuf;
  while (s->bitcnt < need) {
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    val |= (long)(s->in[s->incnt++]) << s->bitcnt;
    s->bitcnt += 8;
  }
  s->bitbuf = (int)(val >> need);
  s->bitcnt -= need;
  return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
  s->bitbuf = 0;
  s->bitcnt = 0;
  if (s->incnt + 4 > s->inlen)
    return 2;
  unsigned len = s->in[s->incnt++];
  len |= s->in[s->incnt++] << 8;
  if (s->in[s->incnt++] != (~len & 0xff) ||
      s->in[s->incnt++] != ((~len >> 8) & 0xff))
    return -2;
  if (s->incnt + len > s->inlen)
    return 2;
  if (s->outcnt + len > s->outlen)
    return 1;
  for (; len--; s->outcnt++, s->incnt++) {
    if (s->in[s->incnt])
      s->out[s->outcnt] = s->in[s->incnt];
  }
  return 0;
}
struct puff_huffman {
  short* count;
  short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
  int first = 0;
  int index = 0;
  int bitbuf = s->bitbuf;
  int left = s->bitcnt;
  int code = first = index = 0;
  int len = 1;
  short* next = h->count + 1;
  while (1) {
    while (left--) {
      code |= bitbuf & 1;
      bitbuf >>= 1;
      int count = *next++;
      if (code - count < first) {
        s->bitbuf = bitbuf;
        s->bitcnt = (s->bitcnt - len) & 7;
        return h->symbol[index + (code - first)];
      }
      index += count;
      first += count;
      first <<= 1;
      code <<= 1;
      len++;
    }
    left = (MAXBITS + 1) - len;
    if (left == 0)
      break;
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    bitbuf = s->in[s->incnt++];
    if (left > 8)
      left = 8;
  }
  return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
  int len;
  for (len = 0; len <= MAXBITS; len++)
    h->count[len] = 0;
  int symbol;
  for (symbol = 0; symbol < n; symbol++)
    (h->count[length[symbol]])++;
  if (h->count[0] == n)
    return 0;
  int left = 1;
  for (len = 1; len <= MAXBITS; len++) {
    left <<= 1;
    left -= h->count[len];
    if (left < 0)
      return left;
  }
  short offs[MAXBITS + 1];
  offs[1] = 0;
  for (len = 1; len < MAXBITS; len++)
    offs[len + 1] = offs[len] + h->count[len];
  for (symbol = 0; symbol < n; symbol++)
    if (length[symbol] != 0)
      h->symbol[offs[length[symbol]]++] = symbol;
  return left;
}
static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode,
                      const struct puff_huffman* distcode)
{
  static const short lens[29] = {3,  4,  5,  6,   7,   8,   9,   10,  11, 13,
                                 15, 17, 19, 23,  27,  31,  35,  43,  51, 59,
                                 67, 83, 99, 115, 131, 163, 195, 227, 258};
  static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
                                 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
  static const short dists[30] = {
      1,    2,    3,    4,    5,    7,    9,    13,    17,    25,
      33,   49,   65,   97,   129,  193,  257,  385,   513,   769,
      1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
  static const short dext[30] = {0, 0, 0,  0,  1,  1,  2,  2,  3,  3,
                                 4, 4, 5,  5,  6,  6,  7,  7,  8,  8,
                                 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
  int symbol;
  do {
    symbol = puff_decode(s, lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 256) {
      if (s->outcnt == s->outlen)
        return 1;
      if (symbol)
        s->out[s->outcnt] = symbol;
      s->outcnt++;
    } else if (symbol > 256) {
      symbol -= 257;
      if (symbol >= 29)
        return -10;
      int len = lens[symbol] + puff_bits(s, lext[symbol]);
      symbol = puff_decode(s, distcode);
      if (symbol < 0)
        return symbol;
      unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
      if (dist > s->outcnt)
        return -11;
      if (s->outcnt + len > s->outlen)
        return 1;
      while (len--) {
        if (dist <= s->outcnt && s->out[s->outcnt - dist])
          s->out[s->outcnt] = s->out[s->outcnt - dist];
        s->outcnt++;
      }
    }
  } while (symbol != 256);
  return 0;
}
static int puff_fixed(struct puff_state* s)
{
  static int virgin = 1;
  static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
  static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  static struct puff_huffman lencode, distcode;
  if (virgin) {
    lencode.count = lencnt;
    lencode.symbol = lensym;
    distcode.count = distcnt;
    distcode.symbol = distsym;
    short lengths[FIXLCODES];
    int symbol;
    for (symbol = 0; symbol < 144; symbol++)
      lengths[symbol] = 8;
    for (; symbol < 256; symbol++)
      lengths[symbol] = 9;
    for (; symbol < 280; symbol++)
      lengths[symbol] = 7;
    for (; symbol < FIXLCODES; symbol++)
      lengths[symbol] = 8;
    puff_construct(&lencode, lengths, FIXLCODES);
    for (symbol = 0; symbol < MAXDCODES; symbol++)
      lengths[symbol] = 5;
    puff_construct(&distcode, lengths, MAXDCODES);
    virgin = 0;
  }
  return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
  static const short order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
                                  11, 4,  12, 3, 13, 2, 14, 1, 15};
  int nlen = puff_bits(s, 5) + 257;
  int ndist = puff_bits(s, 5) + 1;
  int ncode = puff_bits(s, 4) + 4;
  if (nlen > MAXLCODES || ndist > MAXDCODES)
    return -3;
  short lengths[MAXCODES];
  int index;
  for (index = 0; index < ncode; index++)
    lengths[order[index]] = puff_bits(s, 3);
  for (; index < 19; index++)
    lengths[order[index]] = 0;
  short lencnt[MAXBITS + 1], lensym[MAXLCODES];
  struct puff_huffman lencode = {lencnt, lensym};
  int err = puff_construct(&lencode, lengths, 19);
  if (err != 0)
    return -4;
  index = 0;
  while (index < nlen + ndist) {
    int symbol;
    int len;
    symbol = puff_decode(s, &lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 16)
      lengths[index++] = symbol;
    else {
      len = 0;
      if (symbol == 16) {
        if (index == 0)
          return -5;
        len = lengths[index - 1];
        symbol = 3 + puff_bits(s, 2);
      } else if (symbol == 17)
        symbol = 3 + puff_bits(s, 3);
      else
        symbol = 11 + puff_bits(s, 7);
      if (index + symbol > nlen + ndist)
        return -6;
      while (symbol--)
        lengths[index++] = len;
    }
  }
  if (lengths[256] == 0)
    return -9;
  err = puff_construct(&lencode, lengths, nlen);
  if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
    return -7;
  short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  struct puff_huffman distcode = {distcnt, distsym};
  err = puff_construct(&distcode, lengths + nlen, ndist);
  if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
    return -8;
  return puff_codes(s, &lencode, &distcode);
}
static int puff(unsigned char* dest, unsigned long* destlen,
                const unsigned char* source, unsigned long sourcelen)
{
  struct puff_state s = {
      .out = dest,
      .outlen = *destlen,
      .outcnt = 0,
      .in = source,
      .inlen = sourcelen,
      .incnt = 0,
      .bitbuf = 0,
      .bitcnt = 0,
  };
  int err;
  if (setjmp(s.env) != 0)
    err = 2;
  else {
    int last;
    do {
      last = puff_bits(&s, 1);
      int type = puff_bits(&s, 2);
      err = type == 0 ? puff_stored(&s)
                      : (type == 1 ? puff_fixed(&s)
                                   : (type == 2 ? puff_dynamic(&s) : -1));
      if (err != 0)
        break;
    } while (!last);
  }
  *destlen = s.outcnt;
  return err;
}

//% END CODE DERIVED FROM puff.{c,h}

#define ZLIB_HEADER_WIDTH 2

static int puff_zlib_to_file(const unsigned char* source,
                             unsigned long sourcelen, int dest_fd)
{
  if (sourcelen < ZLIB_HEADER_WIDTH)
    return 0;
  source += ZLIB_HEADER_WIDTH;
  sourcelen -= ZLIB_HEADER_WIDTH;
  const unsigned long max_destlen = 132 << 20;
  void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ,
                   MAP_PRIVATE | MAP_ANON, -1, 0);
  if (ret == MAP_FAILED)
    return -1;
  unsigned char* dest = (unsigned char*)ret;
  unsigned long destlen = max_destlen;
  int err = puff(dest, &destlen, source, sourcelen);
  if (err) {
    munmap(dest, max_destlen);
    errno = -err;
    return -1;
  }
  if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
    munmap(dest, max_destlen);
    return -1;
  }
  return munmap(dest, max_destlen);
}

static int setup_loop_device(unsigned char* data, unsigned long size,
                             const char* loopname, int* loopfd_p)
{
  int err = 0, loopfd = -1;
  int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
  if (memfd == -1) {
    err = errno;
    goto error;
  }
  if (puff_zlib_to_file(data, size, memfd)) {
    err = errno;
    goto error_close_memfd;
  }
  loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    err = errno;
    goto error_close_memfd;
  }
  if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
    if (errno != EBUSY) {
      err = errno;
      goto error_close_loop;
    }
    ioctl(loopfd, LOOP_CLR_FD, 0);
    usleep(1000);
    if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
      err = errno;
      goto error_close_loop;
    }
  }
  close(memfd);
  *loopfd_p = loopfd;
  return 0;

error_close_loop:
  close(loopfd);
error_close_memfd:
  close(memfd);
error:
  errno = err;
  return -1;
}

static void reset_loop_device(const char* loopname)
{
  int loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    return;
  }
  if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
  }
  close(loopfd);
}

static long syz_mount_image(volatile long fsarg, volatile long dir,
                            volatile long flags, volatile long optsarg,
                            volatile long change_dir,
                            volatile unsigned long size, volatile long image)
{
  unsigned char* data = (unsigned char*)image;
  int res = -1, err = 0, need_loop_device = !!size;
  char* mount_opts = (char*)optsarg;
  char* target = (char*)dir;
  char* fs = (char*)fsarg;
  char* source = NULL;
  char loopname[64];
  if (need_loop_device) {
    int loopfd;
    memset(loopname, 0, sizeof(loopname));
    snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
    if (setup_loop_device(data, size, loopname, &loopfd) == -1)
      return -1;
    close(loopfd);
    source = loopname;
  }
  mkdir(target, 0777);
  char opts[256];
  memset(opts, 0, sizeof(opts));
  if (strlen(mount_opts) > (sizeof(opts) - 32)) {
  }
  strncpy(opts, mount_opts, sizeof(opts) - 32);
  if (strcmp(fs, "iso9660") == 0) {
    flags |= MS_RDONLY;
  } else if (strncmp(fs, "ext", 3) == 0) {
    bool has_remount_ro = false;
    char* remount_ro_start = strstr(opts, "errors=remount-ro");
    if (remount_ro_start != NULL) {
      char after = *(remount_ro_start + strlen("errors=remount-ro"));
      char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
      has_remount_ro = ((before == '\0' || before == ',') &&
                        (after == '\0' || after == ','));
    }
    if (strstr(opts, "errors=panic") || !has_remount_ro)
      strcat(opts, ",errors=continue");
  } else if (strcmp(fs, "xfs") == 0) {
    strcat(opts, ",nouuid");
  }
  res = mount(source, target, fs, flags, opts);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  res = open(target, O_RDONLY | O_DIRECTORY);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  if (change_dir) {
    res = chdir(target);
    if (res == -1) {
      err = errno;
    }
  }

error_clear_loop:
  if (need_loop_device)
    reset_loop_device(loopname);
  errno = err;
  return res;
}

static void kill_and_wait(int pid, int* status)
{
  kill(-pid, SIGKILL);
  kill(pid, SIGKILL);
  for (int i = 0; i < 100; i++) {
    if (waitpid(-1, status, WNOHANG | __WALL) == pid)
      return;
    usleep(1000);
  }
  DIR* dir = opendir("/sys/fs/fuse/connections");
  if (dir) {
    for (;;) {
      struct dirent* ent = readdir(dir);
      if (!ent)
        break;
      if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
        continue;
      char abort[300];
      snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
               ent->d_name);
      int fd = open(abort, O_WRONLY);
      if (fd == -1) {
        continue;
      }
      if (write(fd, abort, 1) < 0) {
      }
      close(fd);
    }
    closedir(dir);
  } else {
  }
  while (waitpid(-1, status, __WALL) != pid) {
  }
}

static void reset_loop()
{
  char buf[64];
  snprintf(buf, sizeof(buf), "/dev/loop%llu", procid);
  int loopfd = open(buf, O_RDWR);
  if (loopfd != -1) {
    ioctl(loopfd, LOOP_CLR_FD, 0);
    close(loopfd);
  }
}

static void setup_test()
{
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  setpgrp();
  write_file("/proc/self/oom_score_adj", "1000");
}

static void execute_one(void);

#define WAIT_FLAGS __WALL

static void loop(void)
{
  int iter = 0;
  for (;; iter++) {
    reset_loop();
    int pid = fork();
    if (pid < 0)
      exit(1);
    if (pid == 0) {
      setup_test();
      execute_one();
      exit(0);
    }
    int status = 0;
    uint64_t start = current_time_ms();
    for (;;) {
      sleep_ms(10);
      if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
        break;
      if (current_time_ms() - start < 5000)
        continue;
      kill_and_wait(pid, &status);
      break;
    }
  }
}

void execute_one(void)
{
  if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {
  }
  memcpy((void*)0x20000000, "hfsplus\000", 8);
  memcpy((void*)0x20000080, "./bus\000", 6);
  memcpy(
      (void*)0x20000e80,
      "\x78\x9c\xec\xdd\xcd\x8b\x1c\x69\x1d\x07\xf0\x6f\xf5\xf4\x74\xa6\xb3\x90"
      "\xed\xb8\xc9\x6e\x90\x15\xc3\x06\x56\x21\x98\x4c\x32\x64\x35\x5e\x8c\x22"
      "\x92\xc3\x22\xcb\x7a\xf0\x3c\x24\x93\xcd\x90\x4e\xb2\x4c\x66\x65\x76\x11"
      "\x9d\x55\x51\x3c\x08\x1e\xf2\x07\xac\xc2\xdc\x3c\x09\xde\x23\xf1\xbc\xde"
      "\xf6\x3a\xc7\x05\xc1\x4b\xf0\x10\x05\x19\xa9\xea\xea\x9e\x97\xee\x79\xcd"
      "\x38\x2f\xec\xe7\x13\x6a\x9e\xa7\xea\x79\xea\xa9\x5f\xff\xfa\xa9\xaa\xe9"
      "\xee\x0c\x1d\xe0\x0b\xeb\xe6\xc5\x34\x9f\xa4\xc8\xcd\x8b\x6f\x2f\x94\xeb"
      "\xcb\x4b\x53\xdd\xe5\xa5\xa9\x13\x75\x73\x37\x49\x59\x6f\x24\xcd\x5e\x91"
      "\xe2\x41\x52\x3c\x4d\x6e\x94\xed\x45\x92\x4e\x5d\x66\x4d\x39\xe4\xf1\xec"
      "\xf5\x77\x3f\x7b\xb6\xfc\x79\x6f\xad\x59\x2f\x55\xff\xc6\x56\xfb\x8d\x30"
      "\xa2\xef\x62\xbd\xe4\x7c\x92\xb1\xba\x1c\x36\xbe\xd3\x43\xac\x1b\xef\x56"
      "\x92\xf6\x50\x97\xd6\x4e\xc7\x5a\xd7\xb1\x4c\xda\x85\xba\x84\x43\xb7\x32"
      "\x64\x71\x37\xbb\xef\xe6\xbc\x05\x8e\x98\xfe\xdd\xa9\xe8\xdd\x37\x6b\xff"
      "\x1e\xd4\x3a\xc9\xc9\x24\x13\xf5\xef\x01\xa9\xaf\x0e\x8d\x83\x8d\x72\xff"
      "\xed\xea\x2a\x07\x00\x00\x00\xc7\xc3\xd0\x3b\xdf\x9f\x3e\x3c\x9c\x40\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x38\xab\xbf\xff\xbf\xa8\x97\x46\x5d"
      "\xe6\x7c\x8a\xfe\xf7\xff\xb7\xfa\xdb\xea\xfa\xb1\xf6\xe4\xb0\x03\x00\x00"
      "\x00\x00\x00\x00\x00\x80\x7d\xf0\xd5\xe7\x79\x9e\x85\x9c\xea\xaf\xaf\x14"
      "\xd5\x67\xfe\x6f\x54\x2b\x67\xf2\x9f\x95\xe4\xa5\x7c\x90\x47\x99\xc9\x5c"
      "\x2e\x65\x21\xd3\x99\xcf\x7c\xe6\x72\x25\x49\x67\xcd\x40\xad\x85\xe9\xf9"
      "\xf9\xb9\x2b\x83\x3d\x4b\xa3\xf7\xbc\x3a\x72\xcf\xab\x7b\x7f\x0c\xe3\x7b"
      "\xdf\x15\x00\x00\x00\x00\x00\x00\x00\x8e\xb0\xc7\x5b\xb4\x35\x36\x6e\xf8"
      "\x45\x6e\xae\x7e\xfe\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x47"
      "\x41\x91\x8c\xf5\x8a\x6a\x39\x53\x97\x8d\x4e\x1a\xcd\x24\x13\x49\x5a\x65"
      "\xbf\xc5\xe4\xef\xfd\xfa\x31\x51\x8c\xd8\x76\xe2\x10\xe2\x00\x00\x00\x80"
      "\x17\x32\xb1\x87\x7d\x5e\x7e\x9e\xe7\x59\xc8\xa9\xfe\xfa\x4a\x51\xbd\xe6"
      "\x7f\xb5\x7a\xbd\x3c\x91\x0f\xf2\x20\xf3\x99\xcd\x7c\xba\x99\xc9\xed\xfa"
      "\x35\x74\xf9\xaa\xbf\xb1\xbc\x34\xd5\x5d\x5e\x9a\xba\x5f\x2e\xc3\xe3\x7e"
      "\xf7\x9f\xbb\x0a\xa3\x1a\x31\xbd\xf7\x1e\x46\x1f\xf9\x5c\xd5\xa3\x9d\x3b"
      "\x99\xad\xb6\x5c\xca\xad\x2a\x98\xdb\x69\x54\x7b\x96\xce\xf5\xe3\xa9\x96"
      "\xfb\x2b\x3d\x83\x83\x7c\x5c\xc6\x54\x7c\xa7\xb6\xc3\xc8\x9a\x75\x5a\xcb"
      "\x83\xfd\x7e\x93\x77\x11\xf6\xc7\x93\x5d\xf6\xef\x94\xc1\x25\x83\x8c\x4c"
      "\xd6\xb1\x95\xd9\x38\xdd\xcb\x42\x51\xbd\x51\x93\x6c\x7c\x86\xb6\x7d\x76"
      "\x9a\x1b\x8f\x94\x46\xc6\x07\x47\xba\x92\xc6\xe0\x9d\x9f\x33\xeb\x72\x3e"
      "\x34\x17\xf6\x94\xf3\x93\x75\x59\x3e\x9e\x5f\xff\x5f\x73\xbe\x5b\x83\x4c"
      "\x34\x52\x65\xe2\xea\xea\xec\x6b\xbd\xba\x75\x26\x92\xaf\xfd\xe5\x4f\x3f"
      "\xbe\xdb\x7d\x70\xef\xee\x9d\x47\x17\x8f\xce\x43\xda\xc6\xd8\x26\xdb\x37"
      "\xce\x89\xa9\x35\xe7\xe1\x6b\xc7\x3a\x13\xf5\xdc\xdf\x71\x5c\x93\x55\x26"
      "\xce\x0e\xd6\x6f\xe6\x07\xf9\x51\x2e\xe6\x7c\xde\xc9\x5c\x66\xf3\x93\x4c"
      "\x67\x3e\x33\xe9\x5f\x88\xa6\xeb\xa1\xcb\x9f\x9d\xad\x33\x75\x63\xdd\xda"
      "\x3b\x5b\x86\x51\xc7\xdb\xe9\x3d\x67\xff\x5d\x7f\xf1\xdb\x2c\xa6\xf3\xf9"
      "\x7e\x55\x9b\xce\x1b\xd5\xbe\xa7\x32\x9b\x22\x0f\x73\x3b\x33\x79\xab\xfa"
      "\x77\x35\x57\xf2\xcd\x5c\xcb\xb5\x5c\x5f\xf3\x0c\x9f\xdd\x24\xee\xa2\x17"
      "\x46\x75\xd6\x37\x36\x9e\xf5\xfd\x8c\xfe\x75\x64\xfc\x17\xbe\x5e\x57\xda"
      "\x49\x7e\x53\x97\x43\x39\xd8\x60\xb3\xd9\xb9\x5f\x7a\xd7\xfe\xf2\x5a\x77"
      "\x7a\x70\xb4\xfe\xac\x7f\x36\xe8\x75\x7a\x70\x1e\x94\xe9\x5f\xcd\xd2\x97"
      "\xfa\xd9\x19\x1f\x39\xf8\x5e\xae\x8d\xcd\x2f\xd7\x95\xf2\x18\xbf\xac\xcb"
      "\xa3\xa1\x53\x67\xa2\x3c\x81\xfa\x77\x89\x7e\x74\xaf\xf4\x32\xd1\xac\xee"
      "\x45\xc3\xf3\xfc\x0f\xd5\x3c\x7d\xd4\x7d\x70\x6f\xee\xee\xf4\xfb\x9b\x8c"
      "\xbf\xb8\x61\xfd\xcd\xba\x2c\xa7\xd5\xd2\x57\x76\x10\x60\x75\x62\x8f\x7e"
      "\x2a\xf6\x57\x2b\x2b\x2f\x97\x73\xa7\x77\x25\x39\xbd\xe6\x2a\x39\x59\xcd"
      "\xa5\x57\x06\x57\x99\xd3\xeb\xee\xaa\xad\xfa\x13\x97\x5e\x5b\x63\xa8\xed"
      "\x6c\xd5\x56\x14\xfd\x33\xf5\x87\x9b\x9e\xa9\xad\xfa\x77\xb8\xe1\x91\xae"
      "\x56\x6d\xaf\x8d\x6c\x9b\xaa\xda\xce\xad\x69\x5b\xf7\xfb\x56\x1e\xa6\x9b"
      "\xdb\x07\x90\x3f\x00\x5e\x50\x27\x27\x5b\xed\x7f\xb4\x3f\x6d\x7f\xd2\xfe"
      "\x55\xfb\x6e\xfb\xed\x89\xef\x9d\xf8\xd6\x89\xd7\x5b\x19\xff\xdb\xf8\xb7"
      "\x9b\x93\x63\x6f\x36\x5e\x2f\xfe\x9c\x4f\xf2\xb3\xd5\xd7\xff\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\xc0\xde\x3d\xfa\xf0\xa3\x7b\xd3\xdd\xee\xcc\xdc\xe8\x4a\x63\xf3"
      "\xa6\x6d\x2a\xdb\x8d\xbc\xa1\x52\xd4\x5f\xe8\xb3\xa7\x63\xd5\x95\xdf\xbe"
      "\xd4\x7b\x4c\x7b\x8e\x79\x1f\x2b\x13\x65\x1c\x6b\xb7\x8c\xaf\x06\x56\xc6"
      "\x78\x40\x61\xb4\x37\x86\x31\x54\x59\xf9\x79\x72\xe0\xf9\xe9\x7f\x89\xe0"
      "\xe8\x3e\xbf\x2b\x2b\xcd\xec\x64\xc0\x1b\xdb\xf5\xf9\xf8\xd0\x67\xc2\x51"
      "\xaf\x8c\x65\xf4\x04\x38\xc4\x8b\x12\x70\x20\x2e\xcf\xdf\x7f\xff\xf2\xa3"
      "\x0f\x3f\xfa\xc6\xec\xfd\xe9\xf7\x66\xde\x9b\x79\x30\x7e\xed\xda\xf5\xc9"
      "\xeb\xd7\xde\x9a\xba\x7c\x67\xb6\x3b\x33\xd9\xfb\x79\x84\xbe\x6d\x10\xd8"
      "\x37\xab\x37\xfd\xc3\x8e\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\xa9"
      "\x51\x7f\x18\x50\xf4\x9a\x16\x5f\xf0\x6f\x3c\xfc\xcf\x42\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60"
      "\x5f\xdc\xbc\x98\xe6\x93\x14\xb9\x32\x79\x69\xb2\x5c\x5f\x5e\x9a\xea\x96"
      "\x4b\xbf\xbe\xda\xb3\x99\xa4\xd1\x48\x8a\x9f\x26\xc5\xd3\xe4\x46\x7a\x4b"
      "\x3a\x6b\x86\x2b\xf2\xc7\xa7\x59\x19\x71\x9c\xc7\xb3\xd7\xdf\xfd\xec\xd9"
      "\xf2\xe7\xab\x63\x35\x7b\xfd\x93\x46\x5d\xbe\x80\xc5\x7a\xc9\xf9\x24\x63"
      "\x75\xb9\x5f\xe3\xdd\xda\xe9\x78\x9b\x3e\x88\xe2\x5f\xfd\xc6\x32\x61\x17"
      "\xfa\x89\x83\xc3\xf6\xbf\x00\x00\x00\xff\xff\x1a\xca\xfe\x38",
      1743);
  syz_mount_image(
      /*fs=*/0x20000000, /*dir=*/0x20000080,
      /*flags=MS_LAZYTIME|MS_SYNCHRONOUS|MS_RELATIME|MS_NOATIME*/ 0x2200410,
      /*opts=*/0x200000c0, /*chdir=*/0xf, /*size=*/0x6cf, /*img=*/0x20000e80);
}
int main(void)
{
  syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
          /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  const char* reason;
  (void)reason;
  loop();
  return 0;
}