// https://syzkaller.appspot.com/bug?id=c362601f055ed0d3b7878f3880f4c96c29e82af1
// 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[1] = {0xffffffffffffffff};

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;
  *(uint32_t*)0x20001340 = 0;
  *(uint32_t*)0x20001344 = 0x80;
  *(uint8_t*)0x20001348 = 0;
  *(uint8_t*)0x20001349 = 0;
  *(uint8_t*)0x2000134a = 0;
  *(uint8_t*)0x2000134b = 0;
  *(uint32_t*)0x2000134c = 0;
  *(uint64_t*)0x20001350 = 0;
  *(uint64_t*)0x20001358 = 0;
  *(uint64_t*)0x20001360 = 0;
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 0, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 1, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 2, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 3, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 4, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 5, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 6, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 7, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 8, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 9, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 10, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 11, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 12, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 13, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 14, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 15, 2);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 17, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 18, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 19, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 20, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 21, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 22, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 23, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 24, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 25, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 26, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 27, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 28, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 29, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 30, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 31, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 32, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 33, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 34, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 35, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 36, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 37, 1);
  STORE_BY_BITMASK(uint64_t, , 0x20001368, 0, 38, 26);
  *(uint32_t*)0x20001370 = 0;
  *(uint32_t*)0x20001374 = 0;
  *(uint64_t*)0x20001378 = 0;
  *(uint64_t*)0x20001380 = 0;
  *(uint64_t*)0x20001388 = 0xb;
  *(uint64_t*)0x20001390 = 0;
  *(uint32_t*)0x20001398 = 0;
  *(uint32_t*)0x2000139c = 0;
  *(uint64_t*)0x200013a0 = 0;
  *(uint32_t*)0x200013a8 = 0;
  *(uint16_t*)0x200013ac = 0;
  *(uint16_t*)0x200013ae = 0;
  *(uint32_t*)0x200013b0 = 0;
  *(uint32_t*)0x200013b4 = 0;
  *(uint64_t*)0x200013b8 = 0;
  syscall(__NR_perf_event_open, 0x20001340ul, 0, 0ul, -1, 0ul);
  res = syscall(__NR_socket, 0xaul, 1ul, 0);
  if (res != -1)
    r[0] = res;
  *(uint32_t*)0x20000000 = 1;
  syscall(__NR_setsockopt, r[0], 6, 0x13, 0x20000000ul, 4ul);
  *(uint16_t*)0x20000200 = 0xa;
  *(uint16_t*)0x20000202 = htobe16(0);
  *(uint32_t*)0x20000204 = htobe32(0);
  memset((void*)0x20000208, 0, 16);
  *(uint32_t*)0x20000218 = 0;
  syscall(__NR_connect, r[0], 0x20000200ul, 0x1cul);
  memcpy((void*)0x20000540, "tls\000", 4);
  syscall(__NR_setsockopt, r[0], 6, 0x1f, 0x20000540ul, 4ul);
  *(uint16_t*)0x20000040 = 0x303;
  *(uint16_t*)0x20000042 = 0x33;
  memcpy((void*)0x20000044, "\x2e\x99\x16\x92\x00\x20\xb9\xad", 8);
  memcpy((void*)0x2000004c,
         "\x53\x49\x9a\xdd\xa3\x7e\x5c\x14\x26\x5f\x29\x8f\x9f\x57\x22\xd7",
         16);
  memset((void*)0x2000005c, 0, 4);
  memcpy((void*)0x20000060, "\xc7\x91\xd3\x43\x04\xbb\x24\xeb", 8);
  syscall(__NR_setsockopt, r[0], 0x11a, 1, 0x20000040ul, 0x28ul);
  *(uint64_t*)0x20000080 = 0x200000c0;
  memset((void*)0x200000c0, 207, 1);
  *(uint64_t*)0x20000088 = 0x7f02;
  syscall(__NR_writev, r[0], 0x20000080ul, 0x27ful);
  return 0;
}