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

int main(void)
{
  syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x32ul, -1, 0);
  intptr_t res = 0;
  res = syscall(__NR_socket, 0x10ul, 3ul, 0xcul);
  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 = 0x64;
  *(uint8_t*)0x20000004 = 2;
  *(uint8_t*)0x20000005 = 6;
  *(uint16_t*)0x20000006 = 1;
  *(uint32_t*)0x20000008 = 0;
  *(uint32_t*)0x2000000c = 0;
  *(uint8_t*)0x20000010 = 0;
  *(uint8_t*)0x20000011 = 0;
  *(uint16_t*)0x20000012 = htobe16(0);
  *(uint16_t*)0x20000014 = 0xe;
  *(uint16_t*)0x20000016 = 3;
  memcpy((void*)0x20000018, "bitmap:ip\000", 10);
  *(uint16_t*)0x20000024 = 9;
  *(uint16_t*)0x20000026 = 2;
  memcpy((void*)0x20000028, "syz1\000", 5);
  *(uint16_t*)0x20000030 = 0x1c;
  STORE_BY_BITMASK(uint16_t, , 0x20000032, 7, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x20000033, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x20000033, 1, 7, 1);
  *(uint16_t*)0x20000034 = 0xc;
  STORE_BY_BITMASK(uint16_t, , 0x20000036, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x20000037, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x20000037, 1, 7, 1);
  *(uint16_t*)0x20000038 = 8;
  STORE_BY_BITMASK(uint16_t, , 0x2000003a, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x2000003b, 1, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x2000003b, 0, 7, 1);
  *(uint32_t*)0x2000003c = htobe32(0);
  *(uint16_t*)0x20000040 = 0xc;
  STORE_BY_BITMASK(uint16_t, , 0x20000042, 2, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x20000043, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x20000043, 1, 7, 1);
  *(uint16_t*)0x20000044 = 8;
  STORE_BY_BITMASK(uint16_t, , 0x20000046, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x20000047, 1, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x20000047, 0, 7, 1);
  *(uint32_t*)0x20000048 = htobe32(0);
  *(uint16_t*)0x2000004c = 5;
  *(uint16_t*)0x2000004e = 1;
  *(uint8_t*)0x20000050 = 7;
  *(uint16_t*)0x20000054 = 5;
  *(uint16_t*)0x20000056 = 4;
  *(uint8_t*)0x20000058 = 0;
  *(uint16_t*)0x2000005c = 5;
  *(uint16_t*)0x2000005e = 5;
  *(uint8_t*)0x20000060 = 2;
  *(uint64_t*)0x200002c8 = 0x64;
  *(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, 0xcul);
  if (res != -1)
    r[1] = res;
  *(uint64_t*)0x200000c0 = 0;
  *(uint32_t*)0x200000c8 = 0;
  *(uint64_t*)0x200000d0 = 0x20000080;
  *(uint64_t*)0x20000080 = 0x20000040;
  *(uint32_t*)0x20000040 = 0x28;
  *(uint8_t*)0x20000044 = 8;
  *(uint8_t*)0x20000045 = 6;
  *(uint16_t*)0x20000046 = 0x101;
  *(uint32_t*)0x20000048 = 0;
  *(uint32_t*)0x2000004c = 0;
  *(uint8_t*)0x20000050 = 0xa;
  *(uint8_t*)0x20000051 = 0;
  *(uint16_t*)0x20000052 = htobe16(0);
  *(uint16_t*)0x20000054 = 5;
  *(uint16_t*)0x20000056 = 1;
  *(uint8_t*)0x20000058 = 7;
  *(uint16_t*)0x2000005c = 9;
  *(uint16_t*)0x2000005e = 2;
  memcpy((void*)0x20000060, "syz1\000", 5);
  *(uint64_t*)0x20000088 = 0x28;
  *(uint64_t*)0x200000d8 = 1;
  *(uint64_t*)0x200000e0 = 0;
  *(uint64_t*)0x200000e8 = 0;
  *(uint32_t*)0x200000f0 = 0x5c6e364;
  syscall(__NR_sendmsg, r[1], 0x200000c0ul, 0x80ul);
  return 0;
}