#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, n, 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;
        n = 1024;
        *rst &= ~1;
        *rst |= 2;
        *rst &= ~2;
        while (counter < size) {
          if (n > size - counter)
            n = size - counter;
          if (*rd_cntr < n * 2)
            usleep(500);
          if (*rd_cntr >= n * 2 && counter < size) {
            for (j = 0; j < n; ++j)
              buffer[j] = *adc;
            if (send(sock_client, buffer, n * 8, MSG_NOSIGNAL) < 0)
              break;
            counter += n;
          }
          while (*wr_cntr < 16384 - pulses && position < size) {
            for (j = 0; j < pulses; ++j)
              *dac = coordinates[position];
            ++position;
          }
          *rst |= 1;
        }
        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,-0x3c(%rbp)
movl   $0x0,-0x38(%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    19d9 <main+0x7c9>
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,-0x50(%rbp)
mov    -0x50(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x5(%rax)
movl   $0x61a8,-0x4c(%rbp)
mov    -0x1070(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x1070(%rbp),%rax
movl   $0xc8,0xc(%rax)
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x10(%rax)
movl   $0x190,-0x54(%rbp)
mov    -0x54(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x14(%rax)
movl   $0x1e,-0x58(%rbp)
mov    -0x54(%rbp),%ecx
add    -0x58(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x4c(%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    19d9 <main+0x7c9>
mov    -0xc(%rbp),%edi
mov    0x2acb(%rip),%rax
mov    (%rax),%esi
mov    0x2a7a(%rip),%rax
mov    (%rax),%edx
lea    -0x3c(%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    19d9 <main+0x7c9>
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    19d9 <main+0x7c9>
jmp    15db <main+0x3cb>
mov    -0x10(%rbp),%edi
mov    0x2993(%rip),%rax
mov    (%rax),%ecx
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     1604 <main+0x3f4>
jmp    19be <main+0x7ae>
mov    -0x40(%rbp),%eax
sar    $0x1c,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
and    $0xfffffff,%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    %rax,-0x10a8(%rbp)
sub    $0xc,%rax
ja     19b9 <main+0x7a9>
mov    -0x10a8(%rbp),%rax
lea    0x9c6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x1c(%rax)
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0xc(%rax)
jmp    19b9 <main+0x7a9>
cmpl   $0x0,-0x48(%rbp)
jne    169d <main+0x48d>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffb,%ecx
mov    %ecx,(%rax)
jmp    16ba <main+0x4aa>
cmpl   $0x1,-0x48(%rbp)
jne    16b5 <main+0x4a5>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x4,%ecx
mov    %ecx,(%rax)
jmp    16ba <main+0x4aa>
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x54(%rbp),%ecx
add    -0x58(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%ecx
add    -0x58(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x18(%rax)
jmp    19b9 <main+0x7a9>
cmpl   $0x0,-0x48(%rbp)
jne    171f <main+0x50f>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffff7,%ecx
mov    %ecx,(%rax)
jmp    173c <main+0x52c>
cmpl   $0x1,-0x48(%rbp)
jne    1737 <main+0x527>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x8,%ecx
mov    %ecx,(%rax)
jmp    173c <main+0x52c>
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x48(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x28(%rax)
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    19b9 <main+0x7a9>
mov    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1070(%rbp),%rax
mov    %ecx,0x5(%rax)
jmp    19b9 <main+0x7a9>
movl   $0x0,-0x38(%rbp)
jmp    19b9 <main+0x7a9>
cmpl   $0x100000,-0x38(%rbp)
jl     17c1 <main+0x5b1>
jmp    15db <main+0x3cb>
mov    -0x48(%rbp),%edx
and    $0xfffc000,%edx
shl    $0x2,%edx
mov    -0x48(%rbp),%eax
and    $0x3fff,%eax
or     %eax,%edx
mov    -0x60(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    19b9 <main+0x7a9>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
jmp    19b9 <main+0x7a9>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x400,-0x2c(%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)
mov    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    19b4 <main+0x7a4>
mov    -0x2c(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    -0x30(%rbp),%ecx
cmp    %ecx,%eax
jle    1868 <main+0x658>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1088(%rbp),%rax
mov    (%rax),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1889 <main+0x679>
mov    $0x1f4,%edi
call   1120 <usleep@plt>
mov    -0x1088(%rbp),%rax
mov    (%rax),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jl     1916 <main+0x706>
mov    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1916 <main+0x706>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    18e1 <main+0x6d1>
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    18b3 <main+0x6a3>
mov    -0x10(%rbp),%edi
lea    -0x1060(%rbp),%rsi
mov    -0x2c(%rbp),%edx
shl    $0x3,%edx
mov    0x2698(%rip),%rax
mov    (%rax),%ecx
call   1070 <send@plt>
cmp    $0x0,%eax
jge    190d <main+0x6fd>
jmp    19b4 <main+0x7a4>
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    191b <main+0x70b>
mov    -0x1090(%rbp),%rax
mov    (%rax),%ecx
mov    $0x4000,%edx
sub    -0x50(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x10a9(%rbp)
jge    194b <main+0x73b>
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
setl   %al
mov    %al,-0x10a9(%rbp)
mov    -0x10a9(%rbp),%al
test   $0x1,%al
jne    195e <main+0x74e>
jmp    19a1 <main+0x791>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1993 <main+0x783>
mov    -0x60(%rbp),%rax
movslq -0x34(%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    1965 <main+0x755>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    191b <main+0x70b>
mov    -0x1080(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
jmp    1842 <main+0x632>
jmp    19b9 <main+0x7a9>
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 i32*
%21 = alloca [1024 x i32]
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32*
%29 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %12
store i32 0, i32* %11
%30 = call i32* @malloc(i32 4194304)
store i32* %30, i32** %20
%31 = load i32, i32* @O_RDWR
%32 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %31)
store i32 %32, i32* %2
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %0
%35 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %1
br label %421
37: ; preds = %0
%38 = load i32, i32* @_SC_PAGESIZE
%39 = call i32 @sysconf(i32 %38)
%40 = load i32, i32* @PROT_READ
%41 = load i32, i32* @PROT_WRITE
%42 = or i32 %40, %41
%43 = load i32, i32* @MAP_SHARED
%44 = load i32, i32* %2
%45 = call i8* @mmap(i32* null, i32 %39, i32 %42, i32 %43, i32 %44, i32 1073741824)
store i8* %45, i8** %23
%46 = load i32, i32* @_SC_PAGESIZE
%47 = call i32 @sysconf(i32 %46)
%48 = load i32, i32* @PROT_READ
%49 = load i32, i32* @PROT_WRITE
%50 = or i32 %48, %49
%51 = load i32, i32* @MAP_SHARED
%52 = load i32, i32* %2
%53 = call i8* @mmap(i32* null, i32 %47, i32 %50, i32 %51, i32 %52, i32 1073745920)
store i8* %53, i8** %24
%54 = load i32, i32* @_SC_PAGESIZE
%55 = call i32 @sysconf(i32 %54)
%56 = mul nsw i32 16, %55
%57 = load i32, i32* @PROT_READ
%58 = load i32, i32* @PROT_WRITE
%59 = or i32 %57, %58
%60 = load i32, i32* @MAP_SHARED
%61 = load i32, i32* %2
%62 = call i8* @mmap(i32* null, i32 %56, i32 %59, i32 %60, i32 %61, i32 1073807360)
%63 = bitcast i8* %62 to i32*
store i32* %63, i32** %28
%64 = load i32, i32* @_SC_PAGESIZE
%65 = call i32 @sysconf(i32 %64)
%66 = mul nsw i32 32, %65
%67 = load i32, i32* @PROT_READ
%68 = load i32, i32* @PROT_WRITE
%69 = or i32 %67, %68
%70 = load i32, i32* @MAP_SHARED
%71 = load i32, i32* %2
%72 = call i8* @mmap(i32* null, i32 %66, i32 %69, i32 %70, i32 %71, i32 1073872896)
%73 = bitcast i8* %72 to i32*
store i32* %73, i32** %29
%74 = load i8*, i8** %24
%75 = getelementptr i8, i8* %74, i64 0
%76 = bitcast i8* %75 to i32*
store i32* %76, i32** %27
%77 = load i8*, i8** %24
%78 = getelementptr i8, i8* %77, i64 2
%79 = bitcast i8* %78 to i32*
store i32* %79, i32** %26
%80 = load i8*, i8** %23
%81 = getelementptr i8, i8* %80, i64 0
%82 = bitcast i8* %81 to i32*
store i32* %82, i32** %25
%83 = load i32*, i32** %25
%84 = load volatile i32, i32* %83
%85 = and i32 %84, -2
store volatile i32 %85, i32* %83
%86 = load i8*, i8** %23
%87 = getelementptr i8, i8* %86, i64 1
%88 = bitcast i8* %87 to i32*
store i32 1, i32* %88
%89 = load i8*, i8** %23
%90 = getelementptr i8, i8* %89, i64 2
%91 = bitcast i8* %90 to i32*
store i32 1, i32* %91
%92 = load i8*, i8** %23
%93 = getelementptr i8, i8* %92, i64 3
%94 = bitcast i8* %93 to i32*
store i32 1, i32* %94
%95 = load i8*, i8** %23
%96 = getelementptr i8, i8* %95, i64 4
%97 = bitcast i8* %96 to i32*
store i32 31, i32* %97
store i32 2, i32* %17
%98 = load i32, i32* %17
%99 = sub nsw i32 %98, 1
%100 = load i8*, i8** %23
%101 = getelementptr i8, i8* %100, i64 5
%102 = bitcast i8* %101 to i32*
store i32 %99, i32* %102
store i32 25000, i32* %16
%103 = load i8*, i8** %23
%104 = getelementptr i8, i8* %103, i64 8
%105 = bitcast i8* %104 to i32*
store i32 0, i32* %105
%106 = load i8*, i8** %23
%107 = getelementptr i8, i8* %106, i64 12
%108 = bitcast i8* %107 to i32*
store i32 200, i32* %108
%109 = load i32, i32* %16
%110 = sub nsw i32 %109, 1
%111 = load i8*, i8** %23
%112 = getelementptr i8, i8* %111, i64 16
%113 = bitcast i8* %112 to i32*
store i32 %110, i32* %113
store i32 400, i32* %18
%114 = load i32, i32* %18
%115 = load i8*, i8** %23
%116 = getelementptr i8, i8* %115, i64 20
%117 = bitcast i8* %116 to i32*
store i32 %114, i32* %117
store i32 30, i32* %19
%118 = load i32, i32* %18
%119 = load i32, i32* %19
%120 = add nsw i32 %118, %119
%121 = load i8*, i8** %23
%122 = getelementptr i8, i8* %121, i64 24
%123 = bitcast i8* %122 to i32*
store i32 %120, i32* %123
%124 = load i32, i32* %16
%125 = sub nsw i32 %124, 1
%126 = load i8*, i8** %23
%127 = getelementptr i8, i8* %126, i64 28
%128 = bitcast i8* %127 to i32*
store i32 %125, i32* %128
%129 = load i8*, i8** %23
%130 = getelementptr i8, i8* %129, i64 32
%131 = bitcast i8* %130 to i32*
store i32 2000, i32* %131
%132 = load i8*, i8** %23
%133 = getelementptr i8, i8* %132, i64 36
%134 = bitcast i8* %133 to i32*
store i32 2001, i32* %134
%135 = load i8*, i8** %23
%136 = getelementptr i8, i8* %135, i64 40
%137 = bitcast i8* %136 to i32*
store i32 2001, i32* %137
%138 = load i32, i32* @AF_INET
%139 = load i32, i32* @SOCK_STREAM
%140 = call i32 @socket(i32 %138, i32 %139, i32 0)
store i32 %140, i32* %3
%141 = icmp slt i32 %140, 0
br i1 %141, label %142, label %145
142: ; preds = %37
%143 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%144 = load i32, i32* @EXIT_FAILURE
store i32 %144, i32* %1
br label %421
145: ; preds = %37
%146 = load i32, i32* %3
%147 = load i32, i32* @SOL_SOCKET
%148 = load i32, i32* @SO_REUSEADDR
%149 = bitcast i32* %12 to i8*
%150 = call i32 @setsockopt(i32 %146, i32 %147, i32 %148, i8* %149, i32 4)
%151 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%152 = load i32, i32* @AF_INET
%153 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %152, i32* %153
%154 = load i32, i32* @INADDR_ANY
%155 = call i32 @htonl(i32 %154)
%156 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%157 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %156, i32 0, i32 0
store i32 %155, i32* %157
%158 = call i32 @htons(i32 1001)
%159 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %158, i32* %159
%160 = load i32, i32* %3
%161 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%162 = call i64 @bind(i32 %160, %struct.sockaddr* %161, i32 12)
%163 = icmp slt i64 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %145
%165 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%166 = load i32, i32* @EXIT_FAILURE
store i32 %166, i32* %1
br label %421
167: ; preds = %145
%168 = load i32, i32* %3
%169 = call i32 @listen(i32 %168, i32 1024)
br label %170
170: ; preds = %167, %415
%171 = load i32, i32* %3
%172 = call i32 @accept(i32 %171, i32* null, i32* null)
store i32 %172, i32* %4
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %177
174: ; preds = %170
%175 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%176 = load i32, i32* @EXIT_FAILURE
store i32 %176, i32* %1
br label %421
177: ; preds = %170
br label %178
178: ; preds = %177, %291, %414
%179 = load i32, i32* %4
%180 = load i32, i32* @MSG_WAITALL
%181 = call i64 @recv(i32 %179, i32* %13, i32 4, i32 %180)
%182 = icmp sle i64 %181, 0
br i1 %182, label %183, label %184
183: ; preds = %178
br label %415
184: ; preds = %178
%185 = load i32, i32* %13
%186 = ashr i32 %185, 28
store i32 %186, i32* %14
%187 = load i32, i32* %13
%188 = and i32 %187, 268435455
store i32 %188, i32* %15
%189 = load i32, i32* %14
switch i32 %189, label %414 [
i32 0, label %190
i32 1, label %202
i32 2, label %207
i32 3, label %223
i32 4, label %235
i32 5, label %243
i32 6, label %259
i32 7, label %274
i32 8, label %280
i32 9, label %287
i32 10, label %288
i32 11, label %305
i32 12, label %309
]
190: ; preds = %184
%191 = load i32, i32* %15
store i32 %191, i32* %16
%192 = load i32, i32* %16
%193 = sub nsw i32 %192, 1
%194 = load i8*, i8** %23
%195 = getelementptr i8, i8* %194, i64 16
%196 = bitcast i8* %195 to i32*
store i32 %193, i32* %196
%197 = load i32, i32* %16
%198 = sub nsw i32 %197, 1
%199 = load i8*, i8** %23
%200 = getelementptr i8, i8* %199, i64 28
%201 = bitcast i8* %200 to i32*
store i32 %198, i32* %201
br label %414
202: ; preds = %184
%203 = load i32, i32* %15
%204 = load i8*, i8** %23
%205 = getelementptr i8, i8* %204, i64 12
%206 = bitcast i8* %205 to i32*
store i32 %203, i32* %206
br label %414
207: ; preds = %184
%208 = load i32, i32* %15
%209 = icmp eq i32 %208, 0
br i1 %209, label %210, label %214
210: ; preds = %207
%211 = load i32*, i32** %25
%212 = load volatile i32, i32* %211
%213 = and i32 %212, -5
store volatile i32 %213, i32* %211
br label %222
214: ; preds = %207
%215 = load i32, i32* %15
%216 = icmp eq i32 %215, 1
br i1 %216, label %217, label %221
217: ; preds = %214
%218 = load i32*, i32** %25
%219 = load volatile i32, i32* %218
%220 = or i32 %219, 4
store volatile i32 %220, i32* %218
br label %221
221: ; preds = %217, %214
br label %222
222: ; preds = %221, %210
br label %414
223: ; preds = %184
%224 = load i32, i32* %15
store i32 %224, i32* %18
%225 = load i32, i32* %18
%226 = load i8*, i8** %23
%227 = getelementptr i8, i8* %226, i64 20
%228 = bitcast i8* %227 to i32*
store i32 %225, i32* %228
%229 = load i32, i32* %18
%230 = load i32, i32* %19
%231 = add nsw i32 %229, %230
%232 = load i8*, i8** %23
%233 = getelementptr i8, i8* %232, i64 24
%234 = bitcast i8* %233 to i32*
store i32 %231, i32* %234
br label %414
235: ; preds = %184
%236 = load i32, i32* %15
store i32 %236, i32* %19
%237 = load i32, i32* %18
%238 = load i32, i32* %19
%239 = add nsw i32 %237, %238
%240 = load i8*, i8** %23
%241 = getelementptr i8, i8* %240, i64 24
%242 = bitcast i8* %241 to i32*
store i32 %239, i32* %242
br label %414
243: ; preds = %184
%244 = load i32, i32* %15
%245 = icmp eq i32 %244, 0
br i1 %245, label %246, label %250
246: ; preds = %243
%247 = load i32*, i32** %25
%248 = load volatile i32, i32* %247
%249 = and i32 %248, -9
store volatile i32 %249, i32* %247
br label %258
250: ; preds = %243
%251 = load i32, i32* %15
%252 = icmp eq i32 %251, 1
br i1 %252, label %253, label %257
253: ; preds = %250
%254 = load i32*, i32** %25
%255 = load volatile i32, i32* %254
%256 = or i32 %255, 8
store volatile i32 %256, i32* %254
br label %257
257: ; preds = %253, %250
br label %258
258: ; preds = %257, %246
br label %414
259: ; preds = %184
%260 = load i32, i32* %15
%261 = load i8*, i8** %23
%262 = getelementptr i8, i8* %261, i64 32
%263 = bitcast i8* %262 to i32*
store i32 %260, i32* %263
%264 = load i32, i32* %15
%265 = add nsw i32 %264, 1
%266 = load i8*, i8** %23
%267 = getelementptr i8, i8* %266, i64 36
%268 = bitcast i8* %267 to i32*
store i32 %265, i32* %268
%269 = load i32, i32* %15
%270 = add nsw i32 %269, 1
%271 = load i8*, i8** %23
%272 = getelementptr i8, i8* %271, i64 40
%273 = bitcast i8* %272 to i32*
store i32 %270, i32* %273
br label %414
274: ; preds = %184
%275 = load i32, i32* %15
%276 = sub nsw i32 %275, 1
%277 = load i8*, i8** %23
%278 = getelementptr i8, i8* %277, i64 4
%279 = bitcast i8* %278 to i32*
store i32 %276, i32* %279
br label %414
280: ; preds = %184
%281 = load i32, i32* %15
store i32 %281, i32* %17
%282 = load i32, i32* %17
%283 = sub nsw i32 %282, 1
%284 = load i8*, i8** %23
%285 = getelementptr i8, i8* %284, i64 5
%286 = bitcast i8* %285 to i32*
store i32 %283, i32* %286
br label %414
287: ; preds = %184
store i32 0, i32* %11
br label %414
288: ; preds = %184
%289 = load i32, i32* %11
%290 = icmp sge i32 %289, 1048576
br i1 %290, label %291, label %292
291: ; preds = %288
br label %178
292: ; preds = %288
%293 = load i32, i32* %15
%294 = and i32 %293, 268419072
%295 = shl i32 %294, 2
%296 = load i32, i32* %15
%297 = and i32 %296, 16383
%298 = or i32 %295, %297
%299 = load i32*, i32** %20
%300 = load i32, i32* %11
%301 = sext i32 %300 to i64
%302 = getelementptr inbounds i32, i32* %299, i64 %301
store i32 %298, i32* %302
%303 = load i32, i32* %11
%304 = add nsw i32 %303, 1
store i32 %304, i32* %11
br label %414
305: ; preds = %184
%306 = load i32*, i32** %25
%307 = load volatile i32, i32* %306
%308 = or i32 %307, 1
store volatile i32 %308, i32* %306
br label %414
309: ; preds = %184
store i32 0, i32* %9
store i32 0, i32* %10
store i32 1024, i32* %8
%310 = load i32*, i32** %25
%311 = load volatile i32, i32* %310
%312 = and i32 %311, -2
store volatile i32 %312, i32* %310
%313 = load i32*, i32** %25
%314 = load volatile i32, i32* %313
%315 = or i32 %314, 2
store volatile i32 %315, i32* %313
%316 = load i32*, i32** %25
%317 = load volatile i32, i32* %316
%318 = and i32 %317, -3
store volatile i32 %318, i32* %316
br label %319
319: ; preds = %409, %309
%320 = load i32, i32* %9
%321 = load i32, i32* %11
%322 = icmp slt i32 %320, %321
br i1 %322, label %323, label %413
323: ; preds = %319
%324 = load i32, i32* %8
%325 = load i32, i32* %11
%326 = load i32, i32* %9
%327 = sub nsw i32 %325, %326
%328 = icmp sgt i32 %324, %327
br i1 %328, label %329, label %333
329: ; preds = %323
%330 = load i32, i32* %11
%331 = load i32, i32* %9
%332 = sub nsw i32 %330, %331
store i32 %332, i32* %8
br label %333
333: ; preds = %329, %323
%334 = load i32*, i32** %26
%335 = load volatile i32, i32* %334
%336 = load i32, i32* %8
%337 = mul nsw i32 %336, 2
%338 = icmp slt i32 %335, %337
br i1 %338, label %339, label %341
339: ; preds = %333
%340 = call i32 @usleep(i32 500)
br label %341
341: ; preds = %339, %333
%342 = load i32*, i32** %26
%343 = load volatile i32, i32* %342
%344 = load i32, i32* %8
%345 = mul nsw i32 %344, 2
%346 = icmp sge i32 %343, %345
br i1 %346, label %347, label %378
347: ; preds = %341
%348 = load i32, i32* %9
%349 = load i32, i32* %11
%350 = icmp slt i32 %348, %349
br i1 %350, label %351, label %378
351: ; preds = %347
store i32 0, i32* %7
br label %352
352: ; preds = %362, %351
%353 = load i32, i32* %7
%354 = load i32, i32* %8
%355 = icmp slt i32 %353, %354
br i1 %355, label %356, label %365
356: ; preds = %352
%357 = load i32*, i32** %29
%358 = load volatile i32, i32* %357
%359 = load i32, i32* %7
%360 = sext i32 %359 to i64
%361 = getelementptr inbounds [1024 x i32], [1024 x i32]* %21, i64 0, i64 %360
store i32 %358, i32* %361
br label %362
362: ; preds = %356
%363 = load i32, i32* %7
%364 = add nsw i32 %363, 1
store i32 %364, i32* %7
br label %352
365: ; preds = %352
%366 = load i32, i32* %4
%367 = getelementptr inbounds [1024 x i32], [1024 x i32]* %21, i64 0, i64 0
%368 = load i32, i32* %8
%369 = mul nsw i32 %368, 8
%370 = load i32, i32* @MSG_NOSIGNAL
%371 = call i32 @send(i32 %366, i32* %367, i32 %369, i32 %370)
%372 = icmp slt i32 %371, 0
br i1 %372, label %373, label %374
373: ; preds = %365
br label %413
374: ; preds = %365
%375 = load i32, i32* %8
%376 = load i32, i32* %9
%377 = add nsw i32 %376, %375
store i32 %377, i32* %9
br label %378
378: ; preds = %374, %347, %341
br label %379
379: ; preds = %406, %378
%380 = load i32*, i32** %27
%381 = load volatile i32, i32* %380
%382 = load i32, i32* %17
%383 = sub nsw i32 16384, %382
%384 = icmp slt i32 %381, %383
br i1 %384, label %385, label %389
385: ; preds = %379
%386 = load i32, i32* %10
%387 = load i32, i32* %11
%388 = icmp slt i32 %386, %387
br label %389
389: ; preds = %385, %379
%390 = phi i1 [ false, %379 ], [ %388, %385 ]
br i1 %390, label %391, label %409
391: ; preds = %389
store i32 0, i32* %7
br label %392
392: ; preds = %403, %391
%393 = load i32, i32* %7
%394 = load i32, i32* %17
%395 = icmp slt i32 %393, %394
br i1 %395, label %396, label %406
396: ; preds = %392
%397 = load i32*, i32** %20
%398 = load i32, i32* %10
%399 = sext i32 %398 to i64
%400 = getelementptr inbounds i32, i32* %397, i64 %399
%401 = load i32, i32* %400
%402 = load i32*, i32** %28
store volatile i32 %401, i32* %402
br label %403
403: ; preds = %396
%404 = load i32, i32* %7
%405 = add nsw i32 %404, 1
store i32 %405, i32* %7
br label %392
406: ; preds = %392
%407 = load i32, i32* %10
%408 = add nsw i32 %407, 1
store i32 %408, i32* %10
br label %379
409: ; preds = %389
%410 = load i32*, i32** %25
%411 = load volatile i32, i32* %410
%412 = or i32 %411, 1
store volatile i32 %412, i32* %410
br label %319
413: ; preds = %373, %319
br label %414
414: ; preds = %184, %413, %305, %292, %287, %280, %274, %259, %258, %235, %223, %222, %202, %190
br label %178
415: ; preds = %183
%416 = load i32*, i32** %25
%417 = load volatile i32, i32* %416
%418 = and i32 %417, -2
store volatile i32 %418, i32* %416
%419 = load i32, i32* %4
%420 = call i32 @close(i32 %419)
br label %170
421: ; preds = %174, %164, %142, %34
%422 = load i32, i32* %1
ret i32 %422
}

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
}