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

#define _GNU_SOURCE

#include <endian.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off))
#define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len)               \
  *(type*)(addr) =                                                             \
      htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) |           \
            (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len))))

uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,
                 0x0};

int main(void)
{
  syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
  syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
  syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
  intptr_t res = 0;
  res = syscall(__NR_socket, 0x10ul, 3ul, 0);
  if (res != -1)
    r[0] = res;
  *(uint64_t*)0x20000300 = 0;
  *(uint32_t*)0x20000308 = 0;
  *(uint64_t*)0x20000310 = 0x200002c0;
  *(uint64_t*)0x200002c0 = 0x20000000;
  *(uint32_t*)0x20000000 = 0x1c;
  *(uint16_t*)0x20000004 = 0x68;
  *(uint16_t*)0x20000006 = 3;
  *(uint32_t*)0x20000008 = 0;
  *(uint32_t*)0x2000000c = 0;
  *(uint8_t*)0x20000010 = 0;
  *(uint8_t*)0x20000011 = 0;
  *(uint8_t*)0x20000012 = 0;
  *(uint8_t*)0x20000013 = 0;
  *(uint32_t*)0x20000014 = 0;
  *(uint16_t*)0x20000018 = 4;
  *(uint16_t*)0x2000001a = 2;
  *(uint64_t*)0x200002c8 = 0x1c;
  *(uint64_t*)0x20000318 = 1;
  *(uint64_t*)0x20000320 = 0;
  *(uint64_t*)0x20000328 = 0;
  *(uint32_t*)0x20000330 = 0;
  syscall(__NR_sendmsg, r[0], 0x20000300ul, 0ul);
  res = syscall(__NR_socket, 0x10ul, 3ul, 0);
  if (res != -1)
    r[1] = res;
  res = syscall(__NR_socket, 0x11ul, 0x800000003ul, 0);
  if (res != -1)
    r[2] = res;
  *(uint16_t*)0x20000080 = 0x11;
  memcpy((void*)0x20000082,
         "\x00\x00\x01\x00\x00\x00\x00\x00\x08\x00\x44\x94\x4e\xeb\xa7\x1a\x49"
         "\x76\xe2\x52\x92\x2c\xb1\x8f\x6e\x2e\x2a\xc5\x00\x00\x00\x01\x2e\x0b"
         "\x38\x36\x00\x54\x04\xb0\xe0\x30\x1a\x06\x00\x75\xf2\xe3\xff\x5f\x16"
         "\x3e\xe3\x40\xb7\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\xfd\x79\x2b"
         "\xbf\x0e\x5b\xf5\xff\x1b\x08\x16\xf3\xf6\xdb\x1c\x00\x01\x00\x00\x00"
         "\x00\x00\x00\x00\x49\x74\x00\x00\x00\x00\x00\x00\x00\x06\xad\x8e\x5e"
         "\xcc\x32\x6d\x3a\x09\xff\xc2\xc6\x54\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x00\x00",
         126);
  syscall(__NR_bind, r[2], 0x20000080ul, 0x80ul);
  *(uint32_t*)0x20000140 = 0x14;
  res = syscall(__NR_getsockname, r[2], 0x20000040ul, 0x20000140ul);
  if (res != -1)
    r[3] = *(uint32_t*)0x20000044;
  *(uint64_t*)0x20000580 = 0;
  *(uint32_t*)0x20000588 = 0;
  *(uint64_t*)0x20000590 = 0x20000780;
  *(uint64_t*)0x20000780 = 0x20000240;
  *(uint32_t*)0x20000240 = 0x28;
  *(uint16_t*)0x20000244 = 0x18;
  *(uint16_t*)0x20000246 = 0x8ddd;
  *(uint32_t*)0x20000248 = 0;
  *(uint32_t*)0x2000024c = 0;
  *(uint8_t*)0x20000250 = 2;
  *(uint8_t*)0x20000251 = 0;
  *(uint8_t*)0x20000252 = 0;
  *(uint8_t*)0x20000253 = 0;
  *(uint8_t*)0x20000254 = 0;
  *(uint8_t*)0x20000255 = 0;
  *(uint8_t*)0x20000256 = 0;
  *(uint8_t*)0x20000257 = 9;
  *(uint32_t*)0x20000258 = 0;
  *(uint16_t*)0x2000025c = 8;
  *(uint16_t*)0x2000025e = 0x1e;
  *(uint32_t*)0x20000260 = r[3];
  *(uint16_t*)0x20000264 = 4;
  STORE_BY_BITMASK(uint16_t, , 0x20000266, 8, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x20000267, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x20000267, 1, 7, 1);
  *(uint64_t*)0x20000788 = 0x28;
  *(uint64_t*)0x20000598 = 1;
  *(uint64_t*)0x200005a0 = 0;
  *(uint64_t*)0x200005a8 = 0;
  *(uint32_t*)0x200005b0 = 0;
  syscall(__NR_sendmsg, r[1], 0x20000580ul, 0ul);
  return 0;
}