// https://syzkaller.appspot.com/bug?id=b5d5699104873aa56af2793af60be57fe001c5e0
// 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 = 0x20000080;
  *(uint32_t*)0x20000080 = 0x68;
  *(uint8_t*)0x20000084 = 2;
  *(uint8_t*)0x20000085 = 6;
  *(uint16_t*)0x20000086 = 1;
  *(uint32_t*)0x20000088 = 0;
  *(uint32_t*)0x2000008c = 0;
  *(uint8_t*)0x20000090 = 0;
  *(uint8_t*)0x20000091 = 0;
  *(uint16_t*)0x20000092 = htobe16(0);
  *(uint16_t*)0x20000094 = 0x12;
  *(uint16_t*)0x20000096 = 3;
  memcpy((void*)0x20000098, "bitmap:ip,mac\000", 14);
  *(uint16_t*)0x200000a8 = 9;
  *(uint16_t*)0x200000aa = 2;
  memcpy((void*)0x200000ac, "syz0\000", 5);
  *(uint16_t*)0x200000b4 = 0x1c;
  STORE_BY_BITMASK(uint16_t, , 0x200000b6, 7, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x200000b7, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x200000b7, 1, 7, 1);
  *(uint16_t*)0x200000b8 = 0xc;
  STORE_BY_BITMASK(uint16_t, , 0x200000ba, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x200000bb, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x200000bb, 1, 7, 1);
  *(uint16_t*)0x200000bc = 8;
  STORE_BY_BITMASK(uint16_t, , 0x200000be, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x200000bf, 1, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x200000bf, 0, 7, 1);
  *(uint32_t*)0x200000c0 = htobe32(0);
  *(uint16_t*)0x200000c4 = 0xc;
  STORE_BY_BITMASK(uint16_t, , 0x200000c6, 2, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x200000c7, 0, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x200000c7, 1, 7, 1);
  *(uint16_t*)0x200000c8 = 8;
  STORE_BY_BITMASK(uint16_t, , 0x200000ca, 1, 0, 14);
  STORE_BY_BITMASK(uint16_t, , 0x200000cb, 1, 6, 1);
  STORE_BY_BITMASK(uint16_t, , 0x200000cb, 0, 7, 1);
  *(uint32_t*)0x200000cc = htobe32(0);
  *(uint16_t*)0x200000d0 = 5;
  *(uint16_t*)0x200000d2 = 1;
  *(uint8_t*)0x200000d4 = 7;
  *(uint16_t*)0x200000d8 = 5;
  *(uint16_t*)0x200000da = 4;
  *(uint8_t*)0x200000dc = 0;
  *(uint16_t*)0x200000e0 = 5;
  *(uint16_t*)0x200000e2 = 5;
  *(uint8_t*)0x200000e4 = 2;
  *(uint64_t*)0x200002c8 = 0x68;
  *(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*)0x20000680 = 0;
  *(uint32_t*)0x20000688 = 0;
  *(uint64_t*)0x20000690 = 0x20000640;
  *(uint64_t*)0x20000640 = 0x20000600;
  *(uint32_t*)0x20000600 = 0x1c;
  *(uint8_t*)0x20000604 = 8;
  *(uint8_t*)0x20000605 = 6;
  *(uint16_t*)0x20000606 = 0x801;
  *(uint32_t*)0x20000608 = 0;
  *(uint32_t*)0x2000060c = 0;
  *(uint8_t*)0x20000610 = 2;
  *(uint8_t*)0x20000611 = 0;
  *(uint16_t*)0x20000612 = htobe16(4);
  *(uint16_t*)0x20000614 = 5;
  *(uint16_t*)0x20000616 = 1;
  *(uint8_t*)0x20000618 = 7;
  *(uint64_t*)0x20000648 = 0x1c;
  *(uint64_t*)0x20000698 = 1;
  *(uint64_t*)0x200006a0 = 0;
  *(uint64_t*)0x200006a8 = 0;
  *(uint32_t*)0x200006b0 = 0x8000;
  syscall(__NR_sendmsg, r[1], 0x20000680ul, 0x40ul);
  return 0;
}