// https://syzkaller.appspot.com/bug?id=8593724cce469c9898b7fbc49f48f4943fee940f
// 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>

#ifndef __NR_bpf
#define __NR_bpf 321
#endif

#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, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul,
          /*fd=*/(intptr_t)-1, /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul,
          /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul,
          /*fd=*/(intptr_t)-1, /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul,
          /*fd=*/(intptr_t)-1, /*offset=*/0ul);
  const char* reason;
  (void)reason;
  intptr_t res = 0;
  if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {
  }
  *(uint32_t*)0x2000000000c0 = 3;
  *(uint32_t*)0x2000000000c4 = 4;
  *(uint64_t*)0x2000000000c8 = 0x200000000700;
  *(uint8_t*)0x200000000700 = 0x18;
  STORE_BY_BITMASK(uint8_t, , 0x200000000701, 0, 0, 4);
  STORE_BY_BITMASK(uint8_t, , 0x200000000701, 0, 4, 4);
  *(uint16_t*)0x200000000702 = 0;
  *(uint32_t*)0x200000000704 = 0;
  *(uint8_t*)0x200000000708 = 0;
  *(uint8_t*)0x200000000709 = 0;
  *(uint16_t*)0x20000000070a = 0;
  *(uint32_t*)0x20000000070c = 0;
  *(uint8_t*)0x200000000710 = 0x85;
  *(uint8_t*)0x200000000711 = 0;
  *(uint16_t*)0x200000000712 = 0;
  *(uint32_t*)0x200000000714 = 0x4f;
  *(uint8_t*)0x200000000718 = 0x95;
  *(uint8_t*)0x200000000719 = 0;
  *(uint16_t*)0x20000000071a = 0;
  *(uint32_t*)0x20000000071c = 0;
  *(uint64_t*)0x2000000000d0 = 0x200000000200;
  memcpy((void*)0x200000000200, "GPL\000", 4);
  *(uint32_t*)0x2000000000d8 = 0;
  *(uint32_t*)0x2000000000dc = 0;
  *(uint64_t*)0x2000000000e0 = 0;
  *(uint32_t*)0x2000000000e8 = 0;
  *(uint32_t*)0x2000000000ec = 0;
  memset((void*)0x2000000000f0, 0, 16);
  *(uint32_t*)0x200000000100 = 0;
  *(uint32_t*)0x200000000104 = 0;
  *(uint32_t*)0x200000000108 = 0;
  *(uint32_t*)0x20000000010c = 0;
  *(uint64_t*)0x200000000110 = 0;
  *(uint32_t*)0x200000000118 = 0;
  *(uint32_t*)0x20000000011c = 0;
  *(uint64_t*)0x200000000120 = 0;
  *(uint32_t*)0x200000000128 = 0;
  *(uint32_t*)0x20000000012c = 0;
  *(uint32_t*)0x200000000130 = 0;
  *(uint32_t*)0x200000000134 = 0;
  *(uint64_t*)0x200000000138 = 0;
  *(uint64_t*)0x200000000140 = 0;
  *(uint32_t*)0x200000000148 = 0;
  *(uint32_t*)0x20000000014c = 0;
  *(uint32_t*)0x200000000150 = 0;
  res =
      syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x2000000000c0ul, /*size=*/0x94ul);
  if (res != -1)
    r[0] = res;
  *(uint32_t*)0x200000000400 = r[0];
  *(uint32_t*)0x200000000404 = 0x2a0;
  *(uint32_t*)0x200000000408 = 0xe;
  *(uint32_t*)0x20000000040c = 0;
  *(uint64_t*)0x200000000410 = 0x2000000002c0;
  memcpy((void*)0x2000000002c0,
         "\xd2\xff\x03\x07\x60\x03\x00\x8c\xb8\x9e\x08\xf0\x88\xa8", 14);
  *(uint64_t*)0x200000000418 = 0;
  *(uint32_t*)0x200000000420 = 0xd5b1;
  *(uint32_t*)0x200000000424 = 0x60000000;
  *(uint32_t*)0x200000000428 = 0;
  *(uint32_t*)0x20000000042c = 0;
  *(uint64_t*)0x200000000430 = 0;
  *(uint64_t*)0x200000000438 = 0;
  *(uint32_t*)0x200000000440 = 0;
  *(uint32_t*)0x200000000444 = 0;
  *(uint32_t*)0x200000000448 = 0;
  syscall(__NR_bpf, /*cmd=*/0xaul, /*arg=*/0x200000000400ul, /*size=*/0x50ul);
  return 0;
}