#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ yes;
typedef int uint8_t;
typedef int /*<<< orphan*/ uint64_t;
typedef int uint32_t;
typedef int uint16_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ MSG_NOSIGNAL;
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ _SC_PAGESIZE;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, int);
int *malloc(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ recv(int, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main() {
  int fd, sock_server, sock_client;
  struct sockaddr_in addr;
  int i, j, counter, position, size, yes = 1;
  uint32_t command, code, data, period, pulses, shdelay, shtime;
  uint32_t *coordinates;
  uint64_t buffer[1024], tmp;
  volatile void *cfg, *sts;
  volatile uint8_t *rst;
  volatile uint16_t *rd_cntr, *wr_cntr;
  volatile uint32_t *dac;
  volatile uint64_t *adc;
  size = 0;
  coordinates = malloc(4194304);
  if ((fd = open("/dev/mem", O_RDWR)) < 0) {
    perror("open");
    return EXIT_FAILURE;
  }
  cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40000000);
  sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40001000);
  dac = mmap(NULL, 16 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
             MAP_SHARED, fd, 0x40010000);
  adc = mmap(NULL, 32 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
             MAP_SHARED, fd, 0x40020000);
  wr_cntr = (uint16_t *)(sts + 0);
  rd_cntr = (uint16_t *)(sts + 2);
  rst = (uint8_t *)(cfg + 0);
  *rst &= ~1;
  *(uint8_t *)(cfg + 1) = 1;
  *(uint8_t *)(cfg + 2) = 1;
  *(uint8_t *)(cfg + 3) = 1;
  *(uint8_t *)(cfg + 4) = 32 - 1;
  pulses = 2;
  *(uint8_t *)(cfg + 5) = pulses - 1;
  period = 25000;
  *(uint32_t *)(cfg + 8) = 0;
  *(uint32_t *)(cfg + 12) = 200;
  *(uint32_t *)(cfg + 16) = period - 1;
  shdelay = 400;
  *(uint32_t *)(cfg + 20) = shdelay;
  shtime = 30;
  *(uint32_t *)(cfg + 24) = shdelay + shtime;
  *(uint32_t *)(cfg + 28) = period - 1;
  *(uint32_t *)(cfg + 32) = 2000;
  *(uint32_t *)(cfg + 36) = 2001;
  *(uint32_t *)(cfg + 40) = 2001;
  if ((sock_server = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    return EXIT_FAILURE;
  }
  setsockopt(sock_server, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes));
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addr.sin_port = htons(1001);
  if (bind(sock_server, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("bind");
    return EXIT_FAILURE;
  }
  listen(sock_server, 1024);
  while (1) {
    if ((sock_client = accept(sock_server, NULL, NULL)) < 0) {
      perror("accept");
      return EXIT_FAILURE;
    }
    while (1) {
      if (recv(sock_client, &command, 4, MSG_WAITALL) <= 0)
        break;
      code = command >> 28;
      data = command & 0xfffffff;
      switch (code) {
      case 0:
        period = data;
        *(uint32_t *)(cfg + 16) = period - 1;
        *(uint32_t *)(cfg + 28) = period - 1;
        break;
      case 1:
        *(uint32_t *)(cfg + 12) = data;
        break;
      case 2:
        if (data == 0)
          *rst &= ~4;
        else if (data == 1)
          *rst |= 4;
        break;
      case 3:
        shdelay = data;
        *(uint32_t *)(cfg + 20) = shdelay;
        *(uint32_t *)(cfg + 24) = shdelay + shtime;
        break;
      case 4:
        shtime = data;
        *(uint32_t *)(cfg + 24) = shdelay + shtime;
        break;
      case 5:
        if (data == 0)
          *rst &= ~8;
        else if (data == 1)
          *rst |= 8;
        break;
      case 6:
        *(uint32_t *)(cfg + 32) = data;
        *(uint32_t *)(cfg + 36) = data + 1;
        *(uint32_t *)(cfg + 40) = data + 1;
        break;
      case 7:
        *(uint8_t *)(cfg + 4) = data - 1;
        break;
      case 8:
        pulses = data;
        *(uint8_t *)(cfg + 5) = pulses - 1;
        break;
      case 9:
        size = 0;
        break;
      case 10:
        if (size >= 1048576)
          continue;
        coordinates[size] = (data & 0xfffc000) << 2 | (data & 0x3fff);
        ++size;
        break;
      case 11:
        *rst |= 1;
        break;
      case 12:
        counter = 0;
        position = 0;
        *rst &= ~1;
        *rst |= 2;
        *rst &= ~2;
        for (i = 0; i < size; ++i) {
          if (*rd_cntr >= 2048 && counter < size) {
            for (j = 0; j < 1024; ++j)
              buffer[j] = *adc;
            if (send(sock_client, buffer, 8192, MSG_NOSIGNAL) < 0)
              break;
            counter += 1024;
          }
          while (*wr_cntr < 16384 - pulses && position < size) {
            for (j = 0; j < pulses; ++j)
              *dac = coordinates[position];
            ++position;
          }
          *rst |= 1;
          if (*rd_cntr < 2048)
            usleep(500);
        }
        while (counter < size) {
          if (*(uint16_t *)(sts + 2) >= 2048) {
            for (j = 0; j < 1024; ++j)
              buffer[j] = *adc;
            if (send(sock_client, buffer, 8192, MSG_NOSIGNAL) < 0)
              break;
            counter += 1024;
          }
          if (*rd_cntr < 2048)
            usleep(500);
        }
        break;
      }
    }
    *rst &= ~1;
    close(sock_client);
  }
  close(sock_server);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x400000,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
lea    0xde6(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    127c <main+0x6c>
lea    0xdd7(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1a7d <main+0x86d>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
mov    %eax,%esi
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
mov    0x2cfc(%rip),%rax
or     (%rax),%edx
mov    0x2d43(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40000000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x1070(%rbp)
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
mov    %eax,%esi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
mov    0x2cb7(%rip),%rax
or     (%rax),%edx
mov    0x2cfe(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40001000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x1078(%rbp)
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
mov    %eax,%esi
shl    $0x4,%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
mov    0x2c6f(%rip),%rax
or     (%rax),%edx
mov    0x2cb6(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40010000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x1098(%rbp)
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
mov    %eax,%esi
shl    $0x5,%esi
mov    0x2c90(%rip),%rax
mov    (%rax),%edx
mov    0x2c27(%rip),%rax
or     (%rax),%edx
mov    0x2c6e(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40020000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x10a0(%rbp)
mov    -0x1078(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x1078(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x1088(%rbp)
mov    -0x1070(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x1,0x1(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x1,0x2(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x1,0x3(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x1f,0x4(%rax)
movl   $0x2,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x5(%rax)
movl   $0x61a8,-0x48(%rbp)
mov    -0x1070(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x1070(%rbp),%rax
movl   $0xc8,0xc(%rax)
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x10(%rax)
movl   $0x190,-0x50(%rbp)
mov    -0x50(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x14(%rax)
movl   $0x1e,-0x54(%rbp)
mov    -0x50(%rbp),%ecx
add    -0x54(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x7d0,0x20(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x7d1,0x24(%rax)
mov    -0x1070(%rbp),%rax
movl   $0x7d1,0x28(%rax)
mov    0x2b08(%rip),%rax
mov    (%rax),%edi
mov    0x2adf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    14fb <main+0x2eb>
lea    0xb5d(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2aaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1a7d <main+0x86d>
mov    -0xc(%rbp),%edi
mov    0x2acb(%rip),%rax
mov    (%rax),%esi
mov    0x2a7a(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2a92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x3e9,%edi
call   1060 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    1591 <main+0x381>
lea    0xace(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2a19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1a7d <main+0x86d>
mov    -0xc(%rbp),%edi
mov    $0x400,%esi
call   10c0 <listen@plt>
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1110 <accept@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    15d6 <main+0x3c6>
lea    0xa8e(%rip),%rdi
call   10f0 <perror@plt>
mov    0x29d4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1a7d <main+0x86d>
jmp    15db <main+0x3cb>
mov    -0x10(%rbp),%edi
mov    0x2993(%rip),%rax
mov    (%rax),%ecx
lea    -0x3c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     1604 <main+0x3f4>
jmp    1a62 <main+0x852>
mov    -0x3c(%rbp),%eax
sar    $0x1c,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
and    $0xfffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
mov    %rax,-0x10a8(%rbp)
sub    $0xc,%rax
ja     1a5d <main+0x84d>
mov    -0x10a8(%rbp),%rax
lea    0x9c6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0xc(%rax)
jmp    1a5d <main+0x84d>
cmpl   $0x0,-0x44(%rbp)
jne    169d <main+0x48d>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffb,%ecx
mov    %ecx,(%rax)
jmp    16ba <main+0x4aa>
cmpl   $0x1,-0x44(%rbp)
jne    16b5 <main+0x4a5>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x4,%ecx
mov    %ecx,(%rax)
jmp    16ba <main+0x4aa>
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x50(%rbp),%ecx
add    -0x54(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%ecx
add    -0x54(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
jmp    1a5d <main+0x84d>
cmpl   $0x0,-0x44(%rbp)
jne    171f <main+0x50f>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffff7,%ecx
mov    %ecx,(%rax)
jmp    173c <main+0x52c>
cmpl   $0x1,-0x44(%rbp)
jne    1737 <main+0x527>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x8,%ecx
mov    %ecx,(%rax)
jmp    173c <main+0x52c>
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x28(%rax)
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    1a5d <main+0x84d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x5(%rax)
jmp    1a5d <main+0x84d>
movl   $0x0,-0x34(%rbp)
jmp    1a5d <main+0x84d>
cmpl   $0x100000,-0x34(%rbp)
jl     17c1 <main+0x5b1>
jmp    15db <main+0x3cb>
mov    -0x44(%rbp),%edx
and    $0xfffc000,%edx
shl    $0x2,%edx
mov    -0x44(%rbp),%eax
and    $0x3fff,%eax
or     %eax,%edx
mov    -0x60(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1a5d <main+0x84d>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
jmp    1a5d <main+0x84d>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    19a4 <main+0x794>
mov    -0x1088(%rbp),%rax
mov    (%rax),%eax
cmp    $0x800,%eax
jl     18da <main+0x6ca>
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    18da <main+0x6ca>
movl   $0x0,-0x28(%rbp)
cmpl   $0x400,-0x28(%rbp)
jge    18a4 <main+0x694>
mov    -0x10a0(%rbp),%rax
mov    (%rax),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x1060(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1875 <main+0x665>
mov    -0x10(%rbp),%edi
lea    -0x1060(%rbp),%rsi
mov    0x26db(%rip),%rax
mov    (%rax),%ecx
mov    $0x2000,%edx
call   1070 <send@plt>
cmp    $0x0,%eax
jge    18cf <main+0x6bf>
jmp    19a4 <main+0x794>
mov    -0x2c(%rbp),%eax
add    $0x400,%eax
mov    %eax,-0x2c(%rbp)
jmp    18df <main+0x6cf>
mov    -0x1090(%rbp),%rax
mov    (%rax),%ecx
mov    $0x4000,%edx
sub    -0x4c(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x10a9(%rbp)
jge    190f <main+0x6ff>
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
setl   %al
mov    %al,-0x10a9(%rbp)
mov    -0x10a9(%rbp),%al
test   $0x1,%al
jne    1922 <main+0x712>
jmp    1965 <main+0x755>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1957 <main+0x747>
mov    -0x60(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x1098(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1929 <main+0x719>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    18df <main+0x6cf>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x1088(%rbp),%rax
mov    (%rax),%eax
cmp    $0x800,%eax
jge    1991 <main+0x781>
mov    $0x1f4,%edi
call   1120 <usleep@plt>
jmp    1996 <main+0x786>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1842 <main+0x632>
jmp    19a9 <main+0x799>
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1a58 <main+0x848>
mov    -0x1078(%rbp),%rax
cmpl   $0x800,0x2(%rax)
jl     1a35 <main+0x825>
movl   $0x0,-0x28(%rbp)
cmpl   $0x400,-0x28(%rbp)
jge    19ff <main+0x7ef>
mov    -0x10a0(%rbp),%rax
mov    (%rax),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x1060(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    19d0 <main+0x7c0>
mov    -0x10(%rbp),%edi
lea    -0x1060(%rbp),%rsi
mov    0x2580(%rip),%rax
mov    (%rax),%ecx
mov    $0x2000,%edx
call   1070 <send@plt>
cmp    $0x0,%eax
jge    1a2a <main+0x81a>
jmp    1a58 <main+0x848>
mov    -0x2c(%rbp),%eax
add    $0x400,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1088(%rbp),%rax
mov    (%rax),%eax
cmp    $0x800,%eax
jge    1a53 <main+0x843>
mov    $0x1f4,%edi
call   1120 <usleep@plt>
jmp    19a9 <main+0x799>
jmp    1a5d <main+0x84d>
jmp    15db <main+0x3cb>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
jmp    159e <main+0x38e>
mov    -0x4(%rbp),%eax
add    $0x10b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x1,0xc(%rsp)
mov    $0x400000,%edi
call   10a0 <malloc@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
lea    0xe20(%rip),%rdi
call   10d0 <open@plt>
test   %eax,%eax
jns    1235 <main+0x45>
lea    0xe19(%rip),%rdi
jmp    1401 <main+0x211>
mov    %eax,%ebp
mov    0x2d7a(%rip),%r15
mov    (%r15),%edi
call   10f0 <sysconf@plt>
mov    0x2dab(%rip),%r14
mov    0x2d44(%rip),%r12
mov    (%r12),%edx
or     (%r14),%edx
mov    0x2d86(%rip),%r13
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40000000,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    (%r15),%edi
call   10f0 <sysconf@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40001000,%r9d
call   1050 <mmap@plt>
mov    (%r15),%edi
call   10f0 <sysconf@plt>
shl    $0x4,%eax
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40010000,%r9d
call   1050 <mmap@plt>
mov    (%r15),%edi
call   10f0 <sysconf@plt>
shl    $0x5,%eax
mov    (%r12),%edx
or     (%r14),%edx
mov    0x0(%r13),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40020000,%r9d
call   1050 <mmap@plt>
andl   $0xfffffffe,(%rbx)
movl   $0x1,0x1(%rbx)
movl   $0x1,0x2(%rbx)
movl   $0x1,0x3(%rbx)
movl   $0x1f,0x4(%rbx)
movl   $0x1,0x5(%rbx)
movaps 0xce3(%rip),%xmm0
movups %xmm0,0x8(%rbx)
movaps 0xce8(%rip),%xmm0
movups %xmm0,0x18(%rbx)
movl   $0x7d1,0x28(%rbx)
mov    0x2c8e(%rip),%r15
mov    (%r15),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
jns    135d <main+0x16d>
lea    0xcf6(%rip),%rdi
jmp    1401 <main+0x211>
mov    %eax,%ebp
mov    0x2c6a(%rip),%rax
mov    (%rax),%esi
mov    0x2c21(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    0x18(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x20(%rsp)
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x1c(%rsp)
mov    $0x3e9,%edi
call   1060 <htons@plt>
mov    %eax,0x18(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %rax,%rax
jns    13db <main+0x1eb>
lea    0xc7c(%rip),%rdi
jmp    1401 <main+0x211>
mov    %ebp,%edi
mov    $0x400,%esi
call   10b0 <listen@plt>
mov    %ebp,0x4(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
test   %eax,%eax
jns    141e <main+0x22e>
lea    0xc59(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b93(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x1e,%eax
mov    %rax,0x10(%rsp)
mov    $0x190,%r13d
mov    0x2b49(%rip),%r12
lea    0x8(%rsp),%r15
lea    0xbdd(%rip),%r14
jmp    1450 <main+0x260>
add    $0xffffffff,%eax
mov    %eax,0x4(%rbx)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%ecx
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <recv@plt>
test   %rax,%rax
jle    14e1 <main+0x2f1>
mov    0x8(%rsp),%eax
mov    %eax,%ecx
sar    $0x1c,%ecx
cmp    $0x7,%ecx
ja     1450 <main+0x260>
and    $0xfffffff,%eax
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
add    $0xffffffff,%eax
mov    %eax,0x10(%rbx)
mov    %eax,0x1c(%rbx)
jmp    1450 <main+0x260>
mov    %eax,0xc(%rbx)
jmp    1450 <main+0x260>
cmp    $0x1,%eax
je     1507 <main+0x317>
test   %eax,%eax
jne    1450 <main+0x260>
andl   $0xfffffffb,(%rbx)
jmp    1450 <main+0x260>
mov    %eax,0x14(%rbx)
mov    0x10(%rsp),%rcx
add    %eax,%ecx
mov    %ecx,0x18(%rbx)
mov    %eax,%r13d
jmp    1450 <main+0x260>
lea    (%rax,%r13,1),%ecx
mov    %ecx,0x18(%rbx)
mov    %rax,0x10(%rsp)
jmp    1450 <main+0x260>
cmp    $0x1,%eax
je     150f <main+0x31f>
test   %eax,%eax
jne    1450 <main+0x260>
andl   $0xfffffff7,(%rbx)
jmp    1450 <main+0x260>
mov    %eax,0x20(%rbx)
add    $0x1,%eax
mov    %eax,0x24(%rbx)
mov    %eax,0x28(%rbx)
jmp    1450 <main+0x260>
andl   $0xfffffffe,(%rbx)
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1450 <main+0x260>
jmp    13fa <main+0x20a>
orl    $0x4,(%rbx)
jmp    1450 <main+0x260>
orl    $0x8,(%rbx)
jmp    1450 <main+0x260>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [7 x i8] c"accept\00"
@MSG_WAITALL = global i32 0
@MSG_NOSIGNAL = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
%20 = alloca [1024 x i32]
%21 = alloca i32
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %11
store i32 0, i32* %10
%29 = call i32* @malloc(i32 4194304)
store i32* %29, i32** %19
%30 = load i32, i32* @O_RDWR
%31 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %30)
store i32 %31, i32* %2
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %0
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %1
br label %446
36: ; preds = %0
%37 = load i32, i32* @_SC_PAGESIZE
%38 = call i32 @sysconf(i32 %37)
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @PROT_WRITE
%41 = or i32 %39, %40
%42 = load i32, i32* @MAP_SHARED
%43 = load i32, i32* %2
%44 = call i8* @mmap(i32* null, i32 %38, i32 %41, i32 %42, i32 %43, i32 1073741824)
store i8* %44, i8** %22
%45 = load i32, i32* @_SC_PAGESIZE
%46 = call i32 @sysconf(i32 %45)
%47 = load i32, i32* @PROT_READ
%48 = load i32, i32* @PROT_WRITE
%49 = or i32 %47, %48
%50 = load i32, i32* @MAP_SHARED
%51 = load i32, i32* %2
%52 = call i8* @mmap(i32* null, i32 %46, i32 %49, i32 %50, i32 %51, i32 1073745920)
store i8* %52, i8** %23
%53 = load i32, i32* @_SC_PAGESIZE
%54 = call i32 @sysconf(i32 %53)
%55 = mul nsw i32 16, %54
%56 = load i32, i32* @PROT_READ
%57 = load i32, i32* @PROT_WRITE
%58 = or i32 %56, %57
%59 = load i32, i32* @MAP_SHARED
%60 = load i32, i32* %2
%61 = call i8* @mmap(i32* null, i32 %55, i32 %58, i32 %59, i32 %60, i32 1073807360)
%62 = bitcast i8* %61 to i32*
store i32* %62, i32** %27
%63 = load i32, i32* @_SC_PAGESIZE
%64 = call i32 @sysconf(i32 %63)
%65 = mul nsw i32 32, %64
%66 = load i32, i32* @PROT_READ
%67 = load i32, i32* @PROT_WRITE
%68 = or i32 %66, %67
%69 = load i32, i32* @MAP_SHARED
%70 = load i32, i32* %2
%71 = call i8* @mmap(i32* null, i32 %65, i32 %68, i32 %69, i32 %70, i32 1073872896)
%72 = bitcast i8* %71 to i32*
store i32* %72, i32** %28
%73 = load i8*, i8** %23
%74 = getelementptr i8, i8* %73, i64 0
%75 = bitcast i8* %74 to i32*
store i32* %75, i32** %26
%76 = load i8*, i8** %23
%77 = getelementptr i8, i8* %76, i64 2
%78 = bitcast i8* %77 to i32*
store i32* %78, i32** %25
%79 = load i8*, i8** %22
%80 = getelementptr i8, i8* %79, i64 0
%81 = bitcast i8* %80 to i32*
store i32* %81, i32** %24
%82 = load i32*, i32** %24
%83 = load volatile i32, i32* %82
%84 = and i32 %83, -2
store volatile i32 %84, i32* %82
%85 = load i8*, i8** %22
%86 = getelementptr i8, i8* %85, i64 1
%87 = bitcast i8* %86 to i32*
store i32 1, i32* %87
%88 = load i8*, i8** %22
%89 = getelementptr i8, i8* %88, i64 2
%90 = bitcast i8* %89 to i32*
store i32 1, i32* %90
%91 = load i8*, i8** %22
%92 = getelementptr i8, i8* %91, i64 3
%93 = bitcast i8* %92 to i32*
store i32 1, i32* %93
%94 = load i8*, i8** %22
%95 = getelementptr i8, i8* %94, i64 4
%96 = bitcast i8* %95 to i32*
store i32 31, i32* %96
store i32 2, i32* %16
%97 = load i32, i32* %16
%98 = sub nsw i32 %97, 1
%99 = load i8*, i8** %22
%100 = getelementptr i8, i8* %99, i64 5
%101 = bitcast i8* %100 to i32*
store i32 %98, i32* %101
store i32 25000, i32* %15
%102 = load i8*, i8** %22
%103 = getelementptr i8, i8* %102, i64 8
%104 = bitcast i8* %103 to i32*
store i32 0, i32* %104
%105 = load i8*, i8** %22
%106 = getelementptr i8, i8* %105, i64 12
%107 = bitcast i8* %106 to i32*
store i32 200, i32* %107
%108 = load i32, i32* %15
%109 = sub nsw i32 %108, 1
%110 = load i8*, i8** %22
%111 = getelementptr i8, i8* %110, i64 16
%112 = bitcast i8* %111 to i32*
store i32 %109, i32* %112
store i32 400, i32* %17
%113 = load i32, i32* %17
%114 = load i8*, i8** %22
%115 = getelementptr i8, i8* %114, i64 20
%116 = bitcast i8* %115 to i32*
store i32 %113, i32* %116
store i32 30, i32* %18
%117 = load i32, i32* %17
%118 = load i32, i32* %18
%119 = add nsw i32 %117, %118
%120 = load i8*, i8** %22
%121 = getelementptr i8, i8* %120, i64 24
%122 = bitcast i8* %121 to i32*
store i32 %119, i32* %122
%123 = load i32, i32* %15
%124 = sub nsw i32 %123, 1
%125 = load i8*, i8** %22
%126 = getelementptr i8, i8* %125, i64 28
%127 = bitcast i8* %126 to i32*
store i32 %124, i32* %127
%128 = load i8*, i8** %22
%129 = getelementptr i8, i8* %128, i64 32
%130 = bitcast i8* %129 to i32*
store i32 2000, i32* %130
%131 = load i8*, i8** %22
%132 = getelementptr i8, i8* %131, i64 36
%133 = bitcast i8* %132 to i32*
store i32 2001, i32* %133
%134 = load i8*, i8** %22
%135 = getelementptr i8, i8* %134, i64 40
%136 = bitcast i8* %135 to i32*
store i32 2001, i32* %136
%137 = load i32, i32* @AF_INET
%138 = load i32, i32* @SOCK_STREAM
%139 = call i32 @socket(i32 %137, i32 %138, i32 0)
store i32 %139, i32* %3
%140 = icmp slt i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %36
%142 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%143 = load i32, i32* @EXIT_FAILURE
store i32 %143, i32* %1
br label %446
144: ; preds = %36
%145 = load i32, i32* %3
%146 = load i32, i32* @SOL_SOCKET
%147 = load i32, i32* @SO_REUSEADDR
%148 = bitcast i32* %11 to i8*
%149 = call i32 @setsockopt(i32 %145, i32 %146, i32 %147, i8* %148, i32 4)
%150 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%151 = load i32, i32* @AF_INET
%152 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %151, i32* %152
%153 = load i32, i32* @INADDR_ANY
%154 = call i32 @htonl(i32 %153)
%155 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%156 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %155, i32 0, i32 0
store i32 %154, i32* %156
%157 = call i32 @htons(i32 1001)
%158 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %157, i32* %158
%159 = load i32, i32* %3
%160 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%161 = call i64 @bind(i32 %159, %struct.sockaddr* %160, i32 12)
%162 = icmp slt i64 %161, 0
br i1 %162, label %163, label %166
163: ; preds = %144
%164 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%165 = load i32, i32* @EXIT_FAILURE
store i32 %165, i32* %1
br label %446
166: ; preds = %144
%167 = load i32, i32* %3
%168 = call i32 @listen(i32 %167, i32 1024)
br label %169
169: ; preds = %166, %440
%170 = load i32, i32* %3
%171 = call i32 @accept(i32 %170, i32* null, i32* null)
store i32 %171, i32* %4
%172 = icmp slt i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %169
%174 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%175 = load i32, i32* @EXIT_FAILURE
store i32 %175, i32* %1
br label %446
176: ; preds = %169
br label %177
177: ; preds = %176, %290, %439
%178 = load i32, i32* %4
%179 = load i32, i32* @MSG_WAITALL
%180 = call i64 @recv(i32 %178, i32* %12, i32 4, i32 %179)
%181 = icmp sle i64 %180, 0
br i1 %181, label %182, label %183
182: ; preds = %177
br label %440
183: ; preds = %177
%184 = load i32, i32* %12
%185 = ashr i32 %184, 28
store i32 %185, i32* %13
%186 = load i32, i32* %12
%187 = and i32 %186, 268435455
store i32 %187, i32* %14
%188 = load i32, i32* %13
switch i32 %188, label %439 [
i32 0, label %189
i32 1, label %201
i32 2, label %206
i32 3, label %222
i32 4, label %234
i32 5, label %242
i32 6, label %258
i32 7, label %273
i32 8, label %279
i32 9, label %286
i32 10, label %287
i32 11, label %304
i32 12, label %308
]
189: ; preds = %183
%190 = load i32, i32* %14
store i32 %190, i32* %15
%191 = load i32, i32* %15
%192 = sub nsw i32 %191, 1
%193 = load i8*, i8** %22
%194 = getelementptr i8, i8* %193, i64 16
%195 = bitcast i8* %194 to i32*
store i32 %192, i32* %195
%196 = load i32, i32* %15
%197 = sub nsw i32 %196, 1
%198 = load i8*, i8** %22
%199 = getelementptr i8, i8* %198, i64 28
%200 = bitcast i8* %199 to i32*
store i32 %197, i32* %200
br label %439
201: ; preds = %183
%202 = load i32, i32* %14
%203 = load i8*, i8** %22
%204 = getelementptr i8, i8* %203, i64 12
%205 = bitcast i8* %204 to i32*
store i32 %202, i32* %205
br label %439
206: ; preds = %183
%207 = load i32, i32* %14
%208 = icmp eq i32 %207, 0
br i1 %208, label %209, label %213
209: ; preds = %206
%210 = load i32*, i32** %24
%211 = load volatile i32, i32* %210
%212 = and i32 %211, -5
store volatile i32 %212, i32* %210
br label %221
213: ; preds = %206
%214 = load i32, i32* %14
%215 = icmp eq i32 %214, 1
br i1 %215, label %216, label %220
216: ; preds = %213
%217 = load i32*, i32** %24
%218 = load volatile i32, i32* %217
%219 = or i32 %218, 4
store volatile i32 %219, i32* %217
br label %220
220: ; preds = %216, %213
br label %221
221: ; preds = %220, %209
br label %439
222: ; preds = %183
%223 = load i32, i32* %14
store i32 %223, i32* %17
%224 = load i32, i32* %17
%225 = load i8*, i8** %22
%226 = getelementptr i8, i8* %225, i64 20
%227 = bitcast i8* %226 to i32*
store i32 %224, i32* %227
%228 = load i32, i32* %17
%229 = load i32, i32* %18
%230 = add nsw i32 %228, %229
%231 = load i8*, i8** %22
%232 = getelementptr i8, i8* %231, i64 24
%233 = bitcast i8* %232 to i32*
store i32 %230, i32* %233
br label %439
234: ; preds = %183
%235 = load i32, i32* %14
store i32 %235, i32* %18
%236 = load i32, i32* %17
%237 = load i32, i32* %18
%238 = add nsw i32 %236, %237
%239 = load i8*, i8** %22
%240 = getelementptr i8, i8* %239, i64 24
%241 = bitcast i8* %240 to i32*
store i32 %238, i32* %241
br label %439
242: ; preds = %183
%243 = load i32, i32* %14
%244 = icmp eq i32 %243, 0
br i1 %244, label %245, label %249
245: ; preds = %242
%246 = load i32*, i32** %24
%247 = load volatile i32, i32* %246
%248 = and i32 %247, -9
store volatile i32 %248, i32* %246
br label %257
249: ; preds = %242
%250 = load i32, i32* %14
%251 = icmp eq i32 %250, 1
br i1 %251, label %252, label %256
252: ; preds = %249
%253 = load i32*, i32** %24
%254 = load volatile i32, i32* %253
%255 = or i32 %254, 8
store volatile i32 %255, i32* %253
br label %256
256: ; preds = %252, %249
br label %257
257: ; preds = %256, %245
br label %439
258: ; preds = %183
%259 = load i32, i32* %14
%260 = load i8*, i8** %22
%261 = getelementptr i8, i8* %260, i64 32
%262 = bitcast i8* %261 to i32*
store i32 %259, i32* %262
%263 = load i32, i32* %14
%264 = add nsw i32 %263, 1
%265 = load i8*, i8** %22
%266 = getelementptr i8, i8* %265, i64 36
%267 = bitcast i8* %266 to i32*
store i32 %264, i32* %267
%268 = load i32, i32* %14
%269 = add nsw i32 %268, 1
%270 = load i8*, i8** %22
%271 = getelementptr i8, i8* %270, i64 40
%272 = bitcast i8* %271 to i32*
store i32 %269, i32* %272
br label %439
273: ; preds = %183
%274 = load i32, i32* %14
%275 = sub nsw i32 %274, 1
%276 = load i8*, i8** %22
%277 = getelementptr i8, i8* %276, i64 4
%278 = bitcast i8* %277 to i32*
store i32 %275, i32* %278
br label %439
279: ; preds = %183
%280 = load i32, i32* %14
store i32 %280, i32* %16
%281 = load i32, i32* %16
%282 = sub nsw i32 %281, 1
%283 = load i8*, i8** %22
%284 = getelementptr i8, i8* %283, i64 5
%285 = bitcast i8* %284 to i32*
store i32 %282, i32* %285
br label %439
286: ; preds = %183
store i32 0, i32* %10
br label %439
287: ; preds = %183
%288 = load i32, i32* %10
%289 = icmp sge i32 %288, 1048576
br i1 %289, label %290, label %291
290: ; preds = %287
br label %177
291: ; preds = %287
%292 = load i32, i32* %14
%293 = and i32 %292, 268419072
%294 = shl i32 %293, 2
%295 = load i32, i32* %14
%296 = and i32 %295, 16383
%297 = or i32 %294, %296
%298 = load i32*, i32** %19
%299 = load i32, i32* %10
%300 = sext i32 %299 to i64
%301 = getelementptr inbounds i32, i32* %298, i64 %300
store i32 %297, i32* %301
%302 = load i32, i32* %10
%303 = add nsw i32 %302, 1
store i32 %303, i32* %10
br label %439
304: ; preds = %183
%305 = load i32*, i32** %24
%306 = load volatile i32, i32* %305
%307 = or i32 %306, 1
store volatile i32 %307, i32* %305
br label %439
308: ; preds = %183
store i32 0, i32* %8
store i32 0, i32* %9
%309 = load i32*, i32** %24
%310 = load volatile i32, i32* %309
%311 = and i32 %310, -2
store volatile i32 %311, i32* %309
%312 = load i32*, i32** %24
%313 = load volatile i32, i32* %312
%314 = or i32 %313, 2
store volatile i32 %314, i32* %312
%315 = load i32*, i32** %24
%316 = load volatile i32, i32* %315
%317 = and i32 %316, -3
store volatile i32 %317, i32* %315
store i32 0, i32* %6
br label %318
318: ; preds = %394, %308
%319 = load i32, i32* %6
%320 = load i32, i32* %10
%321 = icmp slt i32 %319, %320
br i1 %321, label %322, label %397
322: ; preds = %318
%323 = load i32*, i32** %25
%324 = load volatile i32, i32* %323
%325 = icmp sge i32 %324, 2048
br i1 %325, label %326, label %353
326: ; preds = %322
%327 = load i32, i32* %8
%328 = load i32, i32* %10
%329 = icmp slt i32 %327, %328
br i1 %329, label %330, label %353
330: ; preds = %326
store i32 0, i32* %7
br label %331
331: ; preds = %340, %330
%332 = load i32, i32* %7
%333 = icmp slt i32 %332, 1024
br i1 %333, label %334, label %343
334: ; preds = %331
%335 = load i32*, i32** %28
%336 = load volatile i32, i32* %335
%337 = load i32, i32* %7
%338 = sext i32 %337 to i64
%339 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 %338
store i32 %336, i32* %339
br label %340
340: ; preds = %334
%341 = load i32, i32* %7
%342 = add nsw i32 %341, 1
store i32 %342, i32* %7
br label %331
343: ; preds = %331
%344 = load i32, i32* %4
%345 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 0
%346 = load i32, i32* @MSG_NOSIGNAL
%347 = call i32 @send(i32 %344, i32* %345, i32 8192, i32 %346)
%348 = icmp slt i32 %347, 0
br i1 %348, label %349, label %350
349: ; preds = %343
br label %397
350: ; preds = %343
%351 = load i32, i32* %8
%352 = add nsw i32 %351, 1024
store i32 %352, i32* %8
br label %353
353: ; preds = %350, %326, %322
br label %354
354: ; preds = %381, %353
%355 = load i32*, i32** %26
%356 = load volatile i32, i32* %355
%357 = load i32, i32* %16
%358 = sub nsw i32 16384, %357
%359 = icmp slt i32 %356, %358
br i1 %359, label %360, label %364
360: ; preds = %354
%361 = load i32, i32* %9
%362 = load i32, i32* %10
%363 = icmp slt i32 %361, %362
br label %364
364: ; preds = %360, %354
%365 = phi i1 [ false, %354 ], [ %363, %360 ]
br i1 %365, label %366, label %384
366: ; preds = %364
store i32 0, i32* %7
br label %367
367: ; preds = %378, %366
%368 = load i32, i32* %7
%369 = load i32, i32* %16
%370 = icmp slt i32 %368, %369
br i1 %370, label %371, label %381
371: ; preds = %367
%372 = load i32*, i32** %19
%373 = load i32, i32* %9
%374 = sext i32 %373 to i64
%375 = getelementptr inbounds i32, i32* %372, i64 %374
%376 = load i32, i32* %375
%377 = load i32*, i32** %27
store volatile i32 %376, i32* %377
br label %378
378: ; preds = %371
%379 = load i32, i32* %7
%380 = add nsw i32 %379, 1
store i32 %380, i32* %7
br label %367
381: ; preds = %367
%382 = load i32, i32* %9
%383 = add nsw i32 %382, 1
store i32 %383, i32* %9
br label %354
384: ; preds = %364
%385 = load i32*, i32** %24
%386 = load volatile i32, i32* %385
%387 = or i32 %386, 1
store volatile i32 %387, i32* %385
%388 = load i32*, i32** %25
%389 = load volatile i32, i32* %388
%390 = icmp slt i32 %389, 2048
br i1 %390, label %391, label %393
391: ; preds = %384
%392 = call i32 @usleep(i32 500)
br label %393
393: ; preds = %391, %384
br label %394
394: ; preds = %393
%395 = load i32, i32* %6
%396 = add nsw i32 %395, 1
store i32 %396, i32* %6
br label %318
397: ; preds = %349, %318
br label %398
398: ; preds = %437, %397
%399 = load i32, i32* %8
%400 = load i32, i32* %10
%401 = icmp slt i32 %399, %400
br i1 %401, label %402, label %438
402: ; preds = %398
%403 = load i8*, i8** %23
%404 = getelementptr i8, i8* %403, i64 2
%405 = bitcast i8* %404 to i32*
%406 = load i32, i32* %405
%407 = icmp sge i32 %406, 2048
br i1 %407, label %408, label %431
408: ; preds = %402
store i32 0, i32* %7
br label %409
409: ; preds = %418, %408
%410 = load i32, i32* %7
%411 = icmp slt i32 %410, 1024
br i1 %411, label %412, label %421
412: ; preds = %409
%413 = load i32*, i32** %28
%414 = load volatile i32, i32* %413
%415 = load i32, i32* %7
%416 = sext i32 %415 to i64
%417 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 %416
store i32 %414, i32* %417
br label %418
418: ; preds = %412
%419 = load i32, i32* %7
%420 = add nsw i32 %419, 1
store i32 %420, i32* %7
br label %409
421: ; preds = %409
%422 = load i32, i32* %4
%423 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 0
%424 = load i32, i32* @MSG_NOSIGNAL
%425 = call i32 @send(i32 %422, i32* %423, i32 8192, i32 %424)
%426 = icmp slt i32 %425, 0
br i1 %426, label %427, label %428
427: ; preds = %421
br label %438
428: ; preds = %421
%429 = load i32, i32* %8
%430 = add nsw i32 %429, 1024
store i32 %430, i32* %8
br label %431
431: ; preds = %428, %402
%432 = load i32*, i32** %25
%433 = load volatile i32, i32* %432
%434 = icmp slt i32 %433, 2048
br i1 %434, label %435, label %437
435: ; preds = %431
%436 = call i32 @usleep(i32 500)
br label %437
437: ; preds = %435, %431
br label %398
438: ; preds = %427, %398
br label %439
439: ; preds = %183, %438, %304, %291, %286, %279, %273, %258, %257, %234, %222, %221, %201, %189
br label %177
440: ; preds = %182
%441 = load i32*, i32** %24
%442 = load volatile i32, i32* %441
%443 = and i32 %442, -2
store volatile i32 %443, i32* %441
%444 = load i32, i32* %4
%445 = call i32 @close(i32 %444)
br label %169
446: ; preds = %173, %163, %141, %33
%447 = load i32, i32* %1
ret i32 %447
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [7 x i8] c"accept\00"
@MSG_WAITALL = global i32 0
@MSG_NOSIGNAL = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca i32
%4 = bitcast %struct.sockaddr_in* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @malloc(i32 4194304)
%8 = load i32, i32* @O_RDWR
%9 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %157
13: ; preds = %0
%14 = load i32, i32* @_SC_PAGESIZE
%15 = tail call i32 @sysconf(i32 %14)
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @PROT_WRITE
%18 = or i32 %17, %16
%19 = load i32, i32* @MAP_SHARED
%20 = tail call i8* @mmap(i32* null, i32 %15, i32 %18, i32 %19, i32 %9, i32 1073741824)
%21 = load i32, i32* @_SC_PAGESIZE
%22 = tail call i32 @sysconf(i32 %21)
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %24, %23
%26 = load i32, i32* @MAP_SHARED
%27 = tail call i8* @mmap(i32* null, i32 %22, i32 %25, i32 %26, i32 %9, i32 1073745920)
%28 = load i32, i32* @_SC_PAGESIZE
%29 = tail call i32 @sysconf(i32 %28)
%30 = shl nsw i32 %29, 4
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %32, %31
%34 = load i32, i32* @MAP_SHARED
%35 = tail call i8* @mmap(i32* null, i32 %30, i32 %33, i32 %34, i32 %9, i32 1073807360)
%36 = load i32, i32* @_SC_PAGESIZE
%37 = tail call i32 @sysconf(i32 %36)
%38 = shl nsw i32 %37, 5
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @PROT_WRITE
%41 = or i32 %40, %39
%42 = load i32, i32* @MAP_SHARED
%43 = tail call i8* @mmap(i32* null, i32 %38, i32 %41, i32 %42, i32 %9, i32 1073872896)
%44 = bitcast i8* %20 to i32*
%45 = load volatile i32, i32* %44
%46 = and i32 %45, -2
store volatile i32 %46, i32* %44
%47 = getelementptr i8, i8* %20, i64 1
%48 = bitcast i8* %47 to i32*
store i32 1, i32* %48
%49 = getelementptr i8, i8* %20, i64 2
%50 = bitcast i8* %49 to i32*
store i32 1, i32* %50
%51 = getelementptr i8, i8* %20, i64 3
%52 = bitcast i8* %51 to i32*
store i32 1, i32* %52
%53 = getelementptr i8, i8* %20, i64 4
%54 = bitcast i8* %53 to i32*
store i32 31, i32* %54
%55 = getelementptr i8, i8* %20, i64 5
%56 = bitcast i8* %55 to i32*
store i32 1, i32* %56
%57 = getelementptr i8, i8* %20, i64 8
%58 = getelementptr i8, i8* %20, i64 12
%59 = bitcast i8* %58 to i32*
%60 = getelementptr i8, i8* %20, i64 16
%61 = bitcast i8* %60 to i32*
%62 = getelementptr i8, i8* %20, i64 20
%63 = bitcast i8* %62 to i32*
%64 = bitcast i8* %57 to <4 x i32>*
store <4 x i32> <i32 0, i32 200, i32 24999, i32 400>, <4 x i32>* %64
%65 = getelementptr i8, i8* %20, i64 24
%66 = bitcast i8* %65 to i32*
%67 = getelementptr i8, i8* %20, i64 28
%68 = bitcast i8* %67 to i32*
%69 = getelementptr i8, i8* %20, i64 32
%70 = bitcast i8* %69 to i32*
%71 = getelementptr i8, i8* %20, i64 36
%72 = bitcast i8* %71 to i32*
%73 = bitcast i8* %65 to <4 x i32>*
store <4 x i32> <i32 430, i32 24999, i32 2000, i32 2001>, <4 x i32>* %73
%74 = getelementptr i8, i8* %20, i64 40
%75 = bitcast i8* %74 to i32*
store i32 2001, i32* %75
%76 = load i32, i32* @AF_INET
%77 = load i32, i32* @SOCK_STREAM
%78 = tail call i32 @socket(i32 %76, i32 %77, i32 0)
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %13
%81 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %157
82: ; preds = %13
%83 = load i32, i32* @SOL_SOCKET
%84 = load i32, i32* @SO_REUSEADDR
%85 = call i32 @setsockopt(i32 %78, i32 %83, i32 %84, i8* %5, i32 4)
%86 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%87 = load i32, i32* @AF_INET
%88 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %87, i32* %88
%89 = load i32, i32* @INADDR_ANY
%90 = call i32 @htonl(i32 %89)
%91 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %90, i32* %91
%92 = call i32 @htons(i32 1001)
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %92, i32* %93
%94 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%95 = call i64 @bind(i32 %78, %struct.sockaddr* %94, i32 12)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %82
%98 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %157
99: ; preds = %82
%100 = call i32 @listen(i32 %78, i32 1024)
%101 = call i32 @accept(i32 %78, i32* null, i32* null)
%102 = icmp slt i32 %101, 0
br i1 %102, label %110, label %103
103: ; preds = %99, %149
%104 = phi i32 [ %155, %149 ], [ %101, %99 ]
%105 = phi i32 [ %151, %149 ], [ 400, %99 ]
%106 = phi i32 [ %150, %149 ], [ 30, %99 ]
%107 = load i32, i32* @MSG_WAITALL
%108 = call i64 @recv(i32 %104, i32* %3, i32 4, i32 %107)
%109 = icmp slt i64 %108, 1
br i1 %109, label %149, label %112
110: ; preds = %149, %99
%111 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %157
112: ; preds = %103, %143
%113 = phi i32 [ %145, %143 ], [ %105, %103 ]
%114 = phi i32 [ %144, %143 ], [ %106, %103 ]
%115 = load i32, i32* %3
%116 = ashr i32 %115, 28
%117 = and i32 %115, 268435455
switch i32 %116, label %143 [
i32 0, label %118
i32 1, label %120
i32 2, label %121
i32 3, label %128
i32 4, label %130
i32 5, label %132
i32 6, label %139
i32 7, label %141
]
118: ; preds = %112
%119 = add nsw i32 %117, -1
store i32 %119, i32* %61
store i32 %119, i32* %68
br label %143
120: ; preds = %112
store i32 %117, i32* %59
br label %143
121: ; preds = %112
switch i32 %117, label %143 [
i32 0, label %122
i32 1, label %125
]
122: ; preds = %121
%123 = load volatile i32, i32* %44
%124 = and i32 %123, -5
store volatile i32 %124, i32* %44
br label %143
125: ; preds = %121
%126 = load volatile i32, i32* %44
%127 = or i32 %126, 4
store volatile i32 %127, i32* %44
br label %143
128: ; preds = %112
store i32 %117, i32* %63
%129 = add nsw i32 %117, %114
store i32 %129, i32* %66
br label %143
130: ; preds = %112
%131 = add nsw i32 %117, %113
store i32 %131, i32* %66
br label %143
132: ; preds = %112
switch i32 %117, label %143 [
i32 0, label %133
i32 1, label %136
]
133: ; preds = %132
%134 = load volatile i32, i32* %44
%135 = and i32 %134, -9
store volatile i32 %135, i32* %44
br label %143
136: ; preds = %132
%137 = load volatile i32, i32* %44
%138 = or i32 %137, 8
store volatile i32 %138, i32* %44
br label %143
139: ; preds = %112
store i32 %117, i32* %70
%140 = add nuw nsw i32 %117, 1
store i32 %140, i32* %72
store i32 %140, i32* %75
br label %143
141: ; preds = %112
%142 = add nsw i32 %117, -1
store i32 %142, i32* %54
br label %143
143: ; preds = %132, %121, %133, %136, %122, %125, %112, %141, %139, %130, %128, %120, %118
%144 = phi i32 [ %114, %112 ], [ %114, %141 ], [ %114, %139 ], [ %114, %133 ], [ %114, %136 ], [ %117, %130 ], [ %114, %128 ], [ %114, %122 ], [ %114, %125 ], [ %114, %120 ], [ %114, %118 ], [ %114, %121 ], [ %114, %132 ]
%145 = phi i32 [ %113, %112 ], [ %113, %141 ], [ %113, %139 ], [ %113, %133 ], [ %113, %136 ], [ %113, %130 ], [ %117, %128 ], [ %113, %122 ], [ %113, %125 ], [ %113, %120 ], [ %113, %118 ], [ %113, %121 ], [ %113, %132 ]
%146 = load i32, i32* @MSG_WAITALL
%147 = call i64 @recv(i32 %104, i32* %3, i32 4, i32 %146)
%148 = icmp slt i64 %147, 1
br i1 %148, label %149, label %112
149: ; preds = %143, %103
%150 = phi i32 [ %106, %103 ], [ %144, %143 ]
%151 = phi i32 [ %105, %103 ], [ %145, %143 ]
%152 = load volatile i32, i32* %44
%153 = and i32 %152, -2
store volatile i32 %153, i32* %44
%154 = call i32 @close(i32 %104)
%155 = call i32 @accept(i32 %78, i32* null, i32* null)
%156 = icmp slt i32 %155, 0
br i1 %156, label %110, label %103
157: ; preds = %110, %97, %80, %11
%158 = load i32, i32* @EXIT_FAILURE
ret i32 %158
}