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