// https://syzkaller.appspot.com/bug?id=9c57d3996565d35691fa44b2daf987259838ccce
// 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_bind
#define __NR_bind 361
#endif
#ifndef __NR_connect
#define __NR_connect 362
#endif
#ifndef __NR_ftruncate
#define __NR_ftruncate 93
#endif
#ifndef __NR_memfd_create
#define __NR_memfd_create 356
#endif
#ifndef __NR_mmap
#define __NR_mmap 192
#endif
#ifndef __NR_sendfile
#define __NR_sendfile 187
#endif
#ifndef __NR_setsockopt
#define __NR_setsockopt 366
#endif
#ifndef __NR_socket
#define __NR_socket 359
#endif
#undef __NR_mmap
#define __NR_mmap __NR_mmap2

uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff};

int main(void)
{
  syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
  long res = 0;
  res = syscall(__NR_socket, 2, 2, 0);
  if (res != -1)
    r[0] = res;
  memcpy((void*)0x200000c0,
         "\x23\x7d\x00\xd3\xfc\x1e\xe4\x67\x1f\xba\xa0\xa4\x55\xe7\x3e\x67\x8b"
         "\x8e\x96\xf7\xfd\x82\x9d\x4d\x39\xf1\x82\x8e\xbf\x76\x5e\x22\x09\x13"
         "\xb7\x3d\xb9\x4f\x6d\x49\x50\x77\xa6\xdf\x5a\xb8\x2b\x4c\x4f\x8d",
         50);
  res = syscall(__NR_memfd_create, 0x200000c0, 0);
  if (res != -1)
    r[1] = res;
  *(uint32_t*)0x20000000 = 3;
  syscall(__NR_setsockopt, (long)r[0], 0, 0xa, 0x20000000, 4);
  syscall(__NR_ftruncate, (long)r[1], 0x40001);
  *(uint16_t*)0x200001c0 = 2;
  *(uint16_t*)0x200001c2 = htobe16(0);
  *(uint32_t*)0x200001c4 = htobe32(0x7f000001);
  *(uint8_t*)0x200001c8 = 0;
  *(uint8_t*)0x200001c9 = 0;
  *(uint8_t*)0x200001ca = 0;
  *(uint8_t*)0x200001cb = 0;
  *(uint8_t*)0x200001cc = 0;
  *(uint8_t*)0x200001cd = 0;
  *(uint8_t*)0x200001ce = 0;
  *(uint8_t*)0x200001cf = 0;
  syscall(__NR_connect, (long)r[0], 0x200001c0, 0x10);
  res = syscall(__NR_socket, 0x10, 3, 0xc);
  if (res != -1)
    r[2] = res;
  *(uint16_t*)0x20000080 = 0x10;
  *(uint16_t*)0x20000082 = 0;
  *(uint32_t*)0x20000084 = 0;
  *(uint32_t*)0x20000088 = 0xdbcbddc1;
  syscall(__NR_bind, (long)r[2], 0x20000080, 0xc);
  *(uint32_t*)0x20000080 = 0;
  syscall(__NR_sendfile, (long)r[0], (long)r[1], 0x20000080, 0xffe4);
  return 0;
}