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

#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <linux/net.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

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

const int kFailStatus = 67;
const int kRetryStatus = 69;

static void fail(const char* msg, ...)
{
  int e = errno;
  va_list args;
  va_start(args, msg);
  vfprintf(stderr, msg, args);
  va_end(args);
  fprintf(stderr, " (errno %d)\n", e);
  doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}

static uint64_t current_time_ms()
{
  struct timespec ts;

  if (clock_gettime(CLOCK_MONOTONIC, &ts))
    fail("clock_gettime failed");
  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}

struct ipt_getinfo {
  char name[32];
  unsigned int valid_hooks;
  unsigned int hook_entry[5];
  unsigned int underflow[5];
  unsigned int num_entries;
  unsigned int size;
};

struct ipt_get_entries {
  char name[32];
  unsigned int size;
  void* entrytable[1024 / sizeof(void*)];
};

struct xt_counters {
  uint64_t pcnt, bcnt;
};

struct ipt_replace {
  char name[32];
  unsigned int valid_hooks;
  unsigned int num_entries;
  unsigned int size;
  unsigned int hook_entry[5];
  unsigned int underflow[5];
  unsigned int num_counters;
  struct xt_counters* counters;
  char entrytable[1024];
};

struct ipt_table_desc {
  const char* name;
  struct ipt_getinfo info;
  struct ipt_get_entries entries;
  struct ipt_replace replace;
  struct xt_counters counters[10];
};

static struct ipt_table_desc ipv4_tables[] = {
    {.name = "filter"}, {.name = "nat"},      {.name = "mangle"},
    {.name = "raw"},    {.name = "security"},
};

#define IPT_BASE_CTL 64
#define IPT_SO_SET_REPLACE (IPT_BASE_CTL)
#define IPT_SO_GET_INFO (IPT_BASE_CTL)
#define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1)

static void checkpoint_net_namespace(void)
{
  socklen_t optlen;
  unsigned i;
  int fd;

  fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (fd == -1)
    fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)");
  for (i = 0; i < sizeof(ipv4_tables) / sizeof(ipv4_tables[0]); i++) {
    struct ipt_table_desc* table = &ipv4_tables[i];
    strcpy(table->info.name, table->name);
    strcpy(table->entries.name, table->name);
    strcpy(table->replace.name, table->name);
    optlen = sizeof(table->info);
    if (getsockopt(fd, SOL_IP, IPT_SO_GET_INFO, &table->info, &optlen)) {
      switch (errno) {
      case EPERM:
      case ENOENT:
      case ENOPROTOOPT:
        continue;
      }
      fail("getsockopt(IPT_SO_GET_INFO)");
    }
    if (table->info.size > sizeof(table->entries.entrytable))
      fail("table size is too large: %u", table->info.size);
    if (table->info.num_entries >
        sizeof(table->counters) / sizeof(table->counters[0]))
      fail("too many counters: %u", table->info.num_entries);
    table->entries.size = table->info.size;
    optlen = sizeof(table->entries) - sizeof(table->entries.entrytable) +
             table->info.size;
    if (getsockopt(fd, SOL_IP, IPT_SO_GET_ENTRIES, &table->entries, &optlen))
      fail("getsockopt(IPT_SO_GET_ENTRIES)");
    table->replace.valid_hooks = table->info.valid_hooks;
    table->replace.num_entries = table->info.num_entries;
    table->replace.counters = table->counters;
    table->replace.size = table->info.size;
    memcpy(table->replace.hook_entry, table->info.hook_entry,
           sizeof(table->replace.hook_entry));
    memcpy(table->replace.underflow, table->info.underflow,
           sizeof(table->replace.underflow));
    memcpy(table->replace.entrytable, table->entries.entrytable,
           table->info.size);
  }
  close(fd);
}

static void reset_net_namespace(void)
{
  struct ipt_get_entries entries;
  struct ipt_getinfo info;
  socklen_t optlen;
  unsigned i;
  int fd;

  memset(&info, 0, sizeof(info));
  memset(&entries, 0, sizeof(entries));
  fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (fd == -1)
    fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)");
  for (i = 0; i < sizeof(ipv4_tables) / sizeof(ipv4_tables[0]); i++) {
    struct ipt_table_desc* table = &ipv4_tables[i];
    if (table->info.valid_hooks == 0)
      continue;
    strcpy(info.name, table->name);
    optlen = sizeof(info);
    if (getsockopt(fd, SOL_IP, IPT_SO_GET_INFO, &info, &optlen))
      fail("getsockopt(IPT_SO_GET_INFO)");
    if (memcmp(&table->info, &info, sizeof(table->info)) == 0) {
      strcpy(entries.name, table->name);
      entries.size = table->info.size;
      optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size;
      if (getsockopt(fd, SOL_IP, IPT_SO_GET_ENTRIES, &entries, &optlen))
        fail("getsockopt(IPT_SO_GET_ENTRIES)");
      if (memcmp(&table->entries, &entries, optlen) == 0)
        continue;
    }
    table->replace.num_counters = info.num_entries;
    optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) +
             table->replace.size;
    if (setsockopt(fd, SOL_IP, IPT_SO_SET_REPLACE, &table->replace, optlen))
      fail("setsockopt(IPT_SO_SET_REPLACE)");
  }
  close(fd);
}

static void test();

void loop()
{
  int iter;
  checkpoint_net_namespace();
  for (iter = 0;; iter++) {
    int pid = fork();
    if (pid < 0)
      fail("loop fork failed");
    if (pid == 0) {
      prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
      setpgrp();
      test();
      doexit(0);
    }
    int status = 0;
    uint64_t start = current_time_ms();
    for (;;) {
      int res = waitpid(-1, &status, __WALL | WNOHANG);
      if (res == pid)
        break;
      usleep(1000);
      if (current_time_ms() - start > 5 * 1000) {
        kill(-pid, SIGKILL);
        kill(pid, SIGKILL);
        while (waitpid(-1, &status, __WALL) != pid) {
        }
        break;
      }
    }
    reset_net_namespace();
  }
}

long r[2];
void test()
{
  memset(r, -1, sizeof(r));
  syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0);
  r[0] = syscall(__NR_socket, 2, 1, 0);
  *(uint32_t*)0x20000000 = htobe32(0);
  *(uint32_t*)0x20000004 = htobe32(-1);
  *(uint32_t*)0x20000008 = 0;
  syscall(__NR_setsockopt, r[0], 0, 0x27, 0x20000000, 0xc);
  r[1] = syscall(__NR_socket, 2, 0x80001, 0);
  memcpy((void*)0x20777825, "\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);
  *(uint32_t*)0x20777845 = 0xe;
  *(uint32_t*)0x20777849 = 4;
  *(uint32_t*)0x2077784d = 0x280;
  *(uint32_t*)0x20777851 = -1;
  *(uint32_t*)0x20777855 = 0;
  *(uint32_t*)0x20777859 = 0;
  *(uint32_t*)0x2077785d = 0;
  *(uint32_t*)0x20777861 = -1;
  *(uint32_t*)0x20777865 = -1;
  *(uint32_t*)0x20777869 = 0;
  *(uint32_t*)0x2077786d = 0;
  *(uint32_t*)0x20777871 = 0;
  *(uint32_t*)0x20777875 = -1;
  *(uint32_t*)0x20777879 = 4;
  *(uint64_t*)0x2077787d = 0x20012fc0;
  *(uint8_t*)0x20777885 = 0;
  *(uint8_t*)0x20777886 = 0;
  *(uint8_t*)0x20777887 = 0;
  *(uint8_t*)0x20777888 = 0;
  *(uint8_t*)0x20777889 = 0;
  *(uint8_t*)0x2077788a = 0;
  *(uint8_t*)0x2077788b = 0;
  *(uint8_t*)0x2077788c = 0;
  *(uint8_t*)0x2077788d = 0;
  *(uint8_t*)0x2077788e = 0;
  *(uint8_t*)0x2077788f = 0;
  *(uint8_t*)0x20777890 = 0;
  *(uint8_t*)0x20777891 = 0;
  *(uint8_t*)0x20777892 = 0;
  *(uint8_t*)0x20777893 = 0;
  *(uint8_t*)0x20777894 = 0;
  *(uint8_t*)0x20777895 = 0;
  *(uint8_t*)0x20777896 = 0;
  *(uint8_t*)0x20777897 = 0;
  *(uint8_t*)0x20777898 = 0;
  *(uint8_t*)0x20777899 = 0;
  *(uint8_t*)0x2077789a = 0;
  *(uint8_t*)0x2077789b = 0;
  *(uint8_t*)0x2077789c = 0;
  *(uint8_t*)0x2077789d = 0;
  *(uint8_t*)0x2077789e = 0;
  *(uint8_t*)0x2077789f = 0;
  *(uint8_t*)0x207778a0 = 0;
  *(uint8_t*)0x207778a1 = 0;
  *(uint8_t*)0x207778a2 = 0;
  *(uint8_t*)0x207778a3 = 0;
  *(uint8_t*)0x207778a4 = 0;
  *(uint8_t*)0x207778a5 = 0;
  *(uint8_t*)0x207778a6 = 0;
  *(uint8_t*)0x207778a7 = 0;
  *(uint8_t*)0x207778a8 = 0;
  *(uint8_t*)0x207778a9 = 0;
  *(uint8_t*)0x207778aa = 0;
  *(uint8_t*)0x207778ab = 0;
  *(uint8_t*)0x207778ac = 0;
  *(uint8_t*)0x207778ad = 0;
  *(uint8_t*)0x207778ae = 0;
  *(uint8_t*)0x207778af = 0;
  *(uint8_t*)0x207778b0 = 0;
  *(uint8_t*)0x207778b1 = 0;
  *(uint8_t*)0x207778b2 = 0;
  *(uint8_t*)0x207778b3 = 0;
  *(uint8_t*)0x207778b4 = 0;
  *(uint8_t*)0x207778b5 = 0;
  *(uint8_t*)0x207778b6 = 0;
  *(uint8_t*)0x207778b7 = 0;
  *(uint8_t*)0x207778b8 = 0;
  *(uint8_t*)0x207778b9 = 0;
  *(uint8_t*)0x207778ba = 0;
  *(uint8_t*)0x207778bb = 0;
  *(uint8_t*)0x207778bc = 0;
  *(uint8_t*)0x207778bd = 0;
  *(uint8_t*)0x207778be = 0;
  *(uint8_t*)0x207778bf = 0;
  *(uint8_t*)0x207778c0 = 0;
  *(uint8_t*)0x207778c1 = 0;
  *(uint8_t*)0x207778c2 = 0;
  *(uint8_t*)0x207778c3 = 0;
  *(uint8_t*)0x207778c4 = 0;
  *(uint8_t*)0x207778c5 = 0;
  *(uint8_t*)0x207778c6 = 0;
  *(uint8_t*)0x207778c7 = 0;
  *(uint8_t*)0x207778c8 = 0;
  *(uint8_t*)0x207778c9 = 0;
  *(uint8_t*)0x207778ca = 0;
  *(uint8_t*)0x207778cb = 0;
  *(uint8_t*)0x207778cc = 0;
  *(uint8_t*)0x207778cd = 0;
  *(uint8_t*)0x207778ce = 0;
  *(uint8_t*)0x207778cf = 0;
  *(uint8_t*)0x207778d0 = 0;
  *(uint8_t*)0x207778d1 = 0;
  *(uint8_t*)0x207778d2 = 0;
  *(uint8_t*)0x207778d3 = 0;
  *(uint8_t*)0x207778d4 = 0;
  *(uint8_t*)0x207778d5 = 0;
  *(uint8_t*)0x207778d6 = 0;
  *(uint8_t*)0x207778d7 = 0;
  *(uint8_t*)0x207778d8 = 0;
  *(uint32_t*)0x207778d9 = 0;
  *(uint16_t*)0x207778dd = 0x70;
  *(uint16_t*)0x207778df = 0x98;
  *(uint32_t*)0x207778e1 = 0;
  *(uint64_t*)0x207778e5 = 0;
  *(uint64_t*)0x207778ed = 0;
  *(uint16_t*)0x207778f5 = 0x28;
  memcpy((void*)0x207778f7, "\x00\x00\x00\x00\x00\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);
  *(uint8_t*)0x20777914 = 0;
  *(uint32_t*)0x20777915 = 0xfffffffe;
  *(uint32_t*)0x2077791d = htobe32(0x7f000001);
  *(uint32_t*)0x20777921 = htobe32(-1);
  *(uint32_t*)0x20777925 = htobe32(0);
  *(uint32_t*)0x20777929 = htobe32(0);
  memcpy((void*)0x2077792d,
         "\x69\x70\x36\x5f\x76\x74\x69\x30\x00\x00\x00\x00\x00\x00\x00\x00",
         16);
  *(uint8_t*)0x2077793d = 0x73;
  *(uint8_t*)0x2077793e = 0x79;
  *(uint8_t*)0x2077793f = 0x7a;
  *(uint8_t*)0x20777940 = 0;
  *(uint8_t*)0x20777941 = 0;
  *(uint8_t*)0x2077794d = 0;
  *(uint8_t*)0x2077794e = 0;
  *(uint8_t*)0x2077794f = 0;
  *(uint8_t*)0x20777950 = 0;
  *(uint8_t*)0x20777951 = 0;
  *(uint8_t*)0x20777952 = 0;
  *(uint8_t*)0x20777953 = 0;
  *(uint8_t*)0x20777954 = 0;
  *(uint8_t*)0x20777955 = 0;
  *(uint8_t*)0x20777956 = 0;
  *(uint8_t*)0x20777957 = 0;
  *(uint8_t*)0x20777958 = 0;
  *(uint8_t*)0x20777959 = 0;
  *(uint8_t*)0x2077795a = 0;
  *(uint8_t*)0x2077795b = 0;
  *(uint8_t*)0x2077795c = 0;
  *(uint8_t*)0x2077795d = 0;
  *(uint8_t*)0x2077795e = 0;
  *(uint8_t*)0x2077795f = 0;
  *(uint8_t*)0x20777960 = 0;
  *(uint8_t*)0x20777961 = 0;
  *(uint8_t*)0x20777962 = 0;
  *(uint8_t*)0x20777963 = 0;
  *(uint8_t*)0x20777964 = 0;
  *(uint8_t*)0x20777965 = 0;
  *(uint8_t*)0x20777966 = 0;
  *(uint8_t*)0x20777967 = 0;
  *(uint8_t*)0x20777968 = 0;
  *(uint8_t*)0x20777969 = 0;
  *(uint8_t*)0x2077796a = 0;
  *(uint8_t*)0x2077796b = 0;
  *(uint8_t*)0x2077796c = 0;
  *(uint16_t*)0x2077796d = 0;
  *(uint8_t*)0x2077796f = 0;
  *(uint8_t*)0x20777970 = 0;
  *(uint32_t*)0x20777971 = 0;
  *(uint16_t*)0x20777975 = 0x70;
  *(uint16_t*)0x20777977 = 0x98;
  *(uint32_t*)0x20777979 = 0;
  *(uint64_t*)0x2077797d = 0;
  *(uint64_t*)0x20777985 = 0;
  *(uint16_t*)0x2077798d = 0x28;
  memcpy((void*)0x2077798f, "\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);
  *(uint8_t*)0x207779ac = 0;
  *(uint32_t*)0x207779ad = 0;
  *(uint8_t*)0x207779b5 = 0xac;
  *(uint8_t*)0x207779b6 = 0x14;
  *(uint8_t*)0x207779b7 = 0;
  *(uint8_t*)0x207779b8 = 0;
  *(uint32_t*)0x207779b9 = htobe32(0xe0000001);
  *(uint32_t*)0x207779bd = htobe32(0);
  *(uint32_t*)0x207779c1 = htobe32(0);
  memcpy((void*)0x207779c5,
         "\x6b\xd6\xd4\x48\x45\x73\x6f\x88\x9e\xc1\xcf\x4c\x41\xf2\xaf\xfa",
         16);
  *(uint8_t*)0x207779d5 = 0x73;
  *(uint8_t*)0x207779d6 = 0x79;
  *(uint8_t*)0x207779d7 = 0x7a;
  *(uint8_t*)0x207779d8 = 0;
  *(uint8_t*)0x207779d9 = 0;
  *(uint8_t*)0x207779e5 = 0;
  *(uint8_t*)0x207779e6 = 0;
  *(uint8_t*)0x207779e7 = 0;
  *(uint8_t*)0x207779e8 = 0;
  *(uint8_t*)0x207779e9 = 0;
  *(uint8_t*)0x207779ea = 0;
  *(uint8_t*)0x207779eb = 0;
  *(uint8_t*)0x207779ec = 0;
  *(uint8_t*)0x207779ed = 0;
  *(uint8_t*)0x207779ee = 0;
  *(uint8_t*)0x207779ef = 0;
  *(uint8_t*)0x207779f0 = 0;
  *(uint8_t*)0x207779f1 = 0;
  *(uint8_t*)0x207779f2 = 0;
  *(uint8_t*)0x207779f3 = 0;
  *(uint8_t*)0x207779f4 = 0;
  *(uint8_t*)0x207779f5 = 0;
  *(uint8_t*)0x207779f6 = 0;
  *(uint8_t*)0x207779f7 = 0;
  *(uint8_t*)0x207779f8 = 0;
  *(uint8_t*)0x207779f9 = 0;
  *(uint8_t*)0x207779fa = 0;
  *(uint8_t*)0x207779fb = 0;
  *(uint8_t*)0x207779fc = 0;
  *(uint8_t*)0x207779fd = 0;
  *(uint8_t*)0x207779fe = 0;
  *(uint8_t*)0x207779ff = 0;
  *(uint8_t*)0x20777a00 = 0;
  *(uint8_t*)0x20777a01 = 0;
  *(uint8_t*)0x20777a02 = 0;
  *(uint8_t*)0x20777a03 = 0;
  *(uint8_t*)0x20777a04 = 0;
  *(uint16_t*)0x20777a05 = 0;
  *(uint8_t*)0x20777a07 = 0;
  *(uint8_t*)0x20777a08 = 0;
  *(uint32_t*)0x20777a09 = 0;
  *(uint16_t*)0x20777a0d = 0x70;
  *(uint16_t*)0x20777a0f = 0xb8;
  *(uint32_t*)0x20777a11 = 0;
  *(uint64_t*)0x20777a15 = 0;
  *(uint64_t*)0x20777a1d = 0;
  *(uint16_t*)0x20777a25 = 0x48;
  memcpy((void*)0x20777a27, "\x54\x45\x45\x00\x00\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);
  *(uint8_t*)0x20777a44 = 1;
  *(uint8_t*)0x20777a45 = 0xfe;
  *(uint8_t*)0x20777a46 = 0x80;
  *(uint8_t*)0x20777a47 = 0;
  *(uint8_t*)0x20777a48 = 0;
  *(uint8_t*)0x20777a49 = 0;
  *(uint8_t*)0x20777a4a = 0;
  *(uint8_t*)0x20777a4b = 0;
  *(uint8_t*)0x20777a4c = 0;
  *(uint8_t*)0x20777a4d = 0;
  *(uint8_t*)0x20777a4e = 0;
  *(uint8_t*)0x20777a4f = 0;
  *(uint8_t*)0x20777a50 = 0;
  *(uint8_t*)0x20777a51 = 0;
  *(uint8_t*)0x20777a52 = 0;
  *(uint8_t*)0x20777a53 = 0;
  *(uint8_t*)0x20777a54 = 0;
  *(uint8_t*)0x20777a55 = 0x73;
  *(uint8_t*)0x20777a56 = 0x79;
  *(uint8_t*)0x20777a57 = 0x7a;
  *(uint8_t*)0x20777a58 = 0x30;
  *(uint8_t*)0x20777a59 = 0;
  *(uint64_t*)0x20777a65 = 0;
  *(uint32_t*)0x20777a6d = htobe32(0xe0000002);
  *(uint32_t*)0x20777a71 = htobe32(0x7f000001);
  *(uint32_t*)0x20777a75 = htobe32(0);
  *(uint32_t*)0x20777a79 = htobe32(0);
  memcpy((void*)0x20777a7d,
         "\x69\x66\x62\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
         16);
  *(uint8_t*)0x20777a8d = 0x73;
  *(uint8_t*)0x20777a8e = 0x79;
  *(uint8_t*)0x20777a8f = 0x7a;
  *(uint8_t*)0x20777a90 = 0;
  *(uint8_t*)0x20777a91 = 0;
  *(uint8_t*)0x20777a9d = 0;
  *(uint8_t*)0x20777a9e = 0;
  *(uint8_t*)0x20777a9f = 0;
  *(uint8_t*)0x20777aa0 = 0;
  *(uint8_t*)0x20777aa1 = 0;
  *(uint8_t*)0x20777aa2 = 0;
  *(uint8_t*)0x20777aa3 = 0;
  *(uint8_t*)0x20777aa4 = 0;
  *(uint8_t*)0x20777aa5 = 0;
  *(uint8_t*)0x20777aa6 = 0;
  *(uint8_t*)0x20777aa7 = 0;
  *(uint8_t*)0x20777aa8 = 0;
  *(uint8_t*)0x20777aa9 = 0;
  *(uint8_t*)0x20777aaa = 0;
  *(uint8_t*)0x20777aab = 0;
  *(uint8_t*)0x20777aac = 0;
  *(uint8_t*)0x20777aad = 0;
  *(uint8_t*)0x20777aae = 0;
  *(uint8_t*)0x20777aaf = 0;
  *(uint8_t*)0x20777ab0 = 0;
  *(uint8_t*)0x20777ab1 = 0;
  *(uint8_t*)0x20777ab2 = 0;
  *(uint8_t*)0x20777ab3 = 0;
  *(uint8_t*)0x20777ab4 = 0;
  *(uint8_t*)0x20777ab5 = 0;
  *(uint8_t*)0x20777ab6 = 0;
  *(uint8_t*)0x20777ab7 = 0;
  *(uint8_t*)0x20777ab8 = 0;
  *(uint8_t*)0x20777ab9 = 0;
  *(uint8_t*)0x20777aba = 0;
  *(uint8_t*)0x20777abb = 0;
  *(uint8_t*)0x20777abc = 0;
  *(uint16_t*)0x20777abd = 0;
  *(uint8_t*)0x20777abf = 0;
  *(uint8_t*)0x20777ac0 = 0;
  *(uint32_t*)0x20777ac1 = 0;
  *(uint16_t*)0x20777ac5 = 0x70;
  *(uint16_t*)0x20777ac7 = 0x98;
  *(uint32_t*)0x20777ac9 = 0;
  *(uint64_t*)0x20777acd = 0;
  *(uint64_t*)0x20777ad5 = 0;
  *(uint16_t*)0x20777add = 0x28;
  memcpy((void*)0x20777adf, "\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);
  *(uint8_t*)0x20777afc = 0;
  *(uint32_t*)0x20777afd = 0;
  *(uint64_t*)0x20012fc0 = 0;
  *(uint64_t*)0x20012fc8 = 0;
  *(uint64_t*)0x20012fd0 = 0;
  *(uint64_t*)0x20012fd8 = 0;
  *(uint64_t*)0x20012fe0 = 0;
  *(uint64_t*)0x20012fe8 = 0;
  *(uint64_t*)0x20012ff0 = 0;
  *(uint64_t*)0x20012ff8 = 0;
  syscall(__NR_setsockopt, r[1], 0, 0x40, 0x20777825, 0x2e0);
}

int main()
{
  for (;;) {
    loop();
  }
}