// autogenerated by syzkaller (http://github.com/google/syzkaller)

#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>

#define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1)

#define BITMASK_LEN_OFF(type, bf_off, bf_len)                                  \
  (type)(BITMASK_LEN(type, (bf_len)) << (bf_off))

#define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len)                      \
  if ((bf_off) == 0 && (bf_len) == 0) {                                        \
    *(type*)(addr) = (type)(val);                                              \
  } else {                                                                     \
    type new_val = *(type*)(addr);                                             \
    new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len));                     \
    new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off);          \
    *(type*)(addr) = new_val;                                                  \
  }

#ifndef __NR_bpf
#define __NR_bpf 321
#endif

long r[2];
void loop()
{
  memset(r, -1, sizeof(r));
  syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0);
  *(uint32_t*)0x20161000 = 0;
  *(uint32_t*)0x20161004 = 0x1c;
  *(uint64_t*)0x20161008 = 0x20519fa8;
  *(uint16_t*)0x20519fa8 = 0xa;
  *(uint16_t*)0x20519faa = 0;
  *(uint32_t*)0x20519fac = 0;
  *(uint8_t*)0x20519fb0 = -1;
  *(uint8_t*)0x20519fb1 = 1;
  *(uint8_t*)0x20519fb2 = 0;
  *(uint8_t*)0x20519fb3 = 0;
  *(uint8_t*)0x20519fb4 = 0;
  *(uint8_t*)0x20519fb5 = 0;
  *(uint8_t*)0x20519fb6 = 0;
  *(uint8_t*)0x20519fb7 = 0;
  *(uint8_t*)0x20519fb8 = 0;
  *(uint8_t*)0x20519fb9 = 0;
  *(uint8_t*)0x20519fba = 0;
  *(uint8_t*)0x20519fbb = 0;
  *(uint8_t*)0x20519fbc = 0;
  *(uint8_t*)0x20519fbd = 0;
  *(uint8_t*)0x20519fbe = 0;
  *(uint8_t*)0x20519fbf = 1;
  *(uint32_t*)0x20519fc0 = 0xcc;
  *(uint32_t*)0x20f91ffc = 0x10;
  syscall(__NR_getsockopt, -1, 0x84, 0x6f, 0x20161000, 0x20f91ffc);
  *(uint32_t*)0x20903000 = 1;
  *(uint32_t*)0x20903004 = 5;
  *(uint64_t*)0x20903008 = 0x20519fa8;
  *(uint64_t*)0x20903010 = 0x20c43000;
  *(uint32_t*)0x20903018 = 0x8000;
  *(uint32_t*)0x2090301c = 0x1000;
  *(uint64_t*)0x20903020 = 0x209ab000;
  *(uint32_t*)0x20903028 = 0;
  *(uint32_t*)0x2090302c = 0;
  *(uint8_t*)0x20903030 = 0;
  *(uint8_t*)0x20903031 = 0;
  *(uint8_t*)0x20903032 = 0;
  *(uint8_t*)0x20903033 = 0;
  *(uint8_t*)0x20903034 = 0;
  *(uint8_t*)0x20903035 = 0;
  *(uint8_t*)0x20903036 = 0;
  *(uint8_t*)0x20903037 = 0;
  *(uint8_t*)0x20903038 = 0;
  *(uint8_t*)0x20903039 = 0;
  *(uint8_t*)0x2090303a = 0;
  *(uint8_t*)0x2090303b = 0;
  *(uint8_t*)0x2090303c = 0;
  *(uint8_t*)0x2090303d = 0;
  *(uint8_t*)0x2090303e = 0;
  *(uint8_t*)0x2090303f = 0;
  *(uint32_t*)0x20903040 = 0;
  *(uint8_t*)0x20519fa8 = 0x18;
  STORE_BY_BITMASK(uint8_t, 0x20519fa9, 0, 0, 4);
  STORE_BY_BITMASK(uint8_t, 0x20519fa9, 0, 4, 4);
  *(uint16_t*)0x20519faa = 0;
  *(uint32_t*)0x20519fac = 0;
  *(uint8_t*)0x20519fb0 = 0;
  *(uint8_t*)0x20519fb1 = 0;
  *(uint16_t*)0x20519fb2 = 0;
  *(uint32_t*)0x20519fb4 = 0;
  STORE_BY_BITMASK(uint8_t, 0x20519fb8, 3, 0, 3);
  STORE_BY_BITMASK(uint8_t, 0x20519fb8, 7, 3, 2);
  STORE_BY_BITMASK(uint8_t, 0x20519fb8, 0xb, 5, 3);
  STORE_BY_BITMASK(uint8_t, 0x20519fb9, 0x7a, 0, 4);
  STORE_BY_BITMASK(uint8_t, 0x20519fb9, 0, 4, 4);
  *(uint16_t*)0x20519fba = 0xfff0;
  *(uint32_t*)0x20519fbc = 0;
  *(uint8_t*)0x20519fc8 = 0x95;
  *(uint8_t*)0x20519fc9 = 0;
  *(uint16_t*)0x20519fca = 0;
  *(uint32_t*)0x20519fcc = 0;
  memcpy((void*)0x20c43000, "syzkaller", 10);
  r[0] = syscall(__NR_bpf, 5, 0x20903000, 0x48);
  r[1] = syscall(__NR_socket, 0x10, 3, 0);
  *(uint32_t*)0x209da000 = r[0];
  syscall(__NR_setsockopt, r[1], 1, 0x32, 0x209da000, 4);
  memcpy((void*)0x20fd3000, "\x26\x00\x00\x00\x5e\x00\x09\x00\x00\x00\xea\xf8"
                            "\x3a\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
                            "\xff\xff\xff\x00\x00\x08\xdb\x1e\xe9\xff\x44\x35"
                            "\xea\xde",
         38);
  syscall(__NR_write, r[1], 0x20fd3000, 0x26);
}

int main()
{
  loop();
  return 0;
}
