// https://syzkaller.appspot.com/bug?id=b30ea69cb87bce1089eefd3969b308f63c4e218c
// 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[2] = {0xffffffffffffffff, 0xffffffffffffffff};

int main(void)
{
  syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul,
          /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul);
  intptr_t res = 0;
  memcpy((void*)0x20000040, "ext4\000", 5);
  memcpy((void*)0x20000500, "./file1\000", 8);
  *(uint16_t*)0x200001c0 = 0;
  sprintf((char*)0x200001c2, "0x%016llx", (long long)0);
  memcpy(
      (void*)0x200001d4,
      "\x00\x00\x00\x00\x00\x00\x00\x00\xf7\x00\x00\x2a\xa4\xa3\xc4\x83\xf5\xe3"
      "\x52\xca\x17\x28\x10\x81\x51\x66\x4f\xe1\x58\x64\xda\xc4\xe1\x2b\x3c\xf1"
      "\xee\xa8\x2d\x5b\xe5\xc3\xd0\x16\xd6\x0f\x9e\x28\x5b\xc9\xd2\x50\xc2\x60"
      "\xaf\x69\xcf\xaa\x50\x5a\x87\x85\x5a\xd7\xad\xda\x2f\xb3\x56\x74\x17\xa2"
      "\x49\x22\x02\x29\xac\x8b\x37\x73\x08\x92\x31\xd7\x5c\xde\x1e\xf1\x21\xf7"
      "\x0e\xfa\xaf\xfb\x03\x56\x56\xac\x50\xde\x39\x5e\x09\x1d\x56\x5d\xa9\xb0"
      "\x48\x05\xcd\x93\x80\x0e\xc1\x71\xb1\x03\x53\x20\x51\x51\x04\xfe\xde\x83"
      "\xe4\xf3\xc8\xa6\xa4\x43\x7f\x9a\x40\x19\x01\x0d\xa0\xbb\xc4\x6b\x26\x2f"
      "\x06\xc5\x1d\x56\x77\x0e\xb0\x71\xb5\xda\x8c",
      155);
  sprintf((char*)0x2000026f, "0x%016llx", (long long)0xee00);
  sprintf((char*)0x20000281, "0x%016llx", (long long)-1);
  memcpy(
      (void*)0x200035c0,
      "\x78\x9c\xec\xdd\xcf\x6f\x14\xd7\x1d\x00\xf0\xef\xcc\x7a\xa9\x01\xd3\x35"
      "\x6d\x0f\x14\xa9\x14\x15\x2a\x83\x5a\xd6\x36\x16\x60\xf5\x00\x54\xaa\xca"
      "\x09\xa9\x2d\xbd\x53\xd7\x5e\x5b\x96\xd7\xac\xe5\x5d\x7e\xd8\x42\x95\x51"
      "\xff\x80\x4a\x55\xd5\x56\xea\xa9\xa7\x5e\x2a\xe5\x0f\x88\x14\xf1\x27\x44"
      "\x91\x90\x92\x7b\x94\xa0\x44\x51\x02\xc9\x21\x87\x24\x1b\xed\x7a\x96\x80"
      "\xb3\xeb\x1f\xc1\xf6\x20\xfb\xf3\x91\x86\x79\xef\xcd\xce\x7c\xbf\x0f\xb4"
      "\xb3\xf3\x66\x1e\xbb\x01\xec\x5b\x27\x23\xe2\x6a\x44\x14\x22\xe2\x6c\x44"
      "\x94\xb2\xf6\x34\x5b\xae\xb5\x2a\x2b\xab\xaf\x7b\xfa\xe4\xfe\x64\x6b\x69"
      "\xb5\xdf\xf8\x38\x89\x24\x6b\xeb\x1c\x2b\xc9\xd6\x87\x57\x77\x89\xfe\x88"
      "\xf8\xc3\xb5\x88\x3f\x27\xdf\x8e\x5b\x5f\x5a\x9e\x9b\xa8\x56\x2b\x8b\x59"
      "\x7d\xb8\x31\xbf\x30\x5c\x5f\x5a\x3e\x37\x3b\x3f\x31\x53\x99\xa9\xdc\x1a"
      "\x1b\x1b\xbd\x38\x7e\x69\xfc\xc2\xf8\xc8\xb6\xf4\x73\x30\x22\x2e\xff\xe6"
      "\xf1\x3f\xff\xf6\xbf\xdf\x5e\x7e\xe3\x97\x77\xdf\xbd\xf9\xe1\x99\xbf\xb4"
      "\xd2\x1a\xc8\xb6\x3f\xdf\x8f\xf5\x34\x4b\x5b\x8b\xbb\xda\xf5\x62\xfb\xef"
      "\xa2\xa3\x2f\x22\x16\xb7\x76\x98\x57\x56\x21\x5b\x17\x73\xce\x03\x00\x80"
      "\xcd\x69\x5d\xcb\xff\x20\x22\x7e\xd6\xbe\xfe\x2f\x45\xa1\x7d\x75\x0a\x00"
      "\x00\x00\xec\x25\xcd\x2b\x03\xf1\x45\x12\xd1\x04\x00\x00\x00\xf6\xac\xb4"
      "\x3d\x07\x36\x49\xcb\xd9\x5c\x80\x81\x48\xd3\x72\x79\x75\x0e\xef\x8f\xe2"
      "\x50\x5a\xad\xd5\x1b\xbf\x98\xae\xdd\xbe\x35\xb5\x3a\x57\x76\x30\x8a\xe9"
      "\xf4\x6c\xb5\x32\x92\xcd\x15\x1e\x8c\x62\xd2\xaa\x8f\x66\x73\x6c\x3b\xf5"
      "\xf3\x6b\xea\x85\x88\x38\x1a\x11\xff\x28\x1d\x6c\xd7\xcb\x93\xb5\xea\x54"
      "\xde\x37\x3f\x00\x00\x00\x60\x9f\x38\xbc\x66\xfc\xff\x59\xe9\x4a\xde\x29"
      "\x01\x00\x00\x00\x3b\x61\x30\xef\x04\x00\x00\x00\x80\x1d\x67\xfc\x0f\x00"
      "\x00\x00\x7b\x9f\xf1\x3f\x00\x00\x00\xec\x69\xbf\xbb\x7e\xbd\xb5\x34\x3b"
      "\xbf\x7f\x3d\x75\x67\xe9\xf6\x5c\xed\xce\xb9\xa9\x4a\x7d\xae\x3c\x7f\x7b"
      "\xb2\x3c\x59\x5b\x5c\x28\xcf\xd4\x6a\x33\xed\xef\xec\x9b\xdf\xe8\x78\xd5"
      "\x5a\x6d\xe1\x40\x56\xae\x37\x86\xeb\x4b\xcb\x37\xe7\x6b\xcd\x42\xe3\xe6"
      "\xec\x0b\x3f\x81\x0d\x00\x00\x00\xec\xa2\xa3\x3f\x7d\xf8\x4e\x12\x11\x2b"
      "\xbf\x3a\xd8\x5e\x5a\x0e\xe4\x9d\x14\xb0\x2b\x92\xad\xbc\xf8\xfd\x9d\xcb"
      "\x03\xd8\x7d\x85\xbc\x13\x00\x72\xd3\x97\x77\x02\x40\x6e\x8a\x79\x27\x00"
      "\xe4\x6e\xa3\xfb\x00\x3d\x27\xef\xbc\xd9\xa5\xcd\xa0\x02\x00\x00\x5e\x49"
      "\x43\x3f\xee\xfd\xfc\xdf\xbd\x01\xd8\xdb\xd2\xbc\x13\x00\x00\x76\x9d\xe7"
      "\xff\xb0\x7f\x15\x3d\xac\x83\x7d\xef\xfb\x1b\x6c\xdf\xd2\xf3\xff\xae\x9a"
      "\xcd\x2d\x25\x04\x00\x00\x6c\xbb\x81\xf6\x92\xa4\xe5\xec\x59\xe0\x40\xa4"
      "\x69\xb9\x1c\x71\xa4\xfd\xb3\x00\xc5\x64\x7a\xb6\x5a\x19\xc9\xc6\x07\x6f"
      "\x97\x8a\xdf\x6b\xd5\x47\xdb\x7b\x26\x5b\xfb\xbf\xc3\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\x8f\x35\x9b"
      "\x49\x34\x01\x00\x00\x80\x3d\x2d\x22\xfd\x20\x69\x7f\x9b\x7f\xc4\x50\xe9"
      "\xf4\xc0\xda\xfb\x03\x07\x92\xcf\x4b\xed\x75\x44\xdc\xfd\xcf\x8d\x7f\xdd"
      "\x9b\x68\x34\x16\x47\x5b\xed\x9f\x3c\x6b\x6f\xfc\x3b\x6b\x3f\x9f\xc7\x1d"
      "\x0c\x00\x00\x00\x60\xad\xce\x38\xbd\x33\x8e\x07\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\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\xed\xf4\xf4\xc9\xfd"
      "\xc9\xce\xb2\x9b\x71\x3f\xfa\x75\x44\x0c\x76\x8b\xdf\x17\xfd\xed\x75\x7f"
      "\x14\x23\xe2\xd0\xa7\x49\xf4\x3d\xb7\x5f\x12\x11\x85\x6d\x88\xbf\xf2\x20"
      "\x22\x8e\x75\x8b\x9f\xb4\xd2\x8a\xc1\x2c\x8b\x6e\xf1\x0f\xe6\x18\x3f\x8d"
      "\x88\xc3\xdb\x10\x1f\xf6\xb3\x87\xad\xf3\xcf\xd5\x6e\xef\xbf\x34\x4e\xb6"
      "\xd7\xdd\xdf\x7f\x7d\xd9\xf2\xb2\x7a\x9f\xff\xd2\x67\xe7\xbf\x42\x8f\xf3"
      "\xcf\x91\x4d\xc6\x38\xfe\xe8\xb5\xe1\x9e\xf1\x1f\x44\x1c\xef\xeb\x7e\xfe"
      "\xe9\xc4\x4f\x7a\xc4\x3f\xb5\xc9\xf8\x7f\xfa\xe3\xf2\x72\xaf\x6d\xcd\xff"
      "\x46\x0c\x75\xfd\xfc\x49\x5e\x88\x35\xdc\x98\x5f\x18\xae\x2f\x2d\x9f\x9b"
      "\x9d\x9f\x98\xa9\xcc\x54\x6e\x8d\x8d\x8d\x5e\x1c\xbf\x34\x7e\x61\x7c\x64"
      "\x78\x7a\xb6\x5a\xc9\xfe\xec\x1a\xe3\xef\x3f\x79\xfd\xab\xf5\xfa\x7f\xa8"
      "\x47\xfc\xc1\x0d\xfa\x7f\x7a\x93\xfd\xff\xf2\xd1\xbd\x27\x3f\x5c\x2d\x16"
      "\xbb\xc5\x3f\x73\xaa\xfb\xe7\xef\xb1\x1e\xf1\xd3\xec\xb3\xef\xe7\x59\xb9"
      "\xb5\x7d\xa8\x53\x5e\x59\x2d\x3f\xef\xc4\xff\xdf\x3a\xb1\x5e\xff\xa7\x7a"
      "\xf4\x7f\xa3\x7f\xff\x33\x9b\xec\xff\xd9\xdf\xff\xf5\xbd\x4d\xbe\x14\x00"
      "\xd8\x05\xf5\xa5\xe5\xb9\x89\x6a\xb5\xb2\xf8\x9d\x0b\x8f\xe3\xa5\x76\xdf"
      "\xa8\xd0\x1f\x3b\x75\x64\x05\x05\x85\x9e\x85\xbc\xcf\x4c\x00\x00\xc0\x76"
      "\xfb\xe6\xa2\x3f\xef\x4c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x60\xff\xda\x8d\xaf\x13\x5b\x1b\x73\x25\x9f\xae\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\xac\xeb\xeb\x00\x00\x00\xff\xff\xf5\xd7\xd0\x7d",
      1220);
  syz_mount_image(/*fs=*/0x20000040, /*dir=*/0x20000500, /*flags=*/0x4500,
                  /*opts=*/0x200001c0, /*chdir=*/0x12, /*size=*/0x4c4,
                  /*img=*/0x200035c0);
  memcpy((void*)0x20000100, "./bus\000", 6);
  syscall(__NR_creat, /*file=*/0x20000100ul, /*mode=*/0ul);
  memcpy((void*)0x20001280, "/dev/loop", 9);
  *(uint8_t*)0x20001289 = 0x30;
  *(uint8_t*)0x2000128a = 0;
  memcpy((void*)0x20001240, "./bus\000", 6);
  syscall(__NR_mount, /*src=*/0x20001280ul, /*dst=*/0x20001240ul, /*type=*/0ul,
          /*flags=*/0x1000ul, /*data=*/0ul);
  memcpy((void*)0x20000400, "./bus\000", 6);
  res = syscall(__NR_open, /*file=*/0x20000400ul, /*flags=*/0x14103eul,
                /*mode=*/0ul);
  if (res != -1)
    r[0] = res;
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x600000ul,
          /*prot=*/0x2000002ul, /*flags=*/0x11ul, /*fd=*/r[0], /*offset=*/0ul);
  memcpy((void*)0x20000080, "memory.events.local\000", 20);
  res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000080ul,
                /*flags=*/0x275aul, /*mode=*/0ul);
  if (res != -1)
    r[1] = res;
  *(uint64_t*)0x20000540 = 0;
  *(uint64_t*)0x20000548 = 0;
  *(uint64_t*)0x20000550 = 0x20000000;
  memset((void*)0x20000000, 132, 1);
  *(uint64_t*)0x20000558 = 1;
  *(uint64_t*)0x20000560 = 0;
  *(uint64_t*)0x20000568 = 0;
  *(uint64_t*)0x20000570 = 0;
  *(uint64_t*)0x20000578 = 0;
  syscall(__NR_writev, /*fd=*/r[1], /*vec=*/0x20000540ul, /*vlen=*/4ul);
  return 0;
}