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

#define _GNU_SOURCE

#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.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/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include <linux/loop.h>

#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif

static unsigned long long procid;

//% 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;
}

uint64_t r[1] = {0xffffffffffffffff};

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);
  intptr_t res = 0;
  memcpy((void*)0x20000080, "udf\000", 4);
  memcpy((void*)0x20000180, "./file1\000", 8);
  memcpy((void*)0x20000540,
         "lastblock=00000000000000000000,umask=00000000000000000000002,dmode="
         "00000000000000000077777,novrs,shortad,shortad,undelete,iocharset="
         "cp437,shortad,umask=00000000000000000000006,dmode="
         "00000000000000000000011,fileset=00000000000000000011,uid=",
         239);
  sprintf((char*)0x2000062f, "%020llu", (long long)-1);
  memcpy((void*)0x20000643,
         "\x2c\x73\x58\x0a\x65\x73\x73\x69\x02\xdf\x00\x00\xe2\xeb\x86\x77\x01"
         "\x1f\x00\x29\x00\x00\x00\x00\x00\x00\x00\x30\x30\x01\x00\x30\x30\x35"
         "\x30\x5d\x28\x8f\x2a\x7c\xf9\xfb\x7d\xfc\x95\x83\x97\xf3\x53\x77\xe1"
         "\x95\xd9\xf9\x84\xd8\xcc\xd4\xeb\x9a\x74\xc8\x22\x3b\x0f\x36\xe0\xf4"
         "\xfd\x88\x98\x96\x21\x4e\xeb\x5f\x9d\xdf\xdf\x33\xd1\xbb\x5a\x49\xae"
         "\xf0\x25\xc9\x21\x22\x0b\x5f\xb5",
         93);
  memcpy(
      (void*)0x20001600,
      "\x78\x9c\xec\xdd\x4f\x6c\x1c\xd7\x7d\x07\xf0\xdf\x1b\xed\x8a\x2b\xb9\xad"
      "\x98\xd8\x51\x9c\x34\x2e\x36\x6d\x91\xca\x8a\xe5\xea\x5f\x4c\xc5\x2a\xdc"
      "\x55\x4d\xb3\x0d\x20\xcb\x42\x28\xe6\x16\x80\x2b\x71\xa5\x2e\x4c\x91\x04"
      "\x49\x35\xb2\x91\x16\x4c\x2f\x3d\xf4\x10\xa0\x28\x7a\xc8\x89\x40\x6b\x14"
      "\x48\xd1\xc0\x68\x8a\xa0\x47\xa6\x75\x81\xe4\xe2\x43\x91\x53\x4f\x44\x0b"
      "\x1b\x41\xd1\x03\x5b\x04\x08\x7a\x08\x58\xcc\xec\x5b\x71\x45\x51\x36\x2d"
      "\x8a\x12\x65\x7d\x3e\x36\xf5\xdd\x9d\x7d\x6f\xe6\xbd\x79\xeb\x19\x59\xd0"
      "\x9b\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\xc4\xef"
      "\xbd\x72\xee\xf8\x89\xf4\xb0\x5b\x01\x00\x3c\x48\x17\xc6\xbf\x7a\xfc\xa4"
      "\xfb\x3f\x00\x3c\x56\x2e\xf9\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\xd8\xeb\x52\x14\xf1\x64\xa4\x98\xbb\xb0\x96\x26\xab\xf7\x3d\x8d"
      "\xf3\xdd\xfa\x8d\x9b\x13\xa3\x63\x5b\x57\x3b\x90\xaa\x9a\xfb\xaa\xf2\xe5"
      "\x4f\xe3\xc4\xc9\x53\xa7\xbf\xf4\xc2\xc8\x99\x7e\x9e\xef\xce\x7c\x40\xfd"
      "\xfb\xed\xb3\xf1\xda\xf8\xa5\x73\xcd\x97\x67\xaf\xcf\xcd\x77\x16\x16\x3a"
      "\x53\xcd\x89\x99\xee\x95\xd9\xa9\xce\xb6\xf7\xb0\xd3\xfa\x9b\x1d\xad\x4e"
      "\x40\xf3\xfa\xeb\x37\xa6\xae\x5e\x5d\x68\x9e\x7c\xfe\xd4\x6d\x1f\xdf\x1c"
      "\x7e\x7f\xe8\x89\xc3\xc3\x67\x47\x9e\x3d\xf6\x4c\xbf\xec\xc4\xe8\xd8\xd8"
      "\xf8\x46\x91\xc6\x60\xf9\xda\x3d\x37\xa4\xe7\x6e\x33\x3c\xf6\x47\x11\xc7"
      "\x22\xc5\x73\xdf\xfb\x69\x6a\x47\x44\x11\x3b\x3f\x17\x8d\x07\x3b\xf6\x9b"
      "\x1d\xa8\x3a\x71\xb4\xea\xc4\xc4\xe8\x58\xd5\x91\xe9\x6e\x7b\x66\xb1\xfc"
      "\xf0\x62\xff\x44\x14\x11\xcd\x81\x4a\xad\xfe\x39\xda\x7a\x2c\xa2\x56\x7f"
      "\xa0\x7d\xb8\xbb\x56\xc4\x52\xd9\xfc\xb2\xc1\x47\xcb\xee\x8d\xcf\xb5\xe7"
      "\xdb\x97\xa7\x3b\xcd\x8b\xed\xf9\xc5\xee\x62\x77\x76\xe6\x62\xea\xb5\xb6"
      "\xec\x4f\x33\x8a\x38\x93\x22\x96\x23\x62\x75\xe8\xce\xdd\xd5\xa3\x88\x5a"
      "\xa4\xf8\xce\xa1\xb5\x74\x39\x22\xf6\xf5\xcf\xc3\x17\xab\x89\xc1\x77\x6f"
      "\x47\xb1\x8b\x7d\xdc\x86\xb2\x9d\xcd\x7a\xc4\x72\xf1\x08\x8c\xd9\x1e\x36"
      "\x14\x45\xbc\x1a\x29\x7e\xf6\xce\x91\xb8\x92\xaf\x33\xd5\xb5\xe6\x0b\x11"
      "\xaf\x96\xf9\x83\x88\xb7\xca\x7c\x29\x22\x95\x5f\x8c\xd3\x11\xef\x6d\xf1"
      "\x3d\xe2\xd1\x54\x8b\x22\xfe\xbc\x1c\xff\xb3\x6b\x69\xaa\xba\x1e\xf4\xaf"
      "\x2b\xe7\xbf\xd6\xfc\xca\xcc\xd5\xd9\x81\xb2\xfd\xeb\xca\x47\xbc\x3f\xdc"
      "\x71\xa5\x78\x48\xf7\x87\x03\x9b\xf2\xc1\xd8\xe3\xd7\xa6\x46\x14\xd1\xae"
      "\xae\xf8\x6b\xe9\xde\x7f\xb3\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\xc0\xfd\x76\x20\x8a\xf8\x4c\xa4\x78\xe5\xdf\xfe\xa8\x9a\x57\x1c"
      "\xd5\xbc\xf4\x43\x67\x47\x7e\x7f\xf8\x97\x07\xe7\x8c\x3f\xfd\x21\xfb\x29"
      "\xcb\x3e\x1f\x11\x4b\xc5\xf6\xe6\xe4\xee\xcf\x13\x03\x2f\xa6\x8b\x29\x3d"
      "\xe4\xb9\xc4\x8f\xb3\x46\x14\xf1\xc7\x79\xfe\xdf\xb7\x1e\x76\x63\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x6b\x45\xfc\x24"
      "\x52\xbc\xf8\xee\x91\xb4\x1c\x83\x6b\x8a\x77\x67\xae\x35\x2f\xb5\x2f\x4f"
      "\xf7\x56\x85\xed\xaf\xfd\xdb\x5f\x33\x7d\x7d\x7d\x7d\xbd\x99\x7a\xd9\xca"
      "\x39\x99\x73\x29\xe7\x72\xce\x95\x9c\xab\x39\xa3\xc8\xf5\x73\xb6\x72\x4e"
      "\x56\x59\xaf\x9e\x21\x50\xd5\xcf\xb9\x92\x73\x35\x67\xec\xcb\xf5\x73\xb6"
      "\x72\x4e\xe6\x5c\xca\xb9\x9c\x73\x25\xe7\x6a\xce\xa8\xe5\xfa\x39\x5b\x39"
      "\x27\x73\x2e\xe5\x5c\xce\xb9\x92\x73\x35\x67\xec\x91\xb5\x7b\x01\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x3e\x4e\x8a\x28\xe2\x17\x91\xe2\xdb\xdf"
      "\x58\x4b\x91\x22\xa2\x15\x31\x19\xbd\x5c\x19\x7a\xd8\xad\x03\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4a\x43"
      "\xa9\x88\xef\x47\x8a\xe6\x1f\xb4\x6e\x6d\xab\x45\x44\xaa\xfe\xed\x39\x52"
      "\xfe\x72\x3a\x5a\xfb\xcb\xfc\x64\xb4\x46\xca\x7c\x29\x5a\xe7\x72\xb6\xab"
      "\xac\xb5\xbe\xf5\x10\xda\xcf\xce\xd4\x53\x11\x3f\x8e\x14\x43\x8d\xb7\x6f"
      "\x0d\x78\x1e\xff\x7a\xef\xdd\xad\xaf\x41\xbc\xf5\xcd\x8d\x77\x9f\xad\xf5"
      "\x72\x5f\xff\xc3\xe1\xf7\x87\x9e\x38\x7c\xe8\xec\xc8\xd8\xaf\x3d\x7d\xb7"
      "\xd7\x69\xab\x06\x1c\x3d\xdf\x9d\xb9\x71\xb3\x39\x31\x3a\x36\x36\x3e\xb0"
      "\xb9\x96\x8f\xfe\xc9\x81\x6d\xc3\xf9\xb8\xc5\xfd\xe9\x3a\x11\xb1\xf0\xc6"
      "\x9b\xaf\xb7\xa7\xa7\x3b\xf3\xf7\xfe\xa2\xfc\x0a\xec\xa0\xfa\x23\xf4\x22"
      "\xd5\x1e\x97\x9e\x7a\x51\xbd\x88\xda\x9e\x68\xc6\xc3\xe9\x3b\x8f\x81\xf2"
      "\xfe\xff\x5e\xa4\xf8\xed\x77\xff\xbd\x7f\xc3\xef\xdd\xff\x1b\xf1\x4b\xbd"
      "\x77\xb7\xee\xf0\xf1\xf3\x3f\xd9\xb8\xff\xbf\xb8\x79\x47\xdb\xbc\xff\xd7"
      "\x36\xd7\xcb\xf7\xff\xf2\x9e\xbe\xd5\xfd\xff\xc9\x81\x6d\x2f\xe6\xdf\x8d"
      "\xd4\x6b\x11\x8d\xc5\xeb\x73\xf5\xc3\x11\x8d\x85\x37\xde\x3c\xd6\xbd\xde"
      "\xbe\xd6\xb9\xd6\x99\x39\x7d\xfc\xf8\x97\x47\x46\xbe\x7c\xea\x78\x7d\x7f"
      "\x44\xe3\x6a\x77\xba\x33\xf0\xea\xbe\x9c\x2e\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x80\x07\x27\x15\xf1\xbb\x91\xa2\xfd\xe3\xb5\xd4\x8c"
      "\x88\x9b\xd5\x7c\xad\xe1\xb3\x23\xcf\x1e\x7b\x66\x5f\xec\xab\xe6\x5b\xdd"
      "\x36\x6f\xfb\xb5\xf1\x4b\xe7\x9a\x2f\xcf\x5e\x9f\x9b\xef\x2c\x2c\x74\xa6"
      "\x9a\x13\x33\xdd\x2b\xb3\x53\x9d\xed\x1e\xae\x51\x4d\xf7\x9a\x18\x1d\xdb"
      "\x95\xce\x7c\xa8\x03\xbb\xdc\xfe\x03\x8d\x97\x67\xe7\xde\x98\xef\x5e\xfb"
      "\xc3\xc5\x2d\x3f\x3f\xd8\x38\x77\x79\x61\x71\xbe\x7d\x65\xeb\x8f\xe3\x40"
      "\x14\x11\xad\xc1\x2d\x47\xab\x06\x4f\x8c\x8e\x55\x8d\x9e\xee\xb6\x67\xaa"
      "\xaa\x17\xb7\x9c\x4c\xff\xd1\xd5\x53\x11\xff\x11\x29\xae\x9c\x6e\xa6\xcf"
      "\xe7\x6d\x79\xfe\xff\xe6\x19\xfe\xb7\xcd\xff\x5f\xda\xbc\xa3\x5d\x9a\xff"
      "\xff\x89\x81\x6d\xe5\x31\x53\x2a\xe2\xe7\x91\xe2\xb7\xfe\xe2\xe9\xf8\x7c"
      "\xd5\xce\x83\x71\xc7\x39\xcb\xe5\xfe\x26\x52\x1c\x3d\xf3\xb9\x5c\x2e\xf6"
      "\x97\xe5\xfa\x6d\xe8\x3d\x57\xa0\x37\x33\xb0\x2c\xfb\x3f\x91\xe2\x1f\x7e"
      "\x71\x7b\xd9\xfe\x7c\xc8\x27\x37\xca\x9e\xd8\xf6\x89\x7d\x44\x94\xe3\x7f"
      "\x28\x52\x7c\xff\xcf\xbe\x1b\xbf\x9e\xb7\xdd\xfe\xfc\x87\xad\xc7\xff\xe0"
      "\xe6\x1d\xed\xd2\xf8\x3f\x35\xb0\xed\x60\xff\x79\x05\xff\xb7\xde\x99\x5f"
      "\xd8\x71\xd7\xc9\xe3\x7f\x2c\x52\xbc\xf4\xe4\xdb\xf1\x1b\x79\xdb\x07\x3d"
      "\xff\xa3\xff\xec\x8d\x23\xb9\xf0\xad\xe7\x73\xec\xd2\xf8\x7f\x6a\x60\xdb"
      "\x70\x3e\xee\x6f\xde\x9f\xae\x03\x00\x00\x00\x00\x00\x00\x00\x00\x3c\xd2"
      "\xea\xa9\x88\xbf\x8d\x14\x3f\x1c\xab\xa5\x17\xf2\xb6\xed\xfc\xfd\xbf\xa9"
      "\xcd\x3b\xda\xa5\xbf\xff\xf5\xe9\x81\x6d\x53\xf7\x67\xbd\xa2\x0f\x7d\xb1"
      "\xe3\x93\x0a\x00\x00\x00\x00\x7b\x44\x3d\x15\xf1\x93\x48\x71\x6d\xf1\xed"
      "\x5b\x73\xa8\x6f\x9f\xff\x3d\x30\xff\xf3\x77\x36\xe6\x7f\x8e\xa6\x4d\x9f"
      "\x56\x7f\xce\xf7\x2b\xd5\x73\x03\xee\xe7\x9f\xff\x0d\x1a\xce\xc7\x9d\xdc"
      "\x79\xb7\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60"
      "\x4f\x49\xa9\x88\x17\xf2\x7a\xea\x93\xd5\x7c\xfe\xa9\xbb\xae\xa7\xbe\x12"
      "\x29\x5e\xf9\xaf\xe7\x72\xb9\x74\xb8\x2c\xd7\x5f\x07\x7e\xb8\xfa\xb5\x71"
      "\x61\x76\xe6\xd8\xb9\xe9\xe9\xd9\x2b\xed\xc5\xf6\xe5\xe9\x4e\x73\x7c\xae"
      "\x7d\xa5\x53\xd6\x7d\x2a\x52\xac\xfd\xf5\xe7\x72\xdd\xa2\x5a\x5f\xbd\xbf"
      "\xde\x7c\x6f\x8d\xf7\x8d\xb5\xd8\xe7\x23\xc5\xd8\xdf\xf5\xcb\xf6\xd6\x62"
      "\xef\xaf\x4d\xfe\xd4\x46\xd9\x13\x65\xd9\x4f\x44\x8a\xff\xfc\xfb\xdb\xcb"
      "\xf6\xd7\xb1\xfe\xd4\x46\xd9\x93\x65\xd9\xbf\x8a\x14\x5f\xff\xa7\xad\xcb"
      "\x1e\xde\x28\x7b\xaa\x2c\xfb\xdd\x48\xf1\xa3\xaf\x37\xfb\x65\x0f\x96\x65"
      "\xfb\xcf\x47\xfd\xf4\x46\xd9\xe7\xaf\xcc\x16\xbb\x30\x2a\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x6e\xea\xa9\x88\x3f\x8d"
      "\x14\xff\x7d\x7d\xf9\xd6\x5c\xfe\xbc\xfe\x7f\x7d\xe0\x6d\xe5\xad\x6f\x0e"
      "\xac\xf7\xbf\xc9\xcd\x6a\x9d\xff\xe1\x6a\xfd\xff\xbb\xbd\xbe\x97\xf5\xff"
      "\xab\xe7\x0a\x2c\xdd\xed\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\xf0\xf1\x94\xa2\x88\x37\x23\xc5\xdc\x85\xb5\xb4"
      "\x32\x54\xbe\xef\x69\x9c\xef\xce\xdc\xb8\x39\x31\x3a\xb6\x75\xb5\x03\xa9"
      "\xaa\xb9\xaf\x2a\x5f\xfe\x34\x4e\x9c\x3c\x75\xfa\x4b\x2f\x8c\x9c\xe9\xe7"
      "\x07\xd7\xbf\xdf\x3e\x13\xaf\x8d\x5f\x3a\xd7\x7c\x79\xf6\xfa\xdc\x7c\x67"
      "\x61\xa1\x33\xd5\x9c\x98\xe9\x5e\x99\x9d\xea\x6c\x7b\x0f\x3b\xad\xbf\xd9"
      "\xd1\xea\x04\x34\xaf\xbf\x7e\x63\xea\xea\xd5\x85\xe6\xc9\xe7\x4f\xdd\xf6"
      "\xf1\xcd\xe1\xf7\x87\x9e\x38\x3c\x7c\x76\xe4\xd9\x63\xcf\xf4\xcb\x4e\x8c"
      "\x8e\x8d\x8d\x0f\x94\xa9\xd5\xef\xf9\xe8\x77\x48\x77\xd9\xbe\x3f\x8a\xf8"
      "\xcb\x48\xf1\xdc\xf7\x7e\x9a\x7e\x38\x14\x51\xc4\xce\xcf\xc5\x87\x7c\x77"
      "\x76\xdb\x81\xaa\x13\x47\xab\x4e\x4c\x8c\x8e\x55\x1d\x99\xee\xb6\x67\x16"
      "\xcb\x0f\x2f\xf6\x4f\x44\x11\xd1\x1c\xa8\xd4\xea\x9f\xa3\x07\x30\x16\x3b"
      "\xd2\x8a\x58\x2a\x9b\x5f\x36\xf8\x68\xd9\xbd\xf1\xb9\xf6\x7c\xfb\xf2\x74"
      "\xa7\x79\xb1\x3d\xbf\xd8\x5d\xec\xce\xce\x5c\x4c\xbd\xd6\x96\xfd\x69\x46"
      "\x11\x67\x52\xc4\x72\x44\xac\x0e\xdd\xb9\xbb\x7a\x14\xf1\x7a\xa4\xf8\xce"
      "\xa1\xb5\xf4\xcf\x43\x11\xfb\xfa\xe7\xe1\x8b\x17\xc6\xbf\x7a\xfc\xe4\xdd"
      "\xdb\x51\xec\x62\x1f\xb7\xa1\x6c\x67\xb3\x1e\xb1\x5c\x3c\x02\x63\xb6\x87"
      "\x0d\x45\x11\xff\x18\x29\x7e\xf6\xce\x91\xf8\x97\xa1\x88\x5a\xf4\x7e\xe2"
      "\x0b\x11\xaf\x96\xf9\x83\x88\xb7\xa2\x37\xde\xa9\xfc\x62\x9c\x8e\x78\x6f"
      "\x8b\xef\x11\x8f\xa6\x5a\x14\xf1\xbf\xe5\xf8\x9f\x5d\x4b\xef\x0c\x95\xd7"
      "\x83\xfe\x75\xe5\xfc\xd7\x9a\x5f\x99\xb9\x3a\x3b\x50\xb6\x7f\x5d\x79\xe4"
      "\xef\x0f\x0f\xd2\x1e\xbf\x36\x35\xa2\x88\x1f\x55\x57\xfc\xb5\xf4\xaf\xfe"
      "\xbb\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\x43\x8a\xf8"
      "\xd5\x48\xf1\xe2\xbb\x47\x52\x35\x3f\xf8\xd6\x9c\xe2\xee\xcc\xb5\xe6\xa5"
      "\xf6\xe5\xe9\xde\xb4\xbe\xfe\xdc\xbf\xfe\x9c\xe9\xf5\xf5\xf5\xf5\x66\xea"
      "\x65\x2b\xe7\x64\xce\xa5\x9c\xcb\x39\x57\x72\xae\xe6\x8c\x22\xd7\xcf\xd9"
      "\x2a\xb3\xb1\xbe\x3e\x99\xdf\x2f\xe5\x5c\xce\xb9\x92\x73\x35\x67\xec\xcb"
      "\xf5\x73\xb6\x72\x4e\xe6\x5c\xca\xb9\x9c\x73\x25\xe7\x6a\xce\xa8\xe5\xfa"
      "\x39\x5b\x39\x27\x73\x2e\xe5\x5c\xce\xb9\x92\x73\x35\x67\xec\x91\xb9\x7b"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xc7\x4b\x51"
      "\xfd\x93\xe2\xdb\xdf\x58\x4b\xeb\x43\xbd\xf5\xa5\x27\xa3\x97\x2b\xd6\x03"
      "\xfd\xd8\xfb\xff\x00\x00\x00\xff\xff\xde\x2c\xf7\xd2",
      3127);
  syz_mount_image(/*fs=*/0x20000080, /*dir=*/0x20000180,
                  /*flags=MS_REC*/ 0x4000, /*opts=*/0x20000540, /*chdir=*/2,
                  /*size=*/0xc37, /*img=*/0x20001600);
  memcpy((void*)0x20000140, "./file0\000", 8);
  syscall(__NR_chdir, /*dir=*/0x20000140ul);
  memcpy((void*)0x20000d00,
         "./"
         "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000",
         255);
  syscall(__NR_creat, /*file=*/0x20000d00ul, /*mode=*/0ul);
  memcpy((void*)0x20000e00, "./file0\000", 8);
  memcpy((void*)0x20001080,
         "./"
         "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000",
         257);
  syscall(__NR_rename, /*old=*/0x20000e00ul, /*new=*/0x20001080ul);
  memcpy((void*)0x20000000, ".\000", 2);
  res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000000ul,
                /*flags=*/0ul, /*mode=*/0ul);
  if (res != -1)
    r[0] = res;
  syscall(__NR_getdents64, /*fd=*/r[0], /*ent=*/0x20000f80ul,
          /*count=*/0x1000ul);
  return 0;
}