// https://syzkaller.appspot.com/bug?id=f56f3410688a1cee72d53c6c4be30b7eda56c686
// 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;
    }
  }
}

uint64_t r[1] = {0xffffffffffffffff};

void execute_one(void)
{
  intptr_t res = 0;
  if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {
  }
  memcpy((void*)0x20000000, "nilfs2\000", 7);
  memcpy((void*)0x20000040, "./file0\000", 8);
  *(uint8_t*)0x20000440 = 0;
  memcpy(
      (void*)0x200070c0,
      "\x78\x9c\xec\xdd\x4b\x8c\x1c\x47\xc1\x00\xe0\xea\xd9\x9d\xb5\xd7\x76\x7e"
      "\x8f\xf3\xdb\x64\xb1\x4d\x62\xf3\x48\xc2\x23\xbb\xf1\x7a\x31\x0f\x0b\xe2"
      "\x28\xbe\x60\xc5\x11\xb7\x48\x11\x17\xcb\x71\x82\xc5\xc6\x20\x1c\x09\x12"
      "\x45\xc2\xf6\x89\x1b\x89\x22\x73\x85\x20\x4e\xe6\x10\x01\x42\x4a\x2e\xc8"
      "\xca\x89\x4b\x24\x62\x89\x4b\x4e\x81\x03\x07\x2c\x23\x45\xe2\x00\x01\x7b"
      "\xd0\xee\x54\xcd\xce\xd4\xce\xd0\xb3\xde\xc7\xbc\xbe\x4f\xaa\xad\xa9\xae"
      "\x9e\xa9\xea\xde\xee\x9e\x9e\xee\xae\xaa\x00\x8c\xad\xca\xf2\xdf\x85\x85"
      "\x99\x22\x84\xab\x6f\xbf\x7e\xf2\x6f\x0f\xfe\x75\x7a\x69\xca\x63\xcd\x39"
      "\x6a\xcb\x7f\x27\x5b\x52\xd5\x10\x42\x11\xd3\x93\xd9\xe7\x7d\x30\xd1\x88"
      "\x6f\x7f\xf8\xca\xd9\x4e\x71\x11\xe6\x97\xff\xa6\x74\x78\xea\x56\xf3\xbd"
      "\x3b\x43\x08\x97\xc2\xa1\x70\x3d\xd4\xc2\xfe\xab\x37\x5e\x7b\x77\xfe\xc9"
      "\xd3\x97\x4f\x5d\x39\xfc\xde\xb5\xe3\x37\x37\x67\xe9\x01\x00\x60\xbc\x7c"
      "\xf3\xfa\xf1\x85\x7d\x7f\xfe\xe3\x81\x3d\x1f\xbd\x79\xff\x89\xb0\xad\x39"
      "\x3d\x9d\x9f\xd7\x62\x7a\x57\x3c\xef\x3f\x11\x4f\xfc\xd3\xf9\x7f\x25\xb4"
      "\xa7\x8b\x96\xd0\x6a\x2a\x9b\x6f\x32\x86\x4a\x36\xdf\x44\x87\xf9\x5a\xcb"
      "\xa9\x66\xf3\x4d\x76\x29\x7f\x2a\xfb\xdc\x6a\x33\xff\x40\xdb\x7c\xdb\x4a"
      "\xca\x9f\x68\x99\xd6\x69\xb9\x61\x98\xa5\xed\xb8\x16\x8a\xca\x6c\x5b\xba"
      "\x52\x99\x9d\x6d\xfc\x26\x0f\xcb\xbf\xeb\xa7\x8a\xd9\x0b\xe7\x17\x9f\xbb"
      "\xd8\xa7\x8a\x02\x1b\xee\x1f\x0f\x84\x10\x0e\x6d\x6a\xa8\xd7\xeb\xf5\x46"
      "\x61\x9b\x5b\xce\x96\x86\x7a\xbd\xfe\xa3\x51\x5b\x26\x61\xfc\x42\x7d\x77"
      "\x7f\x8f\x3f\x00\x49\x7e\xbf\x70\x95\x4b\xf9\x95\x85\xf5\x69\x7e\xda\x64"
      "\x6f\xe5\xdf\x7a\xbc\xd2\xf9\xfd\xb0\x01\xb6\x7a\xfb\x57\xfe\x70\x95\xff"
      "\xcb\xcb\x8e\x38\x6c\x9c\x51\xdd\x9a\xd2\x72\xa5\xfd\x68\x57\x4c\xe7\xf7"
      "\x11\xf2\xe7\x97\xd6\xba\xff\xa7\xcf\xcb\xef\x47\x54\x7b\xac\x67\xb7\xfb"
      "\x08\xc3\x72\x7f\xa1\x5b\x3d\x27\xb6\xb8\x1e\x77\xab\x5b\xfd\xf3\xed\x62"
      "\x54\x7d\x2d\xc6\x69\x3d\x7c\x3d\xcb\x6f\xdd\x7f\xf2\xff\xe9\xb0\xfc\x8f"
      "\x81\xce\xfe\xb9\xf9\xd7\xff\x1b\xe1\x8d\xe9\xbe\x5f\xeb\x5c\x0a\x87\x06"
      "\xa0\x0e\x23\x1d\xaa\x03\x50\x07\xa1\xe7\x50\xef\xf7\x01\x08\x18\x58\x2b"
      "\xcf\xcd\x35\xd4\xa3\x94\x9f\x3f\xd7\x97\xe7\x6f\x2b\xc9\xdf\x5e\x92\x3f"
      "\x5d\x92\xbf\xa3\x24\x7f\x67\x49\x3e\x8c\xb3\xdf\xbe\xf8\x93\xf0\x6a\xb1"
      "\xf2\x3b\x3f\xff\x4d\xbf\xd6\xeb\x61\xe9\x3a\xdb\x3d\x31\xfe\xbf\x35\xd6"
      "\x27\xbf\x1e\xb9\xd6\xf2\xf3\xe7\x7e\xd7\x6a\xbd\xe5\xe7\xcf\x13\xc3\x20"
      "\x7b\xeb\xcc\xd3\xe7\xbe\xfc\xec\x33\x37\x1a\xcf\xff\x17\xcd\xed\xff\x4e"
      "\xdc\xde\x0f\xc5\x74\x2d\xee\x5b\xd7\xe3\x0c\xe9\x7a\x61\xda\xdf\xaf\xc5"
      "\xb8\xf9\xec\x7f\xad\xbd\x9c\x4a\x16\xa7\xf9\xee\xcd\xea\x73\xcf\xaa\xf9"
      "\xeb\x8d\x12\xf7\xb6\xcf\x57\xec\x5d\xf9\x9c\xd0\x72\x9c\xc9\x3f\x3f\xcc"
      "\xb4\xbf\x6f\x77\xb7\xf9\x0e\xb6\xcf\x57\xcb\xe6\x9b\x8e\x61\x7b\x56\xdf"
      "\xfc\xfc\x64\x47\xf6\xbe\x74\xfe\x91\x8e\xab\x69\x7d\x4d\x66\xcb\x5b\xcd"
      "\x96\x63\x2a\xab\x47\x3a\xae\xec\x89\x71\x5e\x0f\xb8\x1b\x69\x7b\xec\xf6"
      "\xfc\x7f\xda\x3e\x67\x42\xb5\x78\xee\xfc\xe2\xb9\x47\x63\x3a\x6d\xa7\x7f"
      "\x98\xa8\x6e\x5b\x9a\x7e\xa4\xf5\x43\x7f\xb5\x35\x75\x07\xd6\xa7\xd7\xf6"
      "\x3f\x33\xa1\xbd\xfd\xcf\xae\xe6\xf4\x6a\xa5\xf5\xb8\xb0\x7b\x65\x7a\xd1"
      "\x7a\x5c\xa8\x65\xd3\xe7\x1b\xc9\xe6\x6d\xf2\x34\xfd\x68\x4c\xa7\xef\xb9"
      "\x6f\x4f\x4c\x2f\x4f\x9f\x3d\xfb\xdd\xc5\x67\x37\x7a\xe1\x61\xcc\x5d\x7c"
      "\xe9\xe5\xef\x9c\x59\x5c\x3c\xf7\x7d\x2f\xd2\x8b\x69\xab\xc5\x0b\x2f\xca"
      "\x8e\x1c\xa3\xfa\xe4\x20\x8c\x8f\xb9\x17\x5f\xf8\xde\xdc\xc5\x97\x5e\x7e"
      "\xe4\xfc\x0b\x67\x9e\x3f\xf7\xfc\xb9\x0b\x47\x8f\x1d\x3b\x3a\x3f\x7f\xec"
      "\x2b\x47\x17\xe6\x96\xcf\xeb\xe7\x5a\xcf\xee\x81\x51\xb2\xf2\xa5\xdf\xef"
      "\x9a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbd\xfa\xc1\xa9\x93\x37\xfe"
      "\xf4\xce\x97\xde\x6f\xb4\xff\x5f\x69\xff\x97\xda\xff\xa7\x27\x7f\x53\xfb"
      "\xff\x1f\x67\xed\xff\xf3\x76\xf2\xa9\x55\x40\x6a\x07\xb8\xa7\x43\xfe\xf2"
      "\xb8\x7b\x6f\xb5\xd7\x63\x2a\x9b\xaf\x1a\xc3\xff\x67\xf5\xdd\x1b\x5b\xbe"
      "\xa7\x72\xf6\x65\xef\xfb\x58\x8c\x9b\xe3\xf8\xc5\xf6\xff\xa9\xbd\x7d\xde"
      "\xaf\x6b\xaa\xcf\x7d\xd9\xf4\xbc\xff\xde\x34\x5f\xd6\x9d\xc0\xaa\xfe\x52"
      "\xa6\xb2\x3e\x48\x9a\xe3\x05\xc6\x06\xfb\x9f\x8c\xe9\x2b\x31\xfe\x45\x80"
      "\x3e\x2a\xa6\x3b\x4f\x8e\x71\x59\xff\xd6\x69\x5b\x4f\xfd\x53\xe8\x97\x62"
      "\x38\xa5\xff\x5b\xda\x1a\x52\x3f\x26\xa9\xfd\x77\xb7\x7e\x9d\xd2\xf1\x7f"
      "\xcf\x16\xd4\x91\x8d\xb7\x15\xcd\x09\xfb\xbd\x8c\x40\x67\x7f\xdf\xaa\xfe"
      "\xbf\xef\x3a\xb4\x9c\x89\xf7\xbd\x2e\xff\x33\xd4\xeb\xfd\xaf\xc3\xfa\xc3"
      "\xe0\xaf\x67\x61\x03\x43\xbd\x6e\x14\x0f\x60\x30\xf4\x7b\xfc\xcf\x74\xdd"
      "\x33\xc5\x17\x7e\xff\x8d\xed\x4b\x21\xcd\x76\xeb\xf1\xf6\xe3\x65\xde\x7f"
      "\x29\xac\xc7\xa0\x8f\x3f\xa9\xfc\xd1\x1a\xff\xb3\x39\xfe\x5d\x4f\xc7\xbf"
      "\x0e\xbd\xab\xb7\xf5\xf3\xdc\xfb\xe8\x0a\xff\xfa\xd9\xcd\xf7\x5b\x8a\x0d"
      "\xfb\x7b\x3d\xfe\xe6\xcb\x9f\xfa\x81\xde\x5b\x5e\x66\xab\x8f\x62\xf9\x69"
      "\xf9\x1f\x0a\xbd\x95\x5f\x7f\x23\x2b\x3f\xbf\x21\xd4\xd9\xaa\xe1\x04\xff"
      "\x9d\x95\xbf\xa3\xc7\xf2\x57\x2d\xff\xc1\x9e\xca\x5f\xe5\x3f\xb1\xfc\xb4"
      "\xda\x1e\xfe\x54\xaf\xe5\x37\x6a\x5c\x64\x03\x27\xe6\xd7\x8d\xd3\xfd\xbf"
      "\xfc\xba\x71\x72\x3b\x5b\xfe\xd4\xb7\xe7\x9a\x97\xff\x2e\x07\x6a\xbc\x13"
      "\xcb\x87\x71\xd6\x7d\x9c\xd9\x5e\x47\xb0\x1d\x4c\xc3\x32\xfe\x6f\x37\xf9"
      "\x73\x18\x5f\x8c\xe9\x74\x20\x4c\xcf\x39\xe4\xdf\xc8\x6b\xad\x7f\x7a\xbe"
      "\x22\x7d\x0f\xec\xcb\x3e\xbf\x28\xf9\x7e\x1b\x96\x71\x8a\xbb\x19\xf7\xf1"
      "\x7f\xbf\x1a\xe3\xb2\xfd\x21\x8d\xff\x9b\xb6\xc7\x5a\x87\x74\xa5\x25\x5d"
      "\xed\xb0\x6e\x87\x7d\x5b\x81\x51\xf3\xc1\xc0\xdf\xff\x1b\xb2\x70\x69\x00"
      "\xea\x20\x0c\x68\x18\x8c\x31\xb0\x5b\x43\xbd\x5e\xef\x6b\x47\xde\x7a\x11"
      "\xef\xaf\x7e\xaf\xff\x7e\xdf\x7d\xee\x77\xf9\xfd\x5e\xff\x65\xf2\xf1\x7f"
      "\xf3\x73\xf8\x7c\xfc\xdf\x4a\xf6\x03\x22\x1f\xff\x37\x7f\x7f\x3e\xfe\x6f"
      "\x9e\x9f\x8f\xaf\x97\xe7\xe7\xe3\xff\xe6\xeb\x33\x1f\xff\x37\xcf\xbf\x2f"
      "\xfb\xdc\xfc\x0a\xf6\x4c\x49\xfe\xc7\x4b\xf2\xf7\x97\xe4\x1f\x58\xc9\x9f"
      "\xee\x94\x7f\xb0\xe4\xfd\x9f\x28\xc9\x3f\x5c\x92\x7f\x7f\x49\xfe\x03\x25"
      "\xf9\xf7\x96\xe4\x4f\x94\xe4\x7f\xba\x24\xff\x33\x25\xf9\x0f\x96\xe4\x3f"
      "\x5c\x92\xff\xd9\x92\xfc\x51\xb7\xdc\x1e\xa5\x65\xa7\x1a\xb7\xe5\x87\x71"
      "\x96\xb7\xcf\xb3\xff\xc3\xf8\x48\xf7\x7f\xba\xed\xff\x7b\x4b\xf2\x81\xe1"
      "\xf5\xd3\x37\x8f\x3c\xf1\xcc\x6f\xbe\x55\x6b\xb4\xff\x9f\x6a\xfe\x5e\x4b"
      "\xf7\xf1\x4e\xc4\x74\x35\xfe\x76\xfe\x61\x4c\xe7\xf7\xbd\x43\x4b\x7a\x29"
      "\xef\x9d\x98\xfe\x4b\x96\x3f\xe8\xd7\x3b\x60\x9c\xe4\xfd\x67\xe4\xdf\xef"
      "\x0f\x95\xe4\x03\xc3\x2b\x3d\xe7\x65\xff\x86\x31\x54\x74\xee\xb1\x27\xbf"
      "\xdf\xd6\xad\xdf\xaa\x6e\xe7\xf9\x0c\x97\xcf\xc5\xf8\xf3\x31\xfe\x42\x8c"
      "\x1f\x89\xf1\x6c\x8c\xe7\x62\x7c\x24\xc6\xf3\x5b\x54\x3f\x36\xc7\x13\xbf"
      "\xfe\xdd\xf1\x57\x8b\x95\xdf\xfb\xbb\xb3\xfc\x5e\x9f\x27\x2f\x2a\xed\xbf"
      "\xec\xf3\x7e\xa2\x8e\xf6\x58\x9f\xfc\xfa\xc0\x5a\x9f\x67\xcf\xfb\xf1\x5b"
      "\xab\xf5\x96\xdf\x5b\x73\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xc1\x51\x59\xfe\xbb"
      "\xb0\x30\x53\x84\x70\xf5\xed\xd7\x4f\x3e\x7d\xfa\xfc\xdc\xd2\x94\xc7\x9a"
      "\x73\xd4\x96\xff\x4e\xb6\xa4\xaa\xcd\xf7\x85\xf0\x68\x8c\x27\x62\xfc\xf3"
      "\xf8\xe2\xf6\x87\xaf\x9c\x6d\x8d\xef\xc4\xb8\x08\xf3\xa1\x08\x45\x73\x7a"
      "\x78\xea\x56\xb3\xa4\x9d\x21\x84\x4b\xe1\x50\xb8\x1e\x6a\x61\xff\xd5\x1b"
      "\xaf\xbd\x3b\xff\xe4\xe9\xcb\xa7\xae\x1c\x7e\xef\xda\xf1\x9b\x9b\xb7\x06"
      "\x00\x00\x00\x60\xf4\xfd\x37\x00\x00\xff\xff\xa9\x99\x1f\x77",
      2697);
  syz_mount_image(/*fs=*/0x20000000, /*dir=*/0x20000040, /*flags=*/0,
                  /*opts=*/0x20000440, /*chdir=*/3, /*size=*/0xa89,
                  /*img=*/0x200070c0);
  memcpy((void*)0x20000140, "./file2\000", 8);
  res = syscall(
      __NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000140ul,
      /*flags=O_NOCTTY|O_NOATIME|O_LARGEFILE|O_CREAT|FASYNC|0x1002*/ 0x4b142ul,
      /*mode=*/0ul);
  if (res != -1)
    r[0] = res;
  syscall(__NR_write, /*fd=*/r[0], /*arg=*/0x20000000ul, /*len=*/0x4000ul);
}
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;
}