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

#define _GNU_SOURCE

#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include <linux/futex.h>
#include <linux/loop.h>

#ifndef __NR_ftruncate
#define __NR_ftruncate 46
#endif
#ifndef __NR_memfd_create
#define __NR_memfd_create 279
#endif
#ifndef __NR_mmap
#define __NR_mmap 222
#endif
#ifndef __NR_openat
#define __NR_openat 56
#endif
#ifndef __NR_write
#define __NR_write 64
#endif

static unsigned long long procid;

static __thread int clone_ongoing;
static __thread int skip_segv;
static __thread jmp_buf segv_env;

static void segv_handler(int sig, siginfo_t* info, void* ctx)
{
  if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) {
    exit(sig);
  }
  uintptr_t addr = (uintptr_t)info->si_addr;
  const uintptr_t prog_start = 1 << 20;
  const uintptr_t prog_end = 100 << 20;
  int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0;
  int valid = addr < prog_start || addr > prog_end;
  if (skip && valid) {
    _longjmp(segv_env, 1);
  }
  exit(sig);
}

static void install_segv_handler(void)
{
  struct sigaction sa;
  memset(&sa, 0, sizeof(sa));
  sa.sa_handler = SIG_IGN;
  syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8);
  syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8);
  memset(&sa, 0, sizeof(sa));
  sa.sa_sigaction = segv_handler;
  sa.sa_flags = SA_NODEFER | SA_SIGINFO;
  sigaction(SIGSEGV, &sa, NULL);
  sigaction(SIGBUS, &sa, NULL);
}

#define NONFAILING(...)                                                        \
  ({                                                                           \
    int ok = 1;                                                                \
    __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    if (_setjmp(segv_env) == 0) {                                              \
      __VA_ARGS__;                                                             \
    } else                                                                     \
      ok = 0;                                                                  \
    __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    ok;                                                                        \
  })

static void sleep_ms(uint64_t ms)
{
  usleep(ms * 1000);
}

static uint64_t current_time_ms(void)
{
  struct timespec ts;
  if (clock_gettime(CLOCK_MONOTONIC, &ts))
    exit(1);
  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}

static void thread_start(void* (*fn)(void*), void* arg)
{
  pthread_t th;
  pthread_attr_t attr;
  pthread_attr_init(&attr);
  pthread_attr_setstacksize(&attr, 128 << 10);
  int i = 0;
  for (; i < 100; i++) {
    if (pthread_create(&th, &attr, fn, arg) == 0) {
      pthread_attr_destroy(&attr);
      return;
    }
    if (errno == EAGAIN) {
      usleep(50);
      continue;
    }
    break;
  }
  exit(1);
}

typedef struct {
  int state;
} event_t;

static void event_init(event_t* ev)
{
  ev->state = 0;
}

static void event_reset(event_t* ev)
{
  ev->state = 0;
}

static void event_set(event_t* ev)
{
  if (ev->state)
    exit(1);
  __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE);
  syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000);
}

static void event_wait(event_t* ev)
{
  while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
    syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0);
}

static int event_isset(event_t* ev)
{
  return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE);
}

static int event_timedwait(event_t* ev, uint64_t timeout)
{
  uint64_t start = current_time_ms();
  uint64_t now = start;
  for (;;) {
    uint64_t remain = timeout - (now - start);
    struct timespec ts;
    ts.tv_sec = remain / 1000;
    ts.tv_nsec = (remain % 1000) * 1000 * 1000;
    syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts);
    if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
      return 1;
    now = current_time_ms();
    if (now - start > timeout)
      return 0;
  }
}

static bool write_file(const char* file, const char* what, ...)
{
  char buf[1024];
  va_list args;
  va_start(args, what);
  vsnprintf(buf, sizeof(buf), what, args);
  va_end(args);
  buf[sizeof(buf) - 1] = 0;
  int len = strlen(buf);
  int fd = open(file, O_WRONLY | O_CLOEXEC);
  if (fd == -1)
    return false;
  if (write(fd, buf, len) != len) {
    int err = errno;
    close(fd);
    errno = err;
    return false;
  }
  close(fd);
  return true;
}

//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:

//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty.  In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//%    claim that you wrote the original software. If you use this software
//%    in a product, an acknowledgment in the product documentation would be
//%    appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//%    misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler    madler@alumni.caltech.edu

//% BEGIN CODE DERIVED FROM puff.{c,h}

#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288

struct puff_state {
  unsigned char* out;
  unsigned long outlen;
  unsigned long outcnt;
  const unsigned char* in;
  unsigned long inlen;
  unsigned long incnt;
  int bitbuf;
  int bitcnt;
  jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
  long val = s->bitbuf;
  while (s->bitcnt < need) {
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    val |= (long)(s->in[s->incnt++]) << s->bitcnt;
    s->bitcnt += 8;
  }
  s->bitbuf = (int)(val >> need);
  s->bitcnt -= need;
  return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
  s->bitbuf = 0;
  s->bitcnt = 0;
  if (s->incnt + 4 > s->inlen)
    return 2;
  unsigned len = s->in[s->incnt++];
  len |= s->in[s->incnt++] << 8;
  if (s->in[s->incnt++] != (~len & 0xff) ||
      s->in[s->incnt++] != ((~len >> 8) & 0xff))
    return -2;
  if (s->incnt + len > s->inlen)
    return 2;
  if (s->outcnt + len > s->outlen)
    return 1;
  for (; len--; s->outcnt++, s->incnt++) {
    if (s->in[s->incnt])
      s->out[s->outcnt] = s->in[s->incnt];
  }
  return 0;
}
struct puff_huffman {
  short* count;
  short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
  int first = 0;
  int index = 0;
  int bitbuf = s->bitbuf;
  int left = s->bitcnt;
  int code = first = index = 0;
  int len = 1;
  short* next = h->count + 1;
  while (1) {
    while (left--) {
      code |= bitbuf & 1;
      bitbuf >>= 1;
      int count = *next++;
      if (code - count < first) {
        s->bitbuf = bitbuf;
        s->bitcnt = (s->bitcnt - len) & 7;
        return h->symbol[index + (code - first)];
      }
      index += count;
      first += count;
      first <<= 1;
      code <<= 1;
      len++;
    }
    left = (MAXBITS + 1) - len;
    if (left == 0)
      break;
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    bitbuf = s->in[s->incnt++];
    if (left > 8)
      left = 8;
  }
  return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
  int len;
  for (len = 0; len <= MAXBITS; len++)
    h->count[len] = 0;
  int symbol;
  for (symbol = 0; symbol < n; symbol++)
    (h->count[length[symbol]])++;
  if (h->count[0] == n)
    return 0;
  int left = 1;
  for (len = 1; len <= MAXBITS; len++) {
    left <<= 1;
    left -= h->count[len];
    if (left < 0)
      return left;
  }
  short offs[MAXBITS + 1];
  offs[1] = 0;
  for (len = 1; len < MAXBITS; len++)
    offs[len + 1] = offs[len] + h->count[len];
  for (symbol = 0; symbol < n; symbol++)
    if (length[symbol] != 0)
      h->symbol[offs[length[symbol]]++] = symbol;
  return left;
}
static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode,
                      const struct puff_huffman* distcode)
{
  static const short lens[29] = {3,  4,  5,  6,   7,   8,   9,   10,  11, 13,
                                 15, 17, 19, 23,  27,  31,  35,  43,  51, 59,
                                 67, 83, 99, 115, 131, 163, 195, 227, 258};
  static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
                                 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
  static const short dists[30] = {
      1,    2,    3,    4,    5,    7,    9,    13,    17,    25,
      33,   49,   65,   97,   129,  193,  257,  385,   513,   769,
      1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
  static const short dext[30] = {0, 0, 0,  0,  1,  1,  2,  2,  3,  3,
                                 4, 4, 5,  5,  6,  6,  7,  7,  8,  8,
                                 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
  int symbol;
  do {
    symbol = puff_decode(s, lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 256) {
      if (s->outcnt == s->outlen)
        return 1;
      if (symbol)
        s->out[s->outcnt] = symbol;
      s->outcnt++;
    } else if (symbol > 256) {
      symbol -= 257;
      if (symbol >= 29)
        return -10;
      int len = lens[symbol] + puff_bits(s, lext[symbol]);
      symbol = puff_decode(s, distcode);
      if (symbol < 0)
        return symbol;
      unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
      if (dist > s->outcnt)
        return -11;
      if (s->outcnt + len > s->outlen)
        return 1;
      while (len--) {
        if (dist <= s->outcnt && s->out[s->outcnt - dist])
          s->out[s->outcnt] = s->out[s->outcnt - dist];
        s->outcnt++;
      }
    }
  } while (symbol != 256);
  return 0;
}
static int puff_fixed(struct puff_state* s)
{
  static int virgin = 1;
  static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
  static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  static struct puff_huffman lencode, distcode;
  if (virgin) {
    lencode.count = lencnt;
    lencode.symbol = lensym;
    distcode.count = distcnt;
    distcode.symbol = distsym;
    short lengths[FIXLCODES];
    int symbol;
    for (symbol = 0; symbol < 144; symbol++)
      lengths[symbol] = 8;
    for (; symbol < 256; symbol++)
      lengths[symbol] = 9;
    for (; symbol < 280; symbol++)
      lengths[symbol] = 7;
    for (; symbol < FIXLCODES; symbol++)
      lengths[symbol] = 8;
    puff_construct(&lencode, lengths, FIXLCODES);
    for (symbol = 0; symbol < MAXDCODES; symbol++)
      lengths[symbol] = 5;
    puff_construct(&distcode, lengths, MAXDCODES);
    virgin = 0;
  }
  return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
  static const short order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
                                  11, 4,  12, 3, 13, 2, 14, 1, 15};
  int nlen = puff_bits(s, 5) + 257;
  int ndist = puff_bits(s, 5) + 1;
  int ncode = puff_bits(s, 4) + 4;
  if (nlen > MAXLCODES || ndist > MAXDCODES)
    return -3;
  short lengths[MAXCODES];
  int index;
  for (index = 0; index < ncode; index++)
    lengths[order[index]] = puff_bits(s, 3);
  for (; index < 19; index++)
    lengths[order[index]] = 0;
  short lencnt[MAXBITS + 1], lensym[MAXLCODES];
  struct puff_huffman lencode = {lencnt, lensym};
  int err = puff_construct(&lencode, lengths, 19);
  if (err != 0)
    return -4;
  index = 0;
  while (index < nlen + ndist) {
    int symbol;
    int len;
    symbol = puff_decode(s, &lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 16)
      lengths[index++] = symbol;
    else {
      len = 0;
      if (symbol == 16) {
        if (index == 0)
          return -5;
        len = lengths[index - 1];
        symbol = 3 + puff_bits(s, 2);
      } else if (symbol == 17)
        symbol = 3 + puff_bits(s, 3);
      else
        symbol = 11 + puff_bits(s, 7);
      if (index + symbol > nlen + ndist)
        return -6;
      while (symbol--)
        lengths[index++] = len;
    }
  }
  if (lengths[256] == 0)
    return -9;
  err = puff_construct(&lencode, lengths, nlen);
  if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
    return -7;
  short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  struct puff_huffman distcode = {distcnt, distsym};
  err = puff_construct(&distcode, lengths + nlen, ndist);
  if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
    return -8;
  return puff_codes(s, &lencode, &distcode);
}
static int puff(unsigned char* dest, unsigned long* destlen,
                const unsigned char* source, unsigned long sourcelen)
{
  struct puff_state s = {
      .out = dest,
      .outlen = *destlen,
      .outcnt = 0,
      .in = source,
      .inlen = sourcelen,
      .incnt = 0,
      .bitbuf = 0,
      .bitcnt = 0,
  };
  int err;
  if (setjmp(s.env) != 0)
    err = 2;
  else {
    int last;
    do {
      last = puff_bits(&s, 1);
      int type = puff_bits(&s, 2);
      err = type == 0 ? puff_stored(&s)
                      : (type == 1 ? puff_fixed(&s)
                                   : (type == 2 ? puff_dynamic(&s) : -1));
      if (err != 0)
        break;
    } while (!last);
  }
  *destlen = s.outcnt;
  return err;
}

//% END CODE DERIVED FROM puff.{c,h}

#define ZLIB_HEADER_WIDTH 2

static int puff_zlib_to_file(const unsigned char* source,
                             unsigned long sourcelen, int dest_fd)
{
  if (sourcelen < ZLIB_HEADER_WIDTH)
    return 0;
  source += ZLIB_HEADER_WIDTH;
  sourcelen -= ZLIB_HEADER_WIDTH;
  const unsigned long max_destlen = 132 << 20;
  void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ,
                   MAP_PRIVATE | MAP_ANON, -1, 0);
  if (ret == MAP_FAILED)
    return -1;
  unsigned char* dest = (unsigned char*)ret;
  unsigned long destlen = max_destlen;
  int err = puff(dest, &destlen, source, sourcelen);
  if (err) {
    munmap(dest, max_destlen);
    errno = -err;
    return -1;
  }
  if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
    munmap(dest, max_destlen);
    return -1;
  }
  return munmap(dest, max_destlen);
}

static int setup_loop_device(unsigned char* data, unsigned long size,
                             const char* loopname, int* loopfd_p)
{
  int err = 0, loopfd = -1;
  int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
  if (memfd == -1) {
    err = errno;
    goto error;
  }
  if (puff_zlib_to_file(data, size, memfd)) {
    err = errno;
    goto error_close_memfd;
  }
  loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    err = errno;
    goto error_close_memfd;
  }
  if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
    if (errno != EBUSY) {
      err = errno;
      goto error_close_loop;
    }
    ioctl(loopfd, LOOP_CLR_FD, 0);
    usleep(1000);
    if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
      err = errno;
      goto error_close_loop;
    }
  }
  close(memfd);
  *loopfd_p = loopfd;
  return 0;

error_close_loop:
  close(loopfd);
error_close_memfd:
  close(memfd);
error:
  errno = err;
  return -1;
}

static void reset_loop_device(const char* loopname)
{
  int loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    return;
  }
  if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
  }
  close(loopfd);
}

static long syz_mount_image(volatile long fsarg, volatile long dir,
                            volatile long flags, volatile long optsarg,
                            volatile long change_dir,
                            volatile unsigned long size, volatile long image)
{
  unsigned char* data = (unsigned char*)image;
  int res = -1, err = 0, need_loop_device = !!size;
  char* mount_opts = (char*)optsarg;
  char* target = (char*)dir;
  char* fs = (char*)fsarg;
  char* source = NULL;
  char loopname[64];
  if (need_loop_device) {
    int loopfd;
    memset(loopname, 0, sizeof(loopname));
    snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
    if (setup_loop_device(data, size, loopname, &loopfd) == -1)
      return -1;
    close(loopfd);
    source = loopname;
  }
  mkdir(target, 0777);
  char opts[256];
  memset(opts, 0, sizeof(opts));
  if (strlen(mount_opts) > (sizeof(opts) - 32)) {
  }
  strncpy(opts, mount_opts, sizeof(opts) - 32);
  if (strcmp(fs, "iso9660") == 0) {
    flags |= MS_RDONLY;
  } else if (strncmp(fs, "ext", 3) == 0) {
    bool has_remount_ro = false;
    char* remount_ro_start = strstr(opts, "errors=remount-ro");
    if (remount_ro_start != NULL) {
      char after = *(remount_ro_start + strlen("errors=remount-ro"));
      char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
      has_remount_ro = ((before == '\0' || before == ',') &&
                        (after == '\0' || after == ','));
    }
    if (strstr(opts, "errors=panic") || !has_remount_ro)
      strcat(opts, ",errors=continue");
  } else if (strcmp(fs, "xfs") == 0) {
    strcat(opts, ",nouuid");
  }
  res = mount(source, target, fs, flags, opts);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  res = open(target, O_RDONLY | O_DIRECTORY);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  if (change_dir) {
    res = chdir(target);
    if (res == -1) {
      err = errno;
    }
  }

error_clear_loop:
  if (need_loop_device)
    reset_loop_device(loopname);
  errno = err;
  return res;
}

static void kill_and_wait(int pid, int* status)
{
  kill(-pid, SIGKILL);
  kill(pid, SIGKILL);
  for (int i = 0; i < 100; i++) {
    if (waitpid(-1, status, WNOHANG | __WALL) == pid)
      return;
    usleep(1000);
  }
  DIR* dir = opendir("/sys/fs/fuse/connections");
  if (dir) {
    for (;;) {
      struct dirent* ent = readdir(dir);
      if (!ent)
        break;
      if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
        continue;
      char abort[300];
      snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
               ent->d_name);
      int fd = open(abort, O_WRONLY);
      if (fd == -1) {
        continue;
      }
      if (write(fd, abort, 1) < 0) {
      }
      close(fd);
    }
    closedir(dir);
  } else {
  }
  while (waitpid(-1, status, __WALL) != pid) {
  }
}

static void reset_loop()
{
  char buf[64];
  snprintf(buf, sizeof(buf), "/dev/loop%llu", procid);
  int loopfd = open(buf, O_RDWR);
  if (loopfd != -1) {
    ioctl(loopfd, LOOP_CLR_FD, 0);
    close(loopfd);
  }
}

static void setup_test()
{
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  setpgrp();
  write_file("/proc/self/oom_score_adj", "1000");
}

struct thread_t {
  int created, call;
  event_t ready, done;
};

static struct thread_t threads[16];
static void execute_call(int call);
static int running;

static void* thr(void* arg)
{
  struct thread_t* th = (struct thread_t*)arg;
  for (;;) {
    event_wait(&th->ready);
    event_reset(&th->ready);
    execute_call(th->call);
    __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
    event_set(&th->done);
  }
  return 0;
}

static void execute_one(void)
{
  int i, call, thread;
  for (call = 0; call < 5; call++) {
    for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0]));
         thread++) {
      struct thread_t* th = &threads[thread];
      if (!th->created) {
        th->created = 1;
        event_init(&th->ready);
        event_init(&th->done);
        event_set(&th->done);
        thread_start(thr, th);
      }
      if (!event_isset(&th->done))
        continue;
      event_reset(&th->done);
      th->call = call;
      __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
      event_set(&th->ready);
      if (call == 2)
        break;
      event_timedwait(&th->done, 50 + (call == 0 ? 4000 : 0));
      break;
    }
  }
  for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++)
    sleep_ms(1);
}

static void execute_one(void);

#define WAIT_FLAGS __WALL

static void loop(void)
{
  int iter = 0;
  for (;; iter++) {
    reset_loop();
    int pid = fork();
    if (pid < 0)
      exit(1);
    if (pid == 0) {
      setup_test();
      execute_one();
      exit(0);
    }
    int status = 0;
    uint64_t start = current_time_ms();
    for (;;) {
      if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
        break;
      sleep_ms(1);
      if (current_time_ms() - start < 5000)
        continue;
      kill_and_wait(pid, &status);
      break;
    }
  }
}

uint64_t r[1] = {0xffffffffffffffff};

void execute_call(int call)
{
  intptr_t res = 0;
  switch (call) {
  case 0:
    NONFAILING(memcpy((void*)0x20000480, "udf\000", 4));
    NONFAILING(memcpy((void*)0x200000c0, "./bus\000", 6));
    NONFAILING(memcpy(
        (void*)0x200018c0,
        "\x78\x9c\xec\xdd\x41\x6c\x1c\xd7\x79\x07\xf0\xef\x0d\x49\x93\x92\x8b"
        "\x64\xeb\x58\xb2\x93\x1a\xc1\xda\x05\x1c\x55\x69\x54\x92\x8a\x2d\x1b"
        "\x0c\x50\xab\x66\x89\xa6\x51\x6c\xd6\x14\x93\xb6\xee\xc1\x2b\x71\xa5"
        "\x6e\x45\x2d\x17\x24\xe5\xc8\x46\x9b\xb8\x27\x1f\x5a\xa0\x6c\x0a\xf4"
        "\xd2\x14\x28\x50\xa4\x30\x7a\x08\xd8\x43\x0e\xed\x29\x05\x0a\xf4\x4a"
        "\x14\xb9\x15\x05\xd4\x34\x75\x5d\x14\x05\xf6\x10\x23\x97\xc2\x2c\x66"
        "\xf6\x2d\xb9\x92\x68\x8b\x10\x45\x51\x92\x7f\x3f\x40\xfa\x0f\x67\xbf"
        "\xb7\x3b\xf3\xde\x7a\x66\xb8\x6f\xc7\x0a\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x20\xe2\x57\x7e\xf5\xf4\xf8\x44\x3a\xe8"
        "\xad\x00\x00\xee\xa6\x97\xe6\x5e\x19\x9f\x74\xfe\x07\x80\x8f\x95\xb3"
        "\x7e\xff\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x7b\x5d\x8a"
        "\x22\xde\x8b\x14\xdf\x78\xa2\x9b\x5e\xab\x7e\xee\x19\x3b\xd3\x6a\x5f"
        "\xb9\x3a\x3f\x3d\xb3\x73\xb3\x43\xa9\x6a\x39\x54\xd5\x97\x7f\xc6\x26"
        "\x26\x4f\x7e\xf1\x99\x67\x4f\x3d\xd7\xcf\x8f\x6e\x7f\xa7\x7d\x3a\x5e"
        "\x9e\x3b\x7b\xba\xfe\xe2\xd2\xe5\xce\x72\x73\x65\xa5\xb9\x50\x9f\x6f"
        "\xb7\xce\x2f\x2d\x34\x77\xfd\x0c\x7b\x6d\x7f\xa3\xe3\x55\x07\xd4\x2f"
        "\x5f\xba\xb2\x70\xe1\xc2\x4a\x7d\xf2\xc4\xc9\xeb\x1e\xbe\x5a\x7b\x77"
        "\xf4\xe1\xa3\xb5\xa9\x53\x13\xaf\x1e\xe9\xd7\xce\x4f\xcf\xcc\xcc\x0d"
        "\xd4\x0c\x8f\xdc\xf6\xab\xdf\xe4\xc3\xee\xf0\x78\x28\x8a\xb8\x10\x29"
        "\x2e\xbd\xf3\x5e\x6a\x44\x44\x11\x7b\xef\x8b\x5b\xbc\x77\xf6\xdb\xa1"
        "\x6a\x27\x8e\x57\x3b\x31\x3f\x3d\x53\xed\xc8\x62\xab\xd1\x5e\x2d\x1f"
        "\x9c\xed\x77\x44\x11\x51\x1b\x68\xf4\x42\xbf\x8f\xee\xc2\x58\xec\x49"
        "\x3d\xe2\xad\x72\xf3\xcb\x0d\x3e\x5e\xee\xde\x5c\xa7\xb1\xdc\x38\xb7"
        "\xd8\xac\xcf\x36\x96\x57\x5b\xab\xad\xa5\xf6\x6c\xea\x6d\x6d\xaa\xca"
        "\x8b\x78\x2e\x45\x74\x22\xa2\x3b\x7a\xf3\xd3\x8d\x44\x11\xdf\x8c\x14"
        "\x6f\x7f\xa7\x9b\xce\x45\xc4\x50\xbf\x1f\x3e\x5f\xdd\x18\x7c\xeb\xed"
        "\x29\xf6\x61\x1f\x77\x61\x38\x22\x6a\x23\x11\x1b\xc5\x7d\x30\x66\xf7"
        "\xb0\xd1\x28\xe2\x7b\x91\xe2\xdb\xdf\x1a\x8f\xf3\xb9\x5f\xab\x6e\x7b"
        "\x3a\xe2\xab\x65\x1e\x8d\xb8\x52\xe6\xb5\x88\xb5\x32\x3f\x1b\x91\xca"
        "\x37\xc8\xa3\x11\xef\xef\xf0\x7e\xe2\xfe\x32\x1c\x45\xfc\x51\xa4\xf8"
        "\xc9\x54\x37\x2d\xf4\xc7\xbe\x3a\xae\x9c\xf9\x5a\xfd\xcb\xed\x0b\x4b"
        "\x03\xb5\xfd\xe3\xca\x7d\x7f\x7e\xb8\x9b\xee\xf1\x63\xd3\x58\x14\xd1"
        "\xa8\x8e\xf8\xdd\x74\xfb\x17\x3b\x00\x00\x00\x00\x00\xdc\x7b\x8a\xf8"
        "\xd3\x48\xf1\xe4\x0f\x8f\xa5\x4e\x0c\xce\x29\xb6\xda\x17\xeb\x67\x1b"
        "\xe7\x16\x7b\x9f\x0a\xf7\x3f\xfb\xaf\xe7\x56\x9b\x9b\x9b\x9b\xb5\xd4"
        "\xcb\xf1\x9c\xb3\x39\x3b\x39\xd7\x72\xae\xe7\xdc\xc8\xd9\xcd\x59\x2b"
        "\x72\xfb\x9c\xb3\x39\x3b\x39\xd7\x72\xae\xe7\xdc\xc8\xd9\xcd\x59\x1b"
        "\xca\xed\x73\xce\xe6\xec\xe4\x5c\xcb\xb9\x9e\x73\x23\x67\x37\x67\x6d"
        "\x38\xb7\xcf\x39\x9b\xb3\x93\x73\x2d\xe7\x7a\xce\x8d\x9c\xdd\xe1\x03"
        "\x1c\x2e\x00\x00\x00\x00\x00\x00\x00\xd8\xc1\xa1\x28\xe2\xeb\x91\xe2"
        "\xe9\x5f\x7a\xbd\xba\xaf\x38\xaa\xfb\xd2\x3f\x39\x75\xea\x95\x13\xbf"
        "\x3e\x78\xcf\xf8\xe3\xb7\x78\x9e\xb2\xf6\x44\x44\xac\x17\xbb\xbb\x27"
        "\xf7\xa1\x7c\xeb\xf0\x6c\x9a\x4d\xe9\x80\xee\x21\xa6\x77\xff\xdf\x1f"
        "\xe4\xfb\xff\xfe\xf0\xa0\x37\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x38\x50\x45\x14\xf1\x54\xa4\x78\xfd\xfb\xdd\x14\x29\x22\xea"
        "\x11\xaf\x45\x2f\xaf\x8d\x1e\xf4\xd6\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\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x77\xc2"
        "\x58\x2a\xe2\xfd\x48\xf1\xe7\x5f\x19\xab\x7e\xde\x28\x22\x7e\x3b\x22"
        "\x3e\xd8\xfc\x60\x33\x22\xae\x7d\xb0\x79\xa7\x1d\xf4\x1e\x03\x00\x00"
        "\x00\x00\x00\x00\xc0\x03\x28\x15\xf1\x46\xa4\x78\xea\x95\x6e\xaa\x45"
        "\xc4\xd5\xda\xbb\xa3\x0f\x1f\xad\x4d\x9d\x9a\x78\xf5\xc8\x50\x0c\x45"
        "\x2a\x4b\x06\xeb\x5f\x9e\x3b\x7b\xba\xfe\xe2\xd2\xe5\xce\x72\x73\x65"
        "\xa5\xb9\x50\x9f\x6f\xb7\xce\x2f\x2d\x34\x77\xfb\x72\x63\x67\x5a\xed"
        "\x2b\x57\xe7\xa7\x67\xf6\x65\x67\x6e\xe9\xd0\x3e\x6f\xff\xa1\xb1\x17"
        "\x97\x3a\x6f\x2c\xb7\x2e\xfe\xee\xea\x8e\x8f\x1f\x1e\x3b\x7d\x6e\x65"
        "\x75\xb9\x71\x7e\xe7\x87\xe3\x50\x14\x11\xf5\xc1\x35\xc7\xab\x0d\x9e"
        "\x9f\x9e\xa9\x36\x7a\xb1\xd5\x68\x57\x4d\x67\xd3\x6e\xb7\x18\x00\x00"
        "\x00\x00\x00\x00\x80\x8f\x83\x91\x54\xc4\x07\x91\xe2\xed\xbf\x79\x67"
        "\x6b\xde\x79\xb8\x37\xe7\x3f\x7c\x63\xed\x77\xbf\x14\x51\xe4\xe5\xe9"
        "\x3c\xff\xbc\x35\x0d\x5d\x7d\x6f\xe0\x13\xd5\xf7\x06\x7a\xcb\x9f\x9c"
        "\x3a\xf5\x1b\x93\x9f\x19\x5c\xde\x71\xca\xfa\x78\x35\xa1\x5e\x9f\x9f"
        "\x9e\x99\x99\x1b\x58\x3d\x3c\x72\x73\xe9\x58\x7e\xdd\xf1\xbd\xed\x32"
        "\x03\xca\xf1\x5f\x8d\x14\x7f\xfc\x97\xf5\xf4\x64\x5e\x77\xfd\xf8\x0f"
        "\x6d\xd5\x7e\xf7\xf7\xb7\xc7\xfb\xad\x1b\x9f\xe8\x43\xc6\x7c\xaf\xe3"
        "\xff\xb3\x03\xeb\xca\xd7\x4c\xa9\x88\xbf\x8b\x14\x3f\xf7\x9b\x8f\xc7"
        "\x93\xd5\x76\x1e\x8e\x9b\xbe\x33\x91\xeb\xbe\x12\x29\x7e\x6b\xfd\x89"
        "\x5c\x17\x0f\x95\x75\x4f\xe5\xc7\x1f\xa9\xfe\x1e\xbb\xd0\x5a\x6c\x8e"
        "\x97\xb5\x57\x23\xc5\x3f\x5e\xb9\xbe\xf6\xe9\x5c\xfb\xa9\xed\xda\x89"
        "\x5d\x77\xec\x7d\xa2\x1c\xff\xa7\x22\xc5\xff\xfc\xce\xfa\x56\xdf\xe4"
        "\xf1\xcf\x23\xb0\x3d\x6a\x83\xe3\xff\x99\x1b\xdf\x1d\xfb\x34\xfe\x8f"
        "\x0c\xac\xab\xe5\xd7\xfd\xf9\x3b\xb3\xeb\x44\xc4\xca\x1b\x6f\x5e\x6a"
        "\x2c\x2e\x36\x97\x2d\x58\xb0\x60\x61\x6b\xe1\xa0\x8f\x4c\xdc\x0d\xe5"
        "\xf9\xff\xeb\x91\xe2\x1f\xfe\xec\x5f\xb7\xae\x77\xf2\xf9\xff\x67\x7a"
        "\x3f\x6d\x5f\xff\xfd\xf4\x9b\xdb\xe7\xff\xa9\x1b\x9f\x68\x9f\xce\xff"
        "\x9f\x1a\x58\x37\x95\xaf\x46\x46\x86\x23\xc6\x56\x2f\x77\x46\x1e\x8b"
        "\x18\x5b\x79\xe3\xcd\x2f\xb4\x2e\x37\x2e\x36\x2f\x36\xdb\x27\x4f\x3d"
        "\xff\xec\xe4\xf8\xf3\x13\xe3\x27\x47\x1e\xea\x5f\xdc\x6d\x2f\xed\xb9"
        "\xaf\x1e\x44\xe5\xf8\xff\x5e\xa4\xf8\xde\x8f\xfe\x36\x3e\x97\xd7\x5d"
        "\x7f\xfd\xb7\xf3\xf5\xff\xe1\x1b\x9f\x68\x9f\xc6\xff\xd1\x81\x75\x87"
        "\xaf\xbb\x5e\xd9\xf3\xae\x93\xc7\xff\xff\x22\xc5\x3f\x4f\xff\x20\x8e"
        "\xe5\x75\x1f\x75\xfd\xdf\xff\xfd\xff\x58\xbe\x08\xdf\xba\x3e\xdf\xa7"
        "\xf1\x3f\x32\xb0\xae\xfa\x1d\xef\x13\x11\xbf\x30\xb0\xee\xd8\x91\x88"
        "\x07\xee\x97\x32\x00\x00\x00\xb8\xc3\x52\x2a\xe2\x07\x79\x3e\x75\xfc"
        "\x16\xf3\xa9\xff\x14\x29\xde\xfc\xef\x5f\xcc\x75\xe9\x68\x59\xf7\x42"
        "\x7e\xbc\x56\xfd\x3d\xf6\xd2\x52\xfb\x0b\xa7\x17\x17\x97\xce\x37\x56"
        "\x1b\xe7\x16\x9b\xf5\xb9\x4e\xe3\x7c\xb3\x6c\xfb\xe3\x48\xd1\xfd\xeb"
        "\x27\x72\xdb\xa2\x9a\x5f\xed\xcf\x37\xf7\xe6\x78\xb7\xe7\x62\xff\x25"
        "\x52\x3c\xff\x6b\xfd\xda\xde\x5c\x6c\xff\xb3\xa9\x47\xb7\x6b\x27\xca"
        "\xda\x13\x91\xe2\x4f\x5e\xba\xbe\xb6\xff\x39\xc6\x91\xed\xda\xc9\xb2"
        "\xf6\xdf\x22\xc5\xc4\xab\x3b\xd7\x1e\xdd\xae\x3d\x59\xd6\xfe\x57\xa4"
        "\xf8\xe9\x5f\xd4\xfb\xb5\x87\xcb\xda\x2f\xe5\xda\xc7\xb6\x6b\x4f\x9c"
        "\x5f\x5a\x5c\xd8\x87\x61\x01\x00\x00\x00\x00\x80\x3d\x19\x49\x45\x3c"
        "\x1b\x29\xfe\xfe\xe4\x70\xea\x7f\xbe\xbd\x9b\xef\x7f\xde\xf4\xa1\xf7"
        "\x3e\x7d\xff\xef\xb1\x81\x75\x0b\x77\xe9\x7e\x95\x3d\x77\x2a\x00\xdc"
        "\xe3\xca\xf3\xff\xb1\xf2\xac\xfe\xcb\x7f\xb5\x35\x97\x7f\xfd\xf9\x7f"
        "\xfb\xff\x03\x30\x78\xfe\xbf\xd1\xe0\xbf\x1b\xf0\x61\xcb\xb7\x73\xfe"
        "\xaf\xdd\x99\xdd\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\xf8\xd8\x49\x51\xc4\x52\xa4\xf8\xc6\x13\xdd"
        "\x74\x6d\xb4\xfc\xb9\x67\xec\x4c\xab\x7d\xe5\xea\xfc\xf4\xcc\xce\xcd"
        "\x0e\xa5\xaa\xe5\x50\x55\x5f\xfe\x19\x9b\x98\x3c\xf9\xc5\x67\x9e\x3d"
        "\xf5\x5c\x3f\x3f\xba\xfd\x9d\xf6\xe9\x78\x79\xee\xec\xe9\xfa\x8b\x4b"
        "\x97\x3b\xcb\xcd\x95\x95\xe6\x42\x7d\xbe\xdd\x3a\xbf\xb4\xd0\xdc\xf5"
        "\x33\xec\xb5\xfd\x8d\x8e\x57\x1d\x50\xbf\x7c\xe9\xca\xc2\x85\x0b\x2b"
        "\xf5\xc9\x13\x27\xaf\x7b\xf8\x6a\xed\xdd\xd1\x87\x8f\xd6\xa6\x4e\x4d"
        "\xbc\x7a\xa4\x5f\x3b\x3f\x3d\x33\x33\x37\x50\x33\x3c\x72\xdb\xaf\x7e"
        "\x93\xf4\x21\xeb\x1f\x8a\x22\xfe\x37\x52\x5c\x7a\xe7\xbd\xf4\xef\xa3"
        "\x11\x45\xec\xbd\x2f\x6e\xf1\xde\xd9\x6f\x87\xaa\x9d\x38\x5e\xed\xc4"
        "\xfc\xf4\x4c\xb5\x23\x8b\xad\x46\x7b\xb5\x7c\x70\xb6\xdf\x11\x45\x44"
        "\x6d\xa0\xd1\x0b\xfd\x3e\xba\x0b\x63\x71\xfb\xde\xda\x5a\x2a\xca\x0d"
        "\x3e\x5e\xee\xde\x5c\xa7\xb1\xdc\x38\xb7\xd8\xac\xcf\x36\x96\x57\x5b"
        "\xab\xad\xa5\xf6\x6c\xea\x6d\x6d\xb9\x3f\xf5\x28\xe2\xb9\x14\xd1\x89"
        "\x88\xee\xe8\xcd\xcf\x38\x12\x45\x8c\x44\x8a\xb7\xbf\xd3\x4d\x3f\x1a"
        "\x8d\x18\xea\xf7\xc3\xe7\x5f\x9a\x7b\x65\x7c\xf2\xd6\x9b\x54\xdc\xd1"
        "\x1d\xdc\xb5\xe1\x88\xa8\x8d\x44\x6c\x14\xf7\xfa\x98\xdd\xdb\x46\xa3"
        "\x88\x67\x22\xc5\xb7\xbf\x35\x1e\xff\x31\xda\xeb\xd7\xaa\xdb\x9e\x8e"
        "\xf8\x6a\x99\x47\x23\xae\x94\x79\x2d\x62\xad\xcc\xcf\x46\xa4\xf2\x0d"
        "\xf2\x68\xc4\xfb\x3b\xbc\x9f\xb8\xbf\x0c\x47\x11\x8f\x44\x8a\x9f\x4c"
        "\x75\xd3\x8f\x47\xf3\xd8\x57\xc7\x95\x33\x5f\xab\x7f\xb9\x7d\x61\x69"
        "\xa0\xb6\x7f\x5c\xb9\xef\xcf\x0f\x77\xd3\x3d\x7e\x6c\x1a\x8b\x22\xde"
        "\xab\x8e\xf8\xdd\xf4\x9f\xfe\x7b\x06\x00\x00\x00\x00\x78\x80\x14\xf1"
        "\x78\xa4\x78\xf2\x87\xc7\x52\x35\x3f\xb8\x35\xa7\xd8\x6a\x5f\xac\x9f"
        "\x6d\x9c\x5b\xec\x7d\xac\xdf\xff\xec\xbf\x9e\x5b\x6d\x6e\x6e\x6e\xd6"
        "\x52\x2f\xc7\x73\xce\xe6\xec\xe4\x5c\xcb\xb9\x9e\x73\x23\x67\x37\x67"
        "\xad\xc8\xed\x73\xce\xe6\xec\xe4\x5c\xcb\xb9\x9e\x73\x23\x67\x37\x67"
        "\x6d\x28\xb7\xcf\x39\x9b\xb3\x93\x73\x2d\xe7\x7a\xce\x8d\x9c\xdd\x9c"
        "\xb5\xe1\xdc\x3e\xe7\x6c\xce\x4e\xce\xb5\x9c\xeb\x39\x37\x72\x76\x87"
        "\x0f\x72\xbc\x00\x00\x00\x00\x00\x00\x00\x76\x56\x44\x11\x9f\x8b\x14"
        "\xaf\x7f\xbf\x9b\x36\x47\x7b\x13\xbc\xaf\x45\x2f\xaf\xb9\x1f\xe8\x81"
        "\xf7\xff\x01\x00\x00\xff\xff\xcf\x8d\x5b\x5a",
        3054));
    NONFAILING(syz_mount_image(
        /*fs=*/0x20000480, /*dir=*/0x200000c0, /*flags=MS_MANDLOCK*/ 0x40,
        /*opts=*/0x20000900, /*chdir=*/1, /*size=*/0xbee, /*img=*/0x200018c0));
    break;
  case 1:
    NONFAILING(memcpy((void*)0x20000080, "cgroup.controllers\000", 19));
    res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000080ul,
                  /*flags=*/0x275aul, /*mode=*/0ul);
    if (res != -1)
      r[0] = res;
    break;
  case 2:
    syscall(__NR_write, /*fd=*/r[0], /*data=*/0x20000040ul, /*len=*/0xfea7ul);
    break;
  case 3:
    syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x3000ul,
            /*prot=PROT_READ*/ 1ul,
            /*flags=MAP_NONBLOCK|MAP_FIXED|MAP_PRIVATE*/ 0x10012ul, /*fd=*/r[0],
            /*offset=*/0ul);
    break;
  case 4:
    syscall(__NR_ftruncate, /*fd=*/r[0], /*len=*/0x7faul);
    break;
  }
}
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);
  install_segv_handler();
  loop();
  return 0;
}