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