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

#define _GNU_SOURCE
#include <endian.h>
#include <linux/futex.h>
#include <pthread.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>

__attribute__((noreturn)) static void doexit(int status)
{
  volatile unsigned i;
  syscall(__NR_exit_group, status);
  for (i = 0;; i++) {
  }
}
#include <setjmp.h>
#include <signal.h>
#include <stdint.h>
#include <string.h>
#include <string.h>

static __thread int skip_segv;
static __thread jmp_buf segv_env;

static void segv_handler(int sig, siginfo_t* info, void* uctx)
{
  uintptr_t addr = (uintptr_t)info->si_addr;
  const uintptr_t prog_start = 1 << 20;
  const uintptr_t prog_end = 100 << 20;
  if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) &&
      (addr < prog_start || addr > prog_end)) {
    _longjmp(segv_env, 1);
  }
  doexit(sig);
}

static void install_segv_handler()
{
  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(...)                                                        \
  {                                                                            \
    __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    if (_setjmp(segv_env) == 0) {                                              \
      __VA_ARGS__;                                                             \
    }                                                                          \
    __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
  }

static void test();

void loop()
{
  while (1) {
    test();
  }
}

struct thread_t {
  int created, running, call;
  pthread_t th;
};

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

static void* thr(void* arg)
{
  struct thread_t* th = (struct thread_t*)arg;
  for (;;) {
    while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE))
      syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0);
    execute_call(th->call);
    __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
    __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE);
    syscall(SYS_futex, &th->running, FUTEX_WAKE);
  }
  return 0;
}

static void execute(int num_calls)
{
  int call, thread;
  running = 0;
  for (call = 0; call < num_calls; call++) {
    for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) {
      struct thread_t* th = &threads[thread];
      if (!th->created) {
        th->created = 1;
        pthread_attr_t attr;
        pthread_attr_init(&attr);
        pthread_attr_setstacksize(&attr, 128 << 10);
        pthread_create(&th->th, &attr, thr, th);
      }
      if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) {
        th->call = call;
        __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
        __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE);
        syscall(SYS_futex, &th->running, FUTEX_WAKE);
        if (collide && call % 2)
          break;
        struct timespec ts;
        ts.tv_sec = 0;
        ts.tv_nsec = 20 * 1000 * 1000;
        syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts);
        if (running)
          usleep((call == num_calls - 1) ? 10000 : 1000);
        break;
      }
    }
  }
}

long r[2];
uint64_t procid;
void execute_call(int call)
{
  switch (call) {
  case 0:
    r[0] = syscall(__NR_socket, 2, 0x803, 0);
    break;
  case 1:
    NONFAILING(*(uint32_t*)0x20516ffc = 8);
    syscall(__NR_setsockopt, r[0], 6, 0x1b, 0x20516ffc, 4);
    break;
  case 2:
    syscall(__NR_mmap, 0x20000000, 0x15000, 3, 0x32, -1, 0);
    break;
  case 3:
    r[1] = syscall(__NR_socket, 2, 0x80005, 0);
    break;
  case 4:
    NONFAILING(memcpy((void*)0x20013c90, "\x66\x69\x6c\x74\x65\x72\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00",
                      32));
    NONFAILING(*(uint32_t*)0x20013cb0 = 0xe);
    NONFAILING(*(uint32_t*)0x20013cb4 = 4);
    NONFAILING(*(uint32_t*)0x20013cb8 = 0x2e8);
    NONFAILING(*(uint32_t*)0x20013cbc = -1);
    NONFAILING(*(uint32_t*)0x20013cc0 = 0);
    NONFAILING(*(uint32_t*)0x20013cc4 = 0);
    NONFAILING(*(uint32_t*)0x20013cc8 = 0);
    NONFAILING(*(uint32_t*)0x20013ccc = -1);
    NONFAILING(*(uint32_t*)0x20013cd0 = -1);
    NONFAILING(*(uint32_t*)0x20013cd4 = 0);
    NONFAILING(*(uint32_t*)0x20013cd8 = 0);
    NONFAILING(*(uint32_t*)0x20013cdc = 0);
    NONFAILING(*(uint32_t*)0x20013ce0 = -1);
    NONFAILING(*(uint32_t*)0x20013ce4 = 4);
    NONFAILING(*(uint64_t*)0x20013ce8 = 0x20001000);
    NONFAILING(*(uint8_t*)0x20013cf0 = 0);
    NONFAILING(*(uint8_t*)0x20013cf1 = 0);
    NONFAILING(*(uint8_t*)0x20013cf2 = 0);
    NONFAILING(*(uint8_t*)0x20013cf3 = 0);
    NONFAILING(*(uint8_t*)0x20013cf4 = 0);
    NONFAILING(*(uint8_t*)0x20013cf5 = 0);
    NONFAILING(*(uint8_t*)0x20013cf6 = 0);
    NONFAILING(*(uint8_t*)0x20013cf7 = 0);
    NONFAILING(*(uint8_t*)0x20013cf8 = 0);
    NONFAILING(*(uint8_t*)0x20013cf9 = 0);
    NONFAILING(*(uint8_t*)0x20013cfa = 0);
    NONFAILING(*(uint8_t*)0x20013cfb = 0);
    NONFAILING(*(uint8_t*)0x20013cfc = 0);
    NONFAILING(*(uint8_t*)0x20013cfd = 0);
    NONFAILING(*(uint8_t*)0x20013cfe = 0);
    NONFAILING(*(uint8_t*)0x20013cff = 0);
    NONFAILING(*(uint8_t*)0x20013d00 = 0);
    NONFAILING(*(uint8_t*)0x20013d01 = 0);
    NONFAILING(*(uint8_t*)0x20013d02 = 0);
    NONFAILING(*(uint8_t*)0x20013d03 = 0);
    NONFAILING(*(uint8_t*)0x20013d04 = 0);
    NONFAILING(*(uint8_t*)0x20013d05 = 0);
    NONFAILING(*(uint8_t*)0x20013d06 = 0);
    NONFAILING(*(uint8_t*)0x20013d07 = 0);
    NONFAILING(*(uint8_t*)0x20013d08 = 0);
    NONFAILING(*(uint8_t*)0x20013d09 = 0);
    NONFAILING(*(uint8_t*)0x20013d0a = 0);
    NONFAILING(*(uint8_t*)0x20013d0b = 0);
    NONFAILING(*(uint8_t*)0x20013d0c = 0);
    NONFAILING(*(uint8_t*)0x20013d0d = 0);
    NONFAILING(*(uint8_t*)0x20013d0e = 0);
    NONFAILING(*(uint8_t*)0x20013d0f = 0);
    NONFAILING(*(uint8_t*)0x20013d10 = 0);
    NONFAILING(*(uint8_t*)0x20013d11 = 0);
    NONFAILING(*(uint8_t*)0x20013d12 = 0);
    NONFAILING(*(uint8_t*)0x20013d13 = 0);
    NONFAILING(*(uint8_t*)0x20013d14 = 0);
    NONFAILING(*(uint8_t*)0x20013d15 = 0);
    NONFAILING(*(uint8_t*)0x20013d16 = 0);
    NONFAILING(*(uint8_t*)0x20013d17 = 0);
    NONFAILING(*(uint8_t*)0x20013d18 = 0);
    NONFAILING(*(uint8_t*)0x20013d19 = 0);
    NONFAILING(*(uint8_t*)0x20013d1a = 0);
    NONFAILING(*(uint8_t*)0x20013d1b = 0);
    NONFAILING(*(uint8_t*)0x20013d1c = 0);
    NONFAILING(*(uint8_t*)0x20013d1d = 0);
    NONFAILING(*(uint8_t*)0x20013d1e = 0);
    NONFAILING(*(uint8_t*)0x20013d1f = 0);
    NONFAILING(*(uint8_t*)0x20013d20 = 0);
    NONFAILING(*(uint8_t*)0x20013d21 = 0);
    NONFAILING(*(uint8_t*)0x20013d22 = 0);
    NONFAILING(*(uint8_t*)0x20013d23 = 0);
    NONFAILING(*(uint8_t*)0x20013d24 = 0);
    NONFAILING(*(uint8_t*)0x20013d25 = 0);
    NONFAILING(*(uint8_t*)0x20013d26 = 0);
    NONFAILING(*(uint8_t*)0x20013d27 = 0);
    NONFAILING(*(uint8_t*)0x20013d28 = 0);
    NONFAILING(*(uint8_t*)0x20013d29 = 0);
    NONFAILING(*(uint8_t*)0x20013d2a = 0);
    NONFAILING(*(uint8_t*)0x20013d2b = 0);
    NONFAILING(*(uint8_t*)0x20013d2c = 0);
    NONFAILING(*(uint8_t*)0x20013d2d = 0);
    NONFAILING(*(uint8_t*)0x20013d2e = 0);
    NONFAILING(*(uint8_t*)0x20013d2f = 0);
    NONFAILING(*(uint8_t*)0x20013d30 = 0);
    NONFAILING(*(uint8_t*)0x20013d31 = 0);
    NONFAILING(*(uint8_t*)0x20013d32 = 0);
    NONFAILING(*(uint8_t*)0x20013d33 = 0);
    NONFAILING(*(uint8_t*)0x20013d34 = 0);
    NONFAILING(*(uint8_t*)0x20013d35 = 0);
    NONFAILING(*(uint8_t*)0x20013d36 = 0);
    NONFAILING(*(uint8_t*)0x20013d37 = 0);
    NONFAILING(*(uint8_t*)0x20013d38 = 0);
    NONFAILING(*(uint8_t*)0x20013d39 = 0);
    NONFAILING(*(uint8_t*)0x20013d3a = 0);
    NONFAILING(*(uint8_t*)0x20013d3b = 0);
    NONFAILING(*(uint8_t*)0x20013d3c = 0);
    NONFAILING(*(uint8_t*)0x20013d3d = 0);
    NONFAILING(*(uint8_t*)0x20013d3e = 0);
    NONFAILING(*(uint8_t*)0x20013d3f = 0);
    NONFAILING(*(uint8_t*)0x20013d40 = 0);
    NONFAILING(*(uint8_t*)0x20013d41 = 0);
    NONFAILING(*(uint8_t*)0x20013d42 = 0);
    NONFAILING(*(uint8_t*)0x20013d43 = 0);
    NONFAILING(*(uint32_t*)0x20013d44 = 0);
    NONFAILING(*(uint16_t*)0x20013d48 = 0x70);
    NONFAILING(*(uint16_t*)0x20013d4a = 0x98);
    NONFAILING(*(uint32_t*)0x20013d4c = 0);
    NONFAILING(*(uint64_t*)0x20013d50 = 0);
    NONFAILING(*(uint64_t*)0x20013d58 = 0);
    NONFAILING(*(uint16_t*)0x20013d60 = 0x28);
    NONFAILING(memcpy((void*)0x20013d62, "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00",
                      29));
    NONFAILING(*(uint8_t*)0x20013d7f = 0);
    NONFAILING(*(uint32_t*)0x20013d80 = 0xfffffffe);
    NONFAILING(*(uint8_t*)0x20013d88 = 0);
    NONFAILING(*(uint8_t*)0x20013d89 = 0);
    NONFAILING(*(uint8_t*)0x20013d8a = 0);
    NONFAILING(*(uint8_t*)0x20013d8b = 0);
    NONFAILING(*(uint8_t*)0x20013d8c = 0);
    NONFAILING(*(uint8_t*)0x20013d8d = 0);
    NONFAILING(*(uint8_t*)0x20013d8e = 0);
    NONFAILING(*(uint8_t*)0x20013d8f = 0);
    NONFAILING(*(uint8_t*)0x20013d90 = 0);
    NONFAILING(*(uint8_t*)0x20013d91 = 0);
    NONFAILING(*(uint8_t*)0x20013d92 = 0);
    NONFAILING(*(uint8_t*)0x20013d93 = 0);
    NONFAILING(*(uint8_t*)0x20013d94 = 0);
    NONFAILING(*(uint8_t*)0x20013d95 = 0);
    NONFAILING(*(uint8_t*)0x20013d96 = 0);
    NONFAILING(*(uint8_t*)0x20013d97 = 0);
    NONFAILING(*(uint8_t*)0x20013d98 = 0);
    NONFAILING(*(uint8_t*)0x20013d99 = 0);
    NONFAILING(*(uint8_t*)0x20013d9a = 0);
    NONFAILING(*(uint8_t*)0x20013d9b = 0);
    NONFAILING(*(uint8_t*)0x20013d9c = 0);
    NONFAILING(*(uint8_t*)0x20013d9d = 0);
    NONFAILING(*(uint8_t*)0x20013d9e = 0);
    NONFAILING(*(uint8_t*)0x20013d9f = 0);
    NONFAILING(*(uint8_t*)0x20013da0 = 0);
    NONFAILING(*(uint8_t*)0x20013da1 = 0);
    NONFAILING(*(uint8_t*)0x20013da2 = 0);
    NONFAILING(*(uint8_t*)0x20013da3 = 0);
    NONFAILING(*(uint8_t*)0x20013da4 = 0);
    NONFAILING(*(uint8_t*)0x20013da5 = 0);
    NONFAILING(*(uint8_t*)0x20013da6 = 0);
    NONFAILING(*(uint8_t*)0x20013da7 = 0);
    NONFAILING(*(uint8_t*)0x20013da8 = 0);
    NONFAILING(*(uint8_t*)0x20013da9 = 0);
    NONFAILING(*(uint8_t*)0x20013daa = 0);
    NONFAILING(*(uint8_t*)0x20013dab = 0);
    NONFAILING(*(uint8_t*)0x20013dac = 0);
    NONFAILING(*(uint8_t*)0x20013dad = 0);
    NONFAILING(*(uint8_t*)0x20013dae = 0);
    NONFAILING(*(uint8_t*)0x20013daf = 0);
    NONFAILING(*(uint8_t*)0x20013db0 = 0);
    NONFAILING(*(uint8_t*)0x20013db1 = 0);
    NONFAILING(*(uint8_t*)0x20013db2 = 0);
    NONFAILING(*(uint8_t*)0x20013db3 = 0);
    NONFAILING(*(uint8_t*)0x20013db4 = 0);
    NONFAILING(*(uint8_t*)0x20013db5 = 0);
    NONFAILING(*(uint8_t*)0x20013db6 = 0);
    NONFAILING(*(uint8_t*)0x20013db7 = 0);
    NONFAILING(*(uint8_t*)0x20013db8 = 0);
    NONFAILING(*(uint8_t*)0x20013db9 = 0);
    NONFAILING(*(uint8_t*)0x20013dba = 0);
    NONFAILING(*(uint8_t*)0x20013dbb = 0);
    NONFAILING(*(uint8_t*)0x20013dbc = 0);
    NONFAILING(*(uint8_t*)0x20013dbd = 0);
    NONFAILING(*(uint8_t*)0x20013dbe = 0);
    NONFAILING(*(uint8_t*)0x20013dbf = 0);
    NONFAILING(*(uint8_t*)0x20013dc0 = 0);
    NONFAILING(*(uint8_t*)0x20013dc1 = 0);
    NONFAILING(*(uint8_t*)0x20013dc2 = 0);
    NONFAILING(*(uint8_t*)0x20013dc3 = 0);
    NONFAILING(*(uint8_t*)0x20013dc4 = 0);
    NONFAILING(*(uint8_t*)0x20013dc5 = 0);
    NONFAILING(*(uint8_t*)0x20013dc6 = 0);
    NONFAILING(*(uint8_t*)0x20013dc7 = 0);
    NONFAILING(*(uint8_t*)0x20013dc8 = 0);
    NONFAILING(*(uint8_t*)0x20013dc9 = 0);
    NONFAILING(*(uint8_t*)0x20013dca = 0);
    NONFAILING(*(uint8_t*)0x20013dcb = 0);
    NONFAILING(*(uint8_t*)0x20013dcc = 0);
    NONFAILING(*(uint8_t*)0x20013dcd = 0);
    NONFAILING(*(uint8_t*)0x20013dce = 0);
    NONFAILING(*(uint8_t*)0x20013dcf = 0);
    NONFAILING(*(uint8_t*)0x20013dd0 = 0);
    NONFAILING(*(uint8_t*)0x20013dd1 = 0);
    NONFAILING(*(uint8_t*)0x20013dd2 = 0);
    NONFAILING(*(uint8_t*)0x20013dd3 = 0);
    NONFAILING(*(uint8_t*)0x20013dd4 = 0);
    NONFAILING(*(uint8_t*)0x20013dd5 = 0);
    NONFAILING(*(uint8_t*)0x20013dd6 = 0);
    NONFAILING(*(uint8_t*)0x20013dd7 = 0);
    NONFAILING(*(uint8_t*)0x20013dd8 = 0);
    NONFAILING(*(uint8_t*)0x20013dd9 = 0);
    NONFAILING(*(uint8_t*)0x20013dda = 0);
    NONFAILING(*(uint8_t*)0x20013ddb = 0);
    NONFAILING(*(uint32_t*)0x20013ddc = 0);
    NONFAILING(*(uint16_t*)0x20013de0 = 0x70);
    NONFAILING(*(uint16_t*)0x20013de2 = 0x98);
    NONFAILING(*(uint32_t*)0x20013de4 = 0);
    NONFAILING(*(uint64_t*)0x20013de8 = 0);
    NONFAILING(*(uint64_t*)0x20013df0 = 0);
    NONFAILING(*(uint16_t*)0x20013df8 = 0x28);
    NONFAILING(memcpy((void*)0x20013dfa, "\x52\x45\x4a\x45\x43\x54\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00",
                      29));
    NONFAILING(*(uint8_t*)0x20013e17 = 0);
    NONFAILING(*(uint32_t*)0x20013e18 = 0);
    NONFAILING(*(uint32_t*)0x20013e20 = htobe32(0xe0000001));
    NONFAILING(*(uint8_t*)0x20013e24 = 0xac);
    NONFAILING(*(uint8_t*)0x20013e25 = 0x14);
    NONFAILING(*(uint8_t*)0x20013e26 = 0);
    NONFAILING(*(uint8_t*)0x20013e27 = 0xaa);
    NONFAILING(*(uint32_t*)0x20013e28 = htobe32(0));
    NONFAILING(*(uint32_t*)0x20013e2c = htobe32(-1));
    NONFAILING(memcpy(
        (void*)0x20013e30,
        "\x73\x69\x74\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
        16));
    NONFAILING(memcpy(
        (void*)0x20013e40,
        "\x65\x71\x6c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
        16));
    NONFAILING(*(uint8_t*)0x20013e50 = 0);
    NONFAILING(*(uint8_t*)0x20013e51 = 0);
    NONFAILING(*(uint8_t*)0x20013e52 = 0);
    NONFAILING(*(uint8_t*)0x20013e53 = 0);
    NONFAILING(*(uint8_t*)0x20013e54 = 0);
    NONFAILING(*(uint8_t*)0x20013e55 = 0);
    NONFAILING(*(uint8_t*)0x20013e56 = 0);
    NONFAILING(*(uint8_t*)0x20013e57 = 0);
    NONFAILING(*(uint8_t*)0x20013e58 = 0);
    NONFAILING(*(uint8_t*)0x20013e59 = 0);
    NONFAILING(*(uint8_t*)0x20013e5a = 0);
    NONFAILING(*(uint8_t*)0x20013e5b = 0);
    NONFAILING(*(uint8_t*)0x20013e5c = 0);
    NONFAILING(*(uint8_t*)0x20013e5d = 0);
    NONFAILING(*(uint8_t*)0x20013e5e = 0);
    NONFAILING(*(uint8_t*)0x20013e5f = 0);
    NONFAILING(*(uint8_t*)0x20013e60 = 0);
    NONFAILING(*(uint8_t*)0x20013e61 = 0);
    NONFAILING(*(uint8_t*)0x20013e62 = 0);
    NONFAILING(*(uint8_t*)0x20013e63 = 0);
    NONFAILING(*(uint8_t*)0x20013e64 = 0);
    NONFAILING(*(uint8_t*)0x20013e65 = 0);
    NONFAILING(*(uint8_t*)0x20013e66 = 0);
    NONFAILING(*(uint8_t*)0x20013e67 = 0);
    NONFAILING(*(uint8_t*)0x20013e68 = 0);
    NONFAILING(*(uint8_t*)0x20013e69 = 0);
    NONFAILING(*(uint8_t*)0x20013e6a = 0);
    NONFAILING(*(uint8_t*)0x20013e6b = 0);
    NONFAILING(*(uint8_t*)0x20013e6c = 0);
    NONFAILING(*(uint8_t*)0x20013e6d = 0);
    NONFAILING(*(uint8_t*)0x20013e6e = 0);
    NONFAILING(*(uint8_t*)0x20013e6f = 0);
    NONFAILING(*(uint16_t*)0x20013e70 = 0);
    NONFAILING(*(uint8_t*)0x20013e72 = 0);
    NONFAILING(*(uint8_t*)0x20013e73 = 0);
    NONFAILING(*(uint32_t*)0x20013e74 = 0);
    NONFAILING(*(uint16_t*)0x20013e78 = 0x70);
    NONFAILING(*(uint16_t*)0x20013e7a = 0xd0);
    NONFAILING(*(uint32_t*)0x20013e7c = 0);
    NONFAILING(*(uint64_t*)0x20013e80 = 0);
    NONFAILING(*(uint64_t*)0x20013e88 = 0);
    NONFAILING(*(uint16_t*)0x20013e90 = 0x60);
    NONFAILING(memcpy((void*)0x20013e92, "\x43\x4c\x55\x53\x54\x45\x52\x49\x50"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00",
                      29));
    NONFAILING(*(uint8_t*)0x20013eaf = 0);
    NONFAILING(*(uint32_t*)0x20013eb0 = 1);
    NONFAILING(*(uint8_t*)0x20013eb4 = 1);
    NONFAILING(*(uint8_t*)0x20013eb5 = 0x80);
    NONFAILING(*(uint8_t*)0x20013eb6 = 0xc2);
    NONFAILING(*(uint8_t*)0x20013eb7 = 0);
    NONFAILING(*(uint8_t*)0x20013eb8 = 0);
    NONFAILING(*(uint8_t*)0x20013eb9 = 0);
    NONFAILING(*(uint16_t*)0x20013eba = 0);
    NONFAILING(*(uint16_t*)0x20013ebc = 0);
    NONFAILING(*(uint16_t*)0x20013ebe = 0);
    NONFAILING(*(uint16_t*)0x20013ec0 = 0);
    NONFAILING(*(uint16_t*)0x20013ec2 = 0);
    NONFAILING(*(uint16_t*)0x20013ec4 = 0);
    NONFAILING(*(uint16_t*)0x20013ec6 = 0);
    NONFAILING(*(uint16_t*)0x20013ec8 = 0);
    NONFAILING(*(uint16_t*)0x20013eca = 0);
    NONFAILING(*(uint16_t*)0x20013ecc = 0);
    NONFAILING(*(uint16_t*)0x20013ece = 0);
    NONFAILING(*(uint16_t*)0x20013ed0 = 0);
    NONFAILING(*(uint16_t*)0x20013ed2 = 0);
    NONFAILING(*(uint16_t*)0x20013ed4 = 0);
    NONFAILING(*(uint16_t*)0x20013ed6 = 0);
    NONFAILING(*(uint16_t*)0x20013ed8 = 0);
    NONFAILING(*(uint16_t*)0x20013eda = 0);
    NONFAILING(*(uint16_t*)0x20013edc = 0);
    NONFAILING(*(uint32_t*)0x20013ee0 = 0);
    NONFAILING(*(uint32_t*)0x20013ee4 = 0);
    NONFAILING(*(uint64_t*)0x20013ee8 = 0);
    NONFAILING(*(uint8_t*)0x20013ef0 = 0);
    NONFAILING(*(uint8_t*)0x20013ef1 = 0);
    NONFAILING(*(uint8_t*)0x20013ef2 = 0);
    NONFAILING(*(uint8_t*)0x20013ef3 = 0);
    NONFAILING(*(uint8_t*)0x20013ef4 = 0);
    NONFAILING(*(uint8_t*)0x20013ef5 = 0);
    NONFAILING(*(uint8_t*)0x20013ef6 = 0);
    NONFAILING(*(uint8_t*)0x20013ef7 = 0);
    NONFAILING(*(uint8_t*)0x20013ef8 = 0);
    NONFAILING(*(uint8_t*)0x20013ef9 = 0);
    NONFAILING(*(uint8_t*)0x20013efa = 0);
    NONFAILING(*(uint8_t*)0x20013efb = 0);
    NONFAILING(*(uint8_t*)0x20013efc = 0);
    NONFAILING(*(uint8_t*)0x20013efd = 0);
    NONFAILING(*(uint8_t*)0x20013efe = 0);
    NONFAILING(*(uint8_t*)0x20013eff = 0);
    NONFAILING(*(uint8_t*)0x20013f00 = 0);
    NONFAILING(*(uint8_t*)0x20013f01 = 0);
    NONFAILING(*(uint8_t*)0x20013f02 = 0);
    NONFAILING(*(uint8_t*)0x20013f03 = 0);
    NONFAILING(*(uint8_t*)0x20013f04 = 0);
    NONFAILING(*(uint8_t*)0x20013f05 = 0);
    NONFAILING(*(uint8_t*)0x20013f06 = 0);
    NONFAILING(*(uint8_t*)0x20013f07 = 0);
    NONFAILING(*(uint8_t*)0x20013f08 = 0);
    NONFAILING(*(uint8_t*)0x20013f09 = 0);
    NONFAILING(*(uint8_t*)0x20013f0a = 0);
    NONFAILING(*(uint8_t*)0x20013f0b = 0);
    NONFAILING(*(uint8_t*)0x20013f0c = 0);
    NONFAILING(*(uint8_t*)0x20013f0d = 0);
    NONFAILING(*(uint8_t*)0x20013f0e = 0);
    NONFAILING(*(uint8_t*)0x20013f0f = 0);
    NONFAILING(*(uint8_t*)0x20013f10 = 0);
    NONFAILING(*(uint8_t*)0x20013f11 = 0);
    NONFAILING(*(uint8_t*)0x20013f12 = 0);
    NONFAILING(*(uint8_t*)0x20013f13 = 0);
    NONFAILING(*(uint8_t*)0x20013f14 = 0);
    NONFAILING(*(uint8_t*)0x20013f15 = 0);
    NONFAILING(*(uint8_t*)0x20013f16 = 0);
    NONFAILING(*(uint8_t*)0x20013f17 = 0);
    NONFAILING(*(uint8_t*)0x20013f18 = 0);
    NONFAILING(*(uint8_t*)0x20013f19 = 0);
    NONFAILING(*(uint8_t*)0x20013f1a = 0);
    NONFAILING(*(uint8_t*)0x20013f1b = 0);
    NONFAILING(*(uint8_t*)0x20013f1c = 0);
    NONFAILING(*(uint8_t*)0x20013f1d = 0);
    NONFAILING(*(uint8_t*)0x20013f1e = 0);
    NONFAILING(*(uint8_t*)0x20013f1f = 0);
    NONFAILING(*(uint8_t*)0x20013f20 = 0);
    NONFAILING(*(uint8_t*)0x20013f21 = 0);
    NONFAILING(*(uint8_t*)0x20013f22 = 0);
    NONFAILING(*(uint8_t*)0x20013f23 = 0);
    NONFAILING(*(uint8_t*)0x20013f24 = 0);
    NONFAILING(*(uint8_t*)0x20013f25 = 0);
    NONFAILING(*(uint8_t*)0x20013f26 = 0);
    NONFAILING(*(uint8_t*)0x20013f27 = 0);
    NONFAILING(*(uint8_t*)0x20013f28 = 0);
    NONFAILING(*(uint8_t*)0x20013f29 = 0);
    NONFAILING(*(uint8_t*)0x20013f2a = 0);
    NONFAILING(*(uint8_t*)0x20013f2b = 0);
    NONFAILING(*(uint8_t*)0x20013f2c = 0);
    NONFAILING(*(uint8_t*)0x20013f2d = 0);
    NONFAILING(*(uint8_t*)0x20013f2e = 0);
    NONFAILING(*(uint8_t*)0x20013f2f = 0);
    NONFAILING(*(uint8_t*)0x20013f30 = 0);
    NONFAILING(*(uint8_t*)0x20013f31 = 0);
    NONFAILING(*(uint8_t*)0x20013f32 = 0);
    NONFAILING(*(uint8_t*)0x20013f33 = 0);
    NONFAILING(*(uint8_t*)0x20013f34 = 0);
    NONFAILING(*(uint8_t*)0x20013f35 = 0);
    NONFAILING(*(uint8_t*)0x20013f36 = 0);
    NONFAILING(*(uint8_t*)0x20013f37 = 0);
    NONFAILING(*(uint8_t*)0x20013f38 = 0);
    NONFAILING(*(uint8_t*)0x20013f39 = 0);
    NONFAILING(*(uint8_t*)0x20013f3a = 0);
    NONFAILING(*(uint8_t*)0x20013f3b = 0);
    NONFAILING(*(uint8_t*)0x20013f3c = 0);
    NONFAILING(*(uint8_t*)0x20013f3d = 0);
    NONFAILING(*(uint8_t*)0x20013f3e = 0);
    NONFAILING(*(uint8_t*)0x20013f3f = 0);
    NONFAILING(*(uint8_t*)0x20013f40 = 0);
    NONFAILING(*(uint8_t*)0x20013f41 = 0);
    NONFAILING(*(uint8_t*)0x20013f42 = 0);
    NONFAILING(*(uint8_t*)0x20013f43 = 0);
    NONFAILING(*(uint32_t*)0x20013f44 = 0);
    NONFAILING(*(uint16_t*)0x20013f48 = 0xc0);
    NONFAILING(*(uint16_t*)0x20013f4a = 0xe8);
    NONFAILING(*(uint32_t*)0x20013f4c = 0);
    NONFAILING(*(uint64_t*)0x20013f50 = 0);
    NONFAILING(*(uint64_t*)0x20013f58 = 0);
    NONFAILING(*(uint16_t*)0x20013f60 = 0x50);
    NONFAILING(memcpy((void*)0x20013f62, "\x6f\x73\x66\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00",
                      29));
    NONFAILING(*(uint8_t*)0x20013f7f = 0);
    NONFAILING(memcpy((void*)0x20013f80, "\x73\x79\x7a\x30\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00",
                      32));
    NONFAILING(*(uint32_t*)0x20013fa0 = 0);
    NONFAILING(*(uint32_t*)0x20013fa4 = 0);
    NONFAILING(*(uint32_t*)0x20013fa8 = 0);
    NONFAILING(*(uint32_t*)0x20013fac = 0);
    NONFAILING(*(uint16_t*)0x20013fb0 = 0x28);
    NONFAILING(memcpy((void*)0x20013fb2, "\x52\x45\x4a\x45\x43\x54\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                                         "\x00\x00",
                      29));
    NONFAILING(*(uint8_t*)0x20013fcf = 0);
    NONFAILING(*(uint32_t*)0x20013fd0 = 0);
    NONFAILING(*(uint64_t*)0x20001000 = 0);
    NONFAILING(*(uint64_t*)0x20001008 = 0);
    NONFAILING(*(uint64_t*)0x20001010 = 0);
    NONFAILING(*(uint64_t*)0x20001018 = 0);
    NONFAILING(*(uint64_t*)0x20001020 = 0);
    NONFAILING(*(uint64_t*)0x20001028 = 0);
    NONFAILING(*(uint64_t*)0x20001030 = 0);
    NONFAILING(*(uint64_t*)0x20001038 = 0);
    syscall(__NR_setsockopt, r[1], 0, 0x40, 0x20013c90, 0x348);
    break;
  }
}

void test()
{
  memset(r, -1, sizeof(r));
  execute(5);
  collide = 1;
  execute(5);
}

int main()
{
  for (procid = 0; procid < 8; procid++) {
    if (fork() == 0) {
      install_segv_handler();
      for (;;) {
        loop();
      }
    }
  }
  sleep(1000000);
  return 0;
}