// https://syzkaller.appspot.com/bug?id=583b200c0464331b3f9cf1d67566de0834f916d6
// 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=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
          /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  intptr_t res = 0;
  *(uint32_t*)0x20000000 = 5;
  *(uint32_t*)0x20000004 = 3;
  *(uint32_t*)0x20000008 = 0x3800;
  *(uint32_t*)0x2000000c = 0xff;
  *(uint32_t*)0x20000010 = 0x11;
  *(uint32_t*)0x20000014 = -1;
  *(uint32_t*)0x20000018 = 0;
  memset((void*)0x2000001c, 0, 16);
  *(uint32_t*)0x2000002c = 0;
  *(uint32_t*)0x20000030 = -1;
  *(uint32_t*)0x20000034 = 0;
  *(uint32_t*)0x20000038 = 0;
  *(uint32_t*)0x2000003c = 0;
  *(uint64_t*)0x20000040 = 0;
  res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x20000000ul, /*size=*/0x48ul);
  if (res != -1)
    r[0] = res;
  *(uint32_t*)0x20000440 = 5;
  *(uint32_t*)0x20000444 = 5;
  *(uint64_t*)0x20000448 = 0x20000080;
  *(uint8_t*)0x20000080 = 0x18;
  STORE_BY_BITMASK(uint8_t, , 0x20000081, 8, 0, 4);
  STORE_BY_BITMASK(uint8_t, , 0x20000081, 0, 4, 4);
  *(uint16_t*)0x20000082 = 0;
  *(uint32_t*)0x20000084 = 0;
  *(uint8_t*)0x20000088 = 0;
  *(uint8_t*)0x20000089 = 0;
  *(uint16_t*)0x2000008a = 0;
  *(uint32_t*)0x2000008c = 0;
  *(uint8_t*)0x20000090 = 0x18;
  STORE_BY_BITMASK(uint8_t, , 0x20000091, 0, 0, 4);
  STORE_BY_BITMASK(uint8_t, , 0x20000091, 1, 4, 4);
  *(uint16_t*)0x20000092 = 0;
  *(uint32_t*)0x20000094 = r[0];
  *(uint8_t*)0x20000098 = 0;
  *(uint8_t*)0x20000099 = 0;
  *(uint16_t*)0x2000009a = 0;
  *(uint32_t*)0x2000009c = 0;
  *(uint8_t*)0x200000a0 = 0x95;
  *(uint8_t*)0x200000a1 = 0;
  *(uint16_t*)0x200000a2 = 0;
  *(uint32_t*)0x200000a4 = 0;
  *(uint64_t*)0x20000450 = 0x20000040;
  memcpy((void*)0x20000040, "GPL\000", 4);
  *(uint32_t*)0x20000458 = 4;
  *(uint32_t*)0x2000045c = 0xee;
  *(uint64_t*)0x20000460 = 0x20000340;
  *(uint32_t*)0x20000468 = 0;
  *(uint32_t*)0x2000046c = 0;
  memset((void*)0x20000470, 0, 16);
  *(uint32_t*)0x20000480 = 0;
  *(uint32_t*)0x20000484 = 0;
  *(uint32_t*)0x20000488 = -1;
  *(uint32_t*)0x2000048c = 8;
  *(uint64_t*)0x20000490 = 0;
  *(uint32_t*)0x20000498 = 0;
  *(uint32_t*)0x2000049c = 0x10;
  *(uint64_t*)0x200004a0 = 0;
  *(uint32_t*)0x200004a8 = 0;
  *(uint32_t*)0x200004ac = 0;
  *(uint32_t*)0x200004b0 = 0;
  *(uint32_t*)0x200004b4 = 0;
  *(uint64_t*)0x200004b8 = 0;
  *(uint64_t*)0x200004c0 = 0;
  *(uint32_t*)0x200004c8 = 0x10;
  *(uint32_t*)0x200004cc = 0;
  syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x20000440ul, /*size=*/0x80ul);
  return 0;
}