#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 int16_t;
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);
scalar_t__ floor(double);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ listen(int, 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, char *, 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 argc, char *argv[]) {
  int fd, sock_server, sock_client;
  void *cfg, *sts;
  volatile uint32_t *tx_data, *rx_freq, *tx_freq;
  volatile uint16_t *rx_rate, *rx_cntr, *tx_cntr;
  volatile int16_t *tx_level;
  volatile uint8_t *rx_rst, *tx_rst;
  volatile uint64_t *rx_data;
  struct sockaddr_in addr;
  uint32_t command, value;
  uint64_t buffer[10000];
  int i, j, size, yes = 1;
  if ((fd = open("/dev/mem", O_RDWR)) < 0) {
    perror("open");
    return EXIT_FAILURE;
  }
  sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40000000);
  cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0x40001000);
  rx_data = mmap(NULL, 32 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
                 MAP_SHARED, fd, 0x40020000);
  tx_data = mmap(NULL, 4 * sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE,
                 MAP_SHARED, fd, 0x40004000);
  rx_rst = ((uint8_t *)(cfg + 0));
  rx_freq = ((uint32_t *)(cfg + 4));
  rx_rate = ((uint16_t *)(cfg + 8));
  rx_cntr = ((uint16_t *)(sts + 12));
  tx_rst = ((uint8_t *)(cfg + 1));
  tx_freq = ((uint32_t *)(cfg + 12));
  tx_level = ((int16_t *)(cfg + 16));
  tx_cntr = ((uint16_t *)(sts + 14));
  *rx_rst |= 1;
  *rx_rst &= ~2;
  *tx_rst |= 1;
  *rx_freq = (uint32_t)floor(19000000 / 125.0e6 * (1 << 30) + 0.5);
  *rx_rate = 250;
  *tx_freq = (uint32_t)floor(19000000 / 125.0e6 * (1 << 30) + 0.5);
  *tx_level = 16382;
  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, (char *)&command, 4, MSG_WAITALL) <= 0)
        break;
      value = command & 0xfffffff;
      switch (command >> 28) {
      case 0:
        if (value < 0 || value > 60000000)
          continue;
        *rx_freq = (uint32_t)floor(value / 125.0e6 * (1 << 30) + 0.5);
        *tx_freq = (uint32_t)floor(value / 125.0e6 * (1 << 30) + 0.5);
        break;
      case 1:
        switch (command & 7) {
        case 0:
          *rx_rate = 2500;
          break;
        case 1:
          *rx_rate = 1250;
          break;
        case 2:
          *rx_rate = 250;
          break;
        case 3:
          *rx_rate = 125;
          break;
        case 4:
          *rx_rate = 25;
          break;
        }
        break;
      case 2:
        *tx_rst |= 1;
        *tx_rst &= ~1;
        *tx_data = 0;
        *tx_data = 100 - 2;
        *tx_data = 50 - 1;
        *tx_data = 0;
        *tx_data = (uint32_t)floor(0.25 * (1 << 30) + 0.5);
        ;
        *tx_data = 150 - 2;
        *tx_data = 75 - 1;
        *tx_data = 0;
        *tx_data = (uint32_t)floor(0.5 * (1 << 30) + 0.5);
        ;
        *tx_data = 100 - 2;
        *tx_data = 50 - 1;
        *tx_data = 0;
        break;
      case 3:
        *rx_rst |= 1;
        *rx_rst &= ~1;
        *rx_rst &= ~2;
        *rx_rst |= 2;
        for (i = 0; i < 10; ++i) {
          while (*rx_cntr < 20000)
            usleep(500);
          for (j = 0; j < 10000; ++j)
            buffer[j] = *rx_data;
          send(sock_client, buffer, 80000, MSG_NOSIGNAL);
        }
        *rx_rst |= 1;
        *rx_rst &= ~2;
        *tx_rst |= 1;
        break;
      }
    }
    close(sock_client);
  }
  close(sock_server);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9d00,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x9cf0(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
lea    0xe11(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1271 <main+0x61>
lea    0xe02(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    18a8 <main+0x698>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %eax,%esi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
mov    0x2d07(%rip),%rax
or     (%rax),%edx
mov    0x2d4e(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40000000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %eax,%esi
mov    0x2d2e(%rip),%rax
mov    (%rax),%edx
mov    0x2cc5(%rip),%rax
or     (%rax),%edx
mov    0x2d0c(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40001000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %eax,%esi
shl    $0x5,%esi
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
mov    0x2c80(%rip),%rax
or     (%rax),%edx
mov    0x2cc7(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40020000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x80(%rbp)
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %eax,%esi
shl    $0x2,%esi
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
mov    0x2c3b(%rip),%rax
or     (%rax),%edx
mov    0x2c82(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40004000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rax
add    $0xe,%rax
mov    %rax,-0x60(%rbp)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x78(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
movsd  0xbfc(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
movl   $0xfa,(%rax)
movsd  0xbdd(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x68(%rbp),%rax
movl   $0x3ffe,(%rax)
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
mov    0x2b5e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    147c <main+0x26c>
lea    0xbfc(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    18a8 <main+0x698>
mov    -0x18(%rbp),%edi
mov    0x2b4a(%rip),%rax
mov    (%rax),%esi
mov    0x2af9(%rip),%rax
mov    (%rax),%edx
lea    -0x9cf0(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2b0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x88(%rbp)
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x8c(%rbp)
mov    $0x3e9,%edi
call   1060 <htons@plt>
mov    %eax,-0x90(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    1524 <main+0x314>
lea    0xb5b(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    18a8 <main+0x698>
mov    -0x18(%rbp),%edi
mov    $0x400,%esi
call   10b0 <listen@plt>
mov    -0x18(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1100 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1569 <main+0x359>
lea    0xb1b(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    18a8 <main+0x698>
jmp    156e <main+0x35e>
mov    -0x1c(%rbp),%edi
lea    -0x94(%rbp),%rsi
mov    0x29f9(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%edx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     159a <main+0x38a>
jmp    189b <main+0x68b>
mov    -0x94(%rbp),%eax
and    $0xfffffff,%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%eax
sar    $0x1c,%eax
mov    %eax,%ecx
mov    %rcx,-0x9cf8(%rbp)
sub    $0x3,%eax
ja     1896 <main+0x686>
mov    -0x9cf8(%rbp),%rax
lea    0xa5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x98(%rbp)
jl     15fa <main+0x3ea>
cmpl   $0x3938700,-0x98(%rbp)
87 93 03
jle    15ff <main+0x3ef>
jmp    156e <main+0x35e>
cvtsi2sdl -0x98(%rbp),%xmm0
ff
movsd  0xa19(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0x9fd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x9f9(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
cvtsi2sdl -0x98(%rbp),%xmm0
ff
movsd  0x9e0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0x9c4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x9c0(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
jmp    1896 <main+0x686>
mov    -0x94(%rbp),%eax
and    $0x7,%eax
mov    %rax,-0x9d00(%rbp)
sub    $0x4,%eax
ja     16ec <main+0x4dc>
mov    -0x9d00(%rbp),%rax
lea    0x9a3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x50(%rbp),%rax
movl   $0x9c4,(%rax)
jmp    16ec <main+0x4dc>
mov    -0x50(%rbp),%rax
movl   $0x4e2,(%rax)
jmp    16ec <main+0x4dc>
mov    -0x50(%rbp),%rax
movl   $0xfa,(%rax)
jmp    16ec <main+0x4dc>
mov    -0x50(%rbp),%rax
movl   $0x7d,(%rax)
jmp    16ec <main+0x4dc>
mov    -0x50(%rbp),%rax
movl   $0x19,(%rax)
jmp    1896 <main+0x686>
mov    -0x78(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x78(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x62,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x31,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
movsd  0x8d9(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x94,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x4a,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
movsd  0x89e(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x62,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x31,(%rax)
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
jmp    1896 <main+0x686>
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffe,%ecx
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x9ce4(%rbp)
cmpl   $0xa,-0x9ce4(%rbp)
jge    1875 <main+0x665>
jmp    17e2 <main+0x5d2>
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
cmp    $0x4e20,%eax
jge    1802 <main+0x5f2>
mov    $0x1f4,%edi
call   1120 <usleep@plt>
jmp    17e2 <main+0x5d2>
movl   $0x0,-0x9ce8(%rbp)
cmpl   $0x2710,-0x9ce8(%rbp)
jge    1844 <main+0x634>
mov    -0x80(%rbp),%rax
mov    (%rax),%ecx
movslq -0x9ce8(%rbp),%rax
mov    %ecx,-0x9ce0(%rbp,%rax,4)
mov    -0x9ce8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9ce8(%rbp)
jmp    180c <main+0x5fc>
mov    -0x1c(%rbp),%edi
lea    -0x9ce0(%rbp),%rsi
mov    0x273b(%rip),%rax
mov    (%rax),%ecx
mov    $0x13880,%edx
call   1070 <send@plt>
mov    -0x9ce4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9ce4(%rbp)
jmp    17d0 <main+0x5c0>
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    %ecx,(%rax)
mov    -0x78(%rbp),%rax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
jmp    156e <main+0x35e>
mov    -0x1c(%rbp),%edi
call   10a0 <close@plt>
jmp    1531 <main+0x321>
mov    -0x4(%rbp),%eax
add    $0x9d00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c88,%rsp
movl   $0x1,0x14(%rsp)
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
lea    0xe1b(%rip),%rdi
call   10d0 <open@plt>
test   %eax,%eax
jns    124e <main+0x3e>
lea    0xe14(%rip),%rdi
jmp    1442 <main+0x232>
mov    %eax,%ebp
mov    0x2d61(%rip),%r13
mov    0x0(%r13),%edi
call   10f0 <sysconf@plt>
mov    0x2d91(%rip),%rcx
mov    0x2d2a(%rip),%r14
mov    (%r14),%edx
or     (%rcx),%edx
mov    %rcx,%rbx
mov    0x2d6b(%rip),%r12
mov    (%r12),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40000000,%r9d
call   1050 <mmap@plt>
mov    %rax,%r15
mov    0x0(%r13),%edi
call   10f0 <sysconf@plt>
mov    (%r14),%edx
or     (%rbx),%edx
mov    (%r12),%ecx
mov    %r12,%r14
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40001000,%r9d
call   1050 <mmap@plt>
mov    %rax,%r12
mov    0x0(%r13),%edi
call   10f0 <sysconf@plt>
shl    $0x5,%eax
mov    0x2cc5(%rip),%rcx
mov    (%rcx),%edx
or     (%rbx),%edx
mov    (%r14),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
mov    $0x40020000,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    0x0(%r13),%edi
call   10f0 <sysconf@plt>
lea    0x0(,%rax,4),%esi
mov    0x2c92(%rip),%rax
mov    (%rax),%edx
mov    0x2ce9(%rip),%rax
or     (%rax),%edx
mov    (%r14),%ecx
xor    %edi,%edi
mov    %ebp,%r8d
mov    $0x40004000,%r9d
call   1050 <mmap@plt>
orl    $0x1,(%r12)
andl   $0xfffffffd,(%r12)
mov    %rax,0x38(%rsp)
orl    $0x1,0x1(%r12)
movsd  0xcbf(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,0x4(%r12)
movl   $0xfa,0x8(%r12)
movsd  0xca4(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,0xc(%r12)
mov    %r12,%r13
movl   $0x3ffe,0x10(%r12)
mov    0x2c4f(%rip),%r12
mov    (%r12),%edi
mov    0x2c24(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
jns    139d <main+0x18d>
lea    0xcca(%rip),%rdi
jmp    1442 <main+0x232>
mov    %eax,%ebp
mov    0x2c2a(%rip),%rax
mov    (%rax),%esi
mov    0x2bd9(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    (%r12),%eax
mov    %eax,0x28(%rsp)
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x24(%rsp)
mov    $0x3e9,%edi
call   1060 <htons@plt>
mov    %eax,0x20(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %rax,%rax
jns    141c <main+0x20c>
lea    0xc4f(%rip),%rdi
jmp    1442 <main+0x232>
mov    %ebp,%edi
mov    $0x400,%esi
call   10b0 <listen@plt>
mov    %ebp,0x10(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
test   %eax,%eax
jns    1462 <main+0x252>
lea    0xc2c(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b52(%rip),%rax
mov    (%rax),%eax
add    $0x9c88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    %r13,%r12
mov    0x2b22(%rip),%r14
lea    0x40(%rsp),%r13
mov    %r12,0x18(%rsp)
jmp    1510 <main+0x300>
orl    $0x1,0x1(%r12)
andl   $0xfffffffe,0x1(%r12)
mov    0x38(%rsp),%r12
movl   $0x0,(%r12)
movl   $0x62,(%r12)
movl   $0x31,(%r12)
movl   $0x0,(%r12)
movsd  0xb52(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,(%r12)
movl   $0x94,(%r12)
movl   $0x4a,(%r12)
movl   $0x0,(%r12)
movsd  0xb31(%rip),%xmm0
call   1110 <floor@plt>
mov    %eax,(%r12)
movl   $0x62,(%r12)
movl   $0x31,(%r12)
movl   $0x0,(%r12)
mov    0x18(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2a61(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1030 <recv@plt>
test   %rax,%rax
jle    1680 <main+0x470>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
sar    $0x1c,%ecx
cmp    $0x3,%ecx
ja     1510 <main+0x300>
lea    0xae8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
and    $0xfffffff,%eax
cmp    $0x3938700,%eax
ja     1510 <main+0x300>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xaac(%rip),%xmm0
mulsd  0xaac(%rip),%xmm0
addsd  0xaac(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
call   1110 <floor@plt>
mov    %eax,0x4(%r12)
movsd  0x30(%rsp),%xmm0
call   1110 <floor@plt>
mov    %eax,0xc(%r12)
jmp    1510 <main+0x300>
and    $0x7,%eax
cmp    $0x4,%eax
ja     1510 <main+0x300>
lea    0xa8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x9c4,0x8(%r12)
jmp    1510 <main+0x300>
orl    $0x1,(%r12)
andl   $0xfffffffe,(%r12)
andl   $0xfffffffd,(%r12)
orl    $0x2,(%r12)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%r15),%eax
cmp    $0x4e1f,%eax
jg     1615 <main+0x405>
nopl   0x0(%rax,%rax,1)
mov    $0x1f4,%edi
call   1120 <usleep@plt>
mov    0xc(%r15),%eax
cmp    $0x4e20,%eax
jl     1600 <main+0x3f0>
mov    $0x4,%eax
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%ecx
mov    %ecx,0x30(%rsp,%rax,4)
mov    (%rbx),%ecx
mov    %ecx,0x34(%rsp,%rax,4)
mov    (%rbx),%ecx
mov    %ecx,0x38(%rsp,%rax,4)
mov    (%rbx),%ecx
mov    %ecx,0x3c(%rsp,%rax,4)
mov    (%rbx),%ecx
mov    %ecx,0x40(%rsp,%rax,4)
add    $0x5,%rax
cmp    $0x2714,%rax
jne    1620 <main+0x410>
mov    (%r14),%ecx
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x13880,%edx
call   1070 <send@plt>
add    $0x1,%r12d
cmp    $0xa,%r12d
jne    15f0 <main+0x3e0>
mov    0x18(%rsp),%r12
orl    $0x1,(%r12)
andl   $0xfffffffd,(%r12)
orl    $0x1,0x1(%r12)
jmp    1510 <main+0x300>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x10(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1510 <main+0x300>
jmp    143b <main+0x22b>
movl   $0x4e2,0x8(%r12)
jmp    1510 <main+0x300>
movl   $0xfa,0x8(%r12)
jmp    1510 <main+0x300>
movl   $0x7d,0x8(%r12)
jmp    1510 <main+0x300>
movl   $0x19,0x8(%r12)
jmp    1510 <main+0x300>

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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%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 %struct.sockaddr_in
%22 = alloca i32
%23 = alloca i32
%24 = alloca [10000 x i32]
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %28
%29 = load i32, i32* @O_RDWR
%30 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %29)
store i32 %30, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %282
35: ; preds = %2
%36 = load i32, i32* @_SC_PAGESIZE
%37 = call i32 @sysconf(i32 %36)
%38 = load i32, i32* @PROT_READ
%39 = load i32, i32* @PROT_WRITE
%40 = or i32 %38, %39
%41 = load i32, i32* @MAP_SHARED
%42 = load i32, i32* %6
%43 = call i8* @mmap(i32* null, i32 %37, i32 %40, i32 %41, i32 %42, i32 1073741824)
store i8* %43, i8** %10
%44 = load i32, i32* @_SC_PAGESIZE
%45 = call i32 @sysconf(i32 %44)
%46 = load i32, i32* @PROT_READ
%47 = load i32, i32* @PROT_WRITE
%48 = or i32 %46, %47
%49 = load i32, i32* @MAP_SHARED
%50 = load i32, i32* %6
%51 = call i8* @mmap(i32* null, i32 %45, i32 %48, i32 %49, i32 %50, i32 1073745920)
store i8* %51, i8** %9
%52 = load i32, i32* @_SC_PAGESIZE
%53 = call i32 @sysconf(i32 %52)
%54 = mul nsw i32 32, %53
%55 = load i32, i32* @PROT_READ
%56 = load i32, i32* @PROT_WRITE
%57 = or i32 %55, %56
%58 = load i32, i32* @MAP_SHARED
%59 = load i32, i32* %6
%60 = call i8* @mmap(i32* null, i32 %54, i32 %57, i32 %58, i32 %59, i32 1073872896)
%61 = bitcast i8* %60 to i32*
store i32* %61, i32** %20
%62 = load i32, i32* @_SC_PAGESIZE
%63 = call i32 @sysconf(i32 %62)
%64 = mul nsw i32 4, %63
%65 = load i32, i32* @PROT_READ
%66 = load i32, i32* @PROT_WRITE
%67 = or i32 %65, %66
%68 = load i32, i32* @MAP_SHARED
%69 = load i32, i32* %6
%70 = call i8* @mmap(i32* null, i32 %64, i32 %67, i32 %68, i32 %69, i32 1073758208)
%71 = bitcast i8* %70 to i32*
store i32* %71, i32** %11
%72 = load i8*, i8** %9
%73 = getelementptr i8, i8* %72, i64 0
%74 = bitcast i8* %73 to i32*
store i32* %74, i32** %18
%75 = load i8*, i8** %9
%76 = getelementptr i8, i8* %75, i64 4
%77 = bitcast i8* %76 to i32*
store i32* %77, i32** %12
%78 = load i8*, i8** %9
%79 = getelementptr i8, i8* %78, i64 8
%80 = bitcast i8* %79 to i32*
store i32* %80, i32** %14
%81 = load i8*, i8** %10
%82 = getelementptr i8, i8* %81, i64 12
%83 = bitcast i8* %82 to i32*
store i32* %83, i32** %15
%84 = load i8*, i8** %9
%85 = getelementptr i8, i8* %84, i64 1
%86 = bitcast i8* %85 to i32*
store i32* %86, i32** %19
%87 = load i8*, i8** %9
%88 = getelementptr i8, i8* %87, i64 12
%89 = bitcast i8* %88 to i32*
store i32* %89, i32** %13
%90 = load i8*, i8** %9
%91 = getelementptr i8, i8* %90, i64 16
%92 = bitcast i8* %91 to i32*
store i32* %92, i32** %17
%93 = load i8*, i8** %10
%94 = getelementptr i8, i8* %93, i64 14
%95 = bitcast i8* %94 to i32*
store i32* %95, i32** %16
%96 = load i32*, i32** %18
%97 = load volatile i32, i32* %96
%98 = or i32 %97, 1
store volatile i32 %98, i32* %96
%99 = load i32*, i32** %18
%100 = load volatile i32, i32* %99
%101 = and i32 %100, -3
store volatile i32 %101, i32* %99
%102 = load i32*, i32** %19
%103 = load volatile i32, i32* %102
%104 = or i32 %103, 1
store volatile i32 %104, i32* %102
%105 = call i64 @floor(double 0x41A374BC6B7EF9DB)
%106 = trunc i64 %105 to i32
%107 = load i32*, i32** %12
store volatile i32 %106, i32* %107
%108 = load i32*, i32** %14
store volatile i32 250, i32* %108
%109 = call i64 @floor(double 0x41A374BC6B7EF9DB)
%110 = trunc i64 %109 to i32
%111 = load i32*, i32** %13
store volatile i32 %110, i32* %111
%112 = load i32*, i32** %17
store volatile i32 16382, i32* %112
%113 = load i32, i32* @AF_INET
%114 = load i32, i32* @SOCK_STREAM
%115 = call i32 @socket(i32 %113, i32 %114, i32 0)
store i32 %115, i32* %7
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %35
%118 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
store i32 %119, i32* %3
br label %282
120: ; preds = %35
%121 = load i32, i32* %7
%122 = load i32, i32* @SOL_SOCKET
%123 = load i32, i32* @SO_REUSEADDR
%124 = bitcast i32* %28 to i8*
%125 = call i32 @setsockopt(i32 %121, i32 %122, i32 %123, i8* %124, i32 4)
%126 = call i32 @memset(%struct.sockaddr_in* %21, i32 0, i32 12)
%127 = load i32, i32* @AF_INET
%128 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %21, i32 0, i32 2
store i32 %127, i32* %128
%129 = load i32, i32* @INADDR_ANY
%130 = call i32 @htonl(i32 %129)
%131 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %21, i32 0, i32 1
%132 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %131, i32 0, i32 0
store i32 %130, i32* %132
%133 = call i32 @htons(i32 1001)
%134 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %21, i32 0, i32 0
store i32 %133, i32* %134
%135 = load i32, i32* %7
%136 = bitcast %struct.sockaddr_in* %21 to %struct.sockaddr*
%137 = call i64 @bind(i32 %135, %struct.sockaddr* %136, i32 12)
%138 = icmp slt i64 %137, 0
br i1 %138, label %139, label %142
139: ; preds = %120
%140 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%141 = load i32, i32* @EXIT_FAILURE
store i32 %141, i32* %3
br label %282
142: ; preds = %120
%143 = load i32, i32* %7
%144 = call i32 @listen(i32 %143, i32 1024)
br label %145
145: ; preds = %142, %279
%146 = load i32, i32* %7
%147 = call i32 @accept(i32 %146, i32* null, i32* null)
store i32 %147, i32* %8
%148 = icmp slt i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %145
%150 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%151 = load i32, i32* @EXIT_FAILURE
store i32 %151, i32* %3
br label %282
152: ; preds = %145
br label %153
153: ; preds = %152, %171, %278
%154 = load i32, i32* %8
%155 = bitcast i32* %22 to i8*
%156 = load i32, i32* @MSG_WAITALL
%157 = call i64 @recv(i32 %154, i8* %155, i32 4, i32 %156)
%158 = icmp sle i64 %157, 0
br i1 %158, label %159, label %160
159: ; preds = %153
br label %279
160: ; preds = %153
%161 = load i32, i32* %22
%162 = and i32 %161, 268435455
store i32 %162, i32* %23
%163 = load i32, i32* %22
%164 = ashr i32 %163, 28
switch i32 %164, label %278 [
i32 0, label %165
i32 1, label %187
i32 2, label %201
i32 3, label %224
]
165: ; preds = %160
%166 = load i32, i32* %23
%167 = icmp slt i32 %166, 0
br i1 %167, label %171, label %168
168: ; preds = %165
%169 = load i32, i32* %23
%170 = icmp sgt i32 %169, 60000000
br i1 %170, label %171, label %172
171: ; preds = %168, %165
br label %153
172: ; preds = %168
%173 = load i32, i32* %23
%174 = sitofp i32 %173 to double
%175 = fdiv double %174, 1.250000e+08
%176 = call double @llvm.fmuladd.f64(double %175, double 0x41D0000000000000, double 5.000000e-01)
%177 = call i64 @floor(double %176)
%178 = trunc i64 %177 to i32
%179 = load i32*, i32** %12
store volatile i32 %178, i32* %179
%180 = load i32, i32* %23
%181 = sitofp i32 %180 to double
%182 = fdiv double %181, 1.250000e+08
%183 = call double @llvm.fmuladd.f64(double %182, double 0x41D0000000000000, double 5.000000e-01)
%184 = call i64 @floor(double %183)
%185 = trunc i64 %184 to i32
%186 = load i32*, i32** %13
store volatile i32 %185, i32* %186
br label %278
187: ; preds = %160
%188 = load i32, i32* %22
%189 = and i32 %188, 7
switch i32 %189, label %200 [
i32 0, label %190
i32 1, label %192
i32 2, label %194
i32 3, label %196
i32 4, label %198
]
190: ; preds = %187
%191 = load i32*, i32** %14
store volatile i32 2500, i32* %191
br label %200
192: ; preds = %187
%193 = load i32*, i32** %14
store volatile i32 1250, i32* %193
br label %200
194: ; preds = %187
%195 = load i32*, i32** %14
store volatile i32 250, i32* %195
br label %200
196: ; preds = %187
%197 = load i32*, i32** %14
store volatile i32 125, i32* %197
br label %200
198: ; preds = %187
%199 = load i32*, i32** %14
store volatile i32 25, i32* %199
br label %200
200: ; preds = %187, %198, %196, %194, %192, %190
br label %278
201: ; preds = %160
%202 = load i32*, i32** %19
%203 = load volatile i32, i32* %202
%204 = or i32 %203, 1
store volatile i32 %204, i32* %202
%205 = load i32*, i32** %19
%206 = load volatile i32, i32* %205
%207 = and i32 %206, -2
store volatile i32 %207, i32* %205
%208 = load i32*, i32** %11
store volatile i32 0, i32* %208
%209 = load i32*, i32** %11
store volatile i32 98, i32* %209
%210 = load i32*, i32** %11
store volatile i32 49, i32* %210
%211 = load i32*, i32** %11
store volatile i32 0, i32* %211
%212 = call i64 @floor(double 0x41B0000000800000)
%213 = trunc i64 %212 to i32
%214 = load i32*, i32** %11
store volatile i32 %213, i32* %214
%215 = load i32*, i32** %11
store volatile i32 148, i32* %215
%216 = load i32*, i32** %11
store volatile i32 74, i32* %216
%217 = load i32*, i32** %11
store volatile i32 0, i32* %217
%218 = call i64 @floor(double 0x41C0000000400000)
%219 = trunc i64 %218 to i32
%220 = load i32*, i32** %11
store volatile i32 %219, i32* %220
%221 = load i32*, i32** %11
store volatile i32 98, i32* %221
%222 = load i32*, i32** %11
store volatile i32 49, i32* %222
%223 = load i32*, i32** %11
store volatile i32 0, i32* %223
br label %278
224: ; preds = %160
%225 = load i32*, i32** %18
%226 = load volatile i32, i32* %225
%227 = or i32 %226, 1
store volatile i32 %227, i32* %225
%228 = load i32*, i32** %18
%229 = load volatile i32, i32* %228
%230 = and i32 %229, -2
store volatile i32 %230, i32* %228
%231 = load i32*, i32** %18
%232 = load volatile i32, i32* %231
%233 = and i32 %232, -3
store volatile i32 %233, i32* %231
%234 = load i32*, i32** %18
%235 = load volatile i32, i32* %234
%236 = or i32 %235, 2
store volatile i32 %236, i32* %234
store i32 0, i32* %25
br label %237
237: ; preds = %265, %224
%238 = load i32, i32* %25
%239 = icmp slt i32 %238, 10
br i1 %239, label %240, label %268
240: ; preds = %237
br label %241
241: ; preds = %245, %240
%242 = load i32*, i32** %15
%243 = load volatile i32, i32* %242
%244 = icmp slt i32 %243, 20000
br i1 %244, label %245, label %247
245: ; preds = %241
%246 = call i32 @usleep(i32 500)
br label %241
247: ; preds = %241
store i32 0, i32* %26
br label %248
248: ; preds = %257, %247
%249 = load i32, i32* %26
%250 = icmp slt i32 %249, 10000
br i1 %250, label %251, label %260
251: ; preds = %248
%252 = load i32*, i32** %20
%253 = load volatile i32, i32* %252
%254 = load i32, i32* %26
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds [10000 x i32], [10000 x i32]* %24, i64 0, i64 %255
store i32 %253, i32* %256
br label %257
257: ; preds = %251
%258 = load i32, i32* %26
%259 = add nsw i32 %258, 1
store i32 %259, i32* %26
br label %248
260: ; preds = %248
%261 = load i32, i32* %8
%262 = getelementptr inbounds [10000 x i32], [10000 x i32]* %24, i64 0, i64 0
%263 = load i32, i32* @MSG_NOSIGNAL
%264 = call i32 @send(i32 %261, i32* %262, i32 80000, i32 %263)
br label %265
265: ; preds = %260
%266 = load i32, i32* %25
%267 = add nsw i32 %266, 1
store i32 %267, i32* %25
br label %237
268: ; preds = %237
%269 = load i32*, i32** %18
%270 = load volatile i32, i32* %269
%271 = or i32 %270, 1
store volatile i32 %271, i32* %269
%272 = load i32*, i32** %18
%273 = load volatile i32, i32* %272
%274 = and i32 %273, -3
store volatile i32 %274, i32* %272
%275 = load i32*, i32** %19
%276 = load volatile i32, i32* %275
%277 = or i32 %276, 1
store volatile i32 %277, i32* %275
br label %278
278: ; preds = %160, %268, %201, %200, %172
br label %153
279: ; preds = %159
%280 = load i32, i32* %8
%281 = call i32 @close(i32 %280)
br label %145
282: ; preds = %149, %139, %117, %32
%283 = load i32, i32* %3
ret i32 %283
}

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(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [10000 x i32]
%6 = alloca i32
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast [10000 x i32]* %5 to i8*
%10 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%11 = load i32, i32* @O_RDWR
%12 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %194
16: ; preds = %2
%17 = load i32, i32* @_SC_PAGESIZE
%18 = tail call i32 @sysconf(i32 %17)
%19 = load i32, i32* @PROT_READ
%20 = load i32, i32* @PROT_WRITE
%21 = or i32 %20, %19
%22 = load i32, i32* @MAP_SHARED
%23 = tail call i8* @mmap(i32* null, i32 %18, i32 %21, i32 %22, i32 %12, i32 1073741824)
%24 = load i32, i32* @_SC_PAGESIZE
%25 = tail call i32 @sysconf(i32 %24)
%26 = load i32, i32* @PROT_READ
%27 = load i32, i32* @PROT_WRITE
%28 = or i32 %27, %26
%29 = load i32, i32* @MAP_SHARED
%30 = tail call i8* @mmap(i32* null, i32 %25, i32 %28, i32 %29, i32 %12, i32 1073745920)
%31 = load i32, i32* @_SC_PAGESIZE
%32 = tail call i32 @sysconf(i32 %31)
%33 = shl nsw i32 %32, 5
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @PROT_WRITE
%36 = or i32 %35, %34
%37 = load i32, i32* @MAP_SHARED
%38 = tail call i8* @mmap(i32* null, i32 %33, i32 %36, i32 %37, i32 %12, i32 1073872896)
%39 = bitcast i8* %38 to i32*
%40 = load i32, i32* @_SC_PAGESIZE
%41 = tail call i32 @sysconf(i32 %40)
%42 = shl nsw i32 %41, 2
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @PROT_WRITE
%45 = or i32 %44, %43
%46 = load i32, i32* @MAP_SHARED
%47 = tail call i8* @mmap(i32* null, i32 %42, i32 %45, i32 %46, i32 %12, i32 1073758208)
%48 = bitcast i8* %47 to i32*
%49 = bitcast i8* %30 to i32*
%50 = getelementptr i8, i8* %30, i64 4
%51 = bitcast i8* %50 to i32*
%52 = getelementptr i8, i8* %30, i64 8
%53 = bitcast i8* %52 to i32*
%54 = getelementptr i8, i8* %23, i64 12
%55 = bitcast i8* %54 to i32*
%56 = getelementptr i8, i8* %30, i64 1
%57 = bitcast i8* %56 to i32*
%58 = getelementptr i8, i8* %30, i64 12
%59 = bitcast i8* %58 to i32*
%60 = getelementptr i8, i8* %30, i64 16
%61 = bitcast i8* %60 to i32*
%62 = load volatile i32, i32* %49
%63 = or i32 %62, 1
store volatile i32 %63, i32* %49
%64 = load volatile i32, i32* %49
%65 = and i32 %64, -3
store volatile i32 %65, i32* %49
%66 = load volatile i32, i32* %57
%67 = or i32 %66, 1
store volatile i32 %67, i32* %57
%68 = tail call i64 @floor(double 0x41A374BC6B7EF9DB)
%69 = trunc i64 %68 to i32
store volatile i32 %69, i32* %51
store volatile i32 250, i32* %53
%70 = tail call i64 @floor(double 0x41A374BC6B7EF9DB)
%71 = trunc i64 %70 to i32
store volatile i32 %71, i32* %59
store volatile i32 16382, i32* %61
%72 = load i32, i32* @AF_INET
%73 = load i32, i32* @SOCK_STREAM
%74 = tail call i32 @socket(i32 %72, i32 %73, i32 0)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %16
%77 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %194
78: ; preds = %16
%79 = load i32, i32* @SOL_SOCKET
%80 = load i32, i32* @SO_REUSEADDR
%81 = call i32 @setsockopt(i32 %74, i32 %79, i32 %80, i8* %10, i32 4)
%82 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%83 = load i32, i32* @AF_INET
%84 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %83, i32* %84
%85 = load i32, i32* @INADDR_ANY
%86 = call i32 @htonl(i32 %85)
%87 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %86, i32* %87
%88 = call i32 @htons(i32 1001)
%89 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %88, i32* %89
%90 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%91 = call i64 @bind(i32 %74, %struct.sockaddr* %90, i32 12)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %78
%94 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %194
95: ; preds = %78
%96 = call i32 @listen(i32 %74, i32 1024)
%97 = call i32 @accept(i32 %74, i32* null, i32* null)
%98 = icmp slt i32 %97, 0
br i1 %98, label %106, label %99
99: ; preds = %95
%100 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 0
br label %101
101: ; preds = %99, %190
%102 = phi i32 [ %97, %99 ], [ %192, %190 ]
%103 = load i32, i32* @MSG_WAITALL
%104 = call i64 @recv(i32 %102, i8* %8, i32 4, i32 %103)
%105 = icmp slt i64 %104, 1
br i1 %105, label %190, label %108
106: ; preds = %190, %95
%107 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %194
108: ; preds = %101, %186
%109 = load i32, i32* %4
%110 = and i32 %109, 268435455
%111 = ashr i32 %109, 28
switch i32 %111, label %186 [
i32 0, label %112
i32 1, label %122
i32 2, label %129
i32 3, label %138
]
112: ; preds = %108
%113 = icmp ugt i32 %110, 60000000
br i1 %113, label %186, label %114
114: ; preds = %112
%115 = sitofp i32 %110 to double
%116 = fdiv double %115, 1.250000e+08
%117 = call double @llvm.fmuladd.f64(double %116, double 0x41D0000000000000, double 5.000000e-01)
%118 = call i64 @floor(double %117)
%119 = trunc i64 %118 to i32
store volatile i32 %119, i32* %51
%120 = call i64 @floor(double %117)
%121 = trunc i64 %120 to i32
store volatile i32 %121, i32* %59
br label %186
122: ; preds = %108
%123 = and i32 %109, 7
switch i32 %123, label %186 [
i32 0, label %124
i32 1, label %125
i32 2, label %126
i32 3, label %127
i32 4, label %128
]
124: ; preds = %122
store volatile i32 2500, i32* %53
br label %186
125: ; preds = %122
store volatile i32 1250, i32* %53
br label %186
126: ; preds = %122
store volatile i32 250, i32* %53
br label %186
127: ; preds = %122
store volatile i32 125, i32* %53
br label %186
128: ; preds = %122
store volatile i32 25, i32* %53
br label %186
129: ; preds = %108
%130 = load volatile i32, i32* %57
%131 = or i32 %130, 1
store volatile i32 %131, i32* %57
%132 = load volatile i32, i32* %57
%133 = and i32 %132, -2
store volatile i32 %133, i32* %57
store volatile i32 0, i32* %48
store volatile i32 98, i32* %48
store volatile i32 49, i32* %48
store volatile i32 0, i32* %48
%134 = call i64 @floor(double 0x41B0000000800000)
%135 = trunc i64 %134 to i32
store volatile i32 %135, i32* %48
store volatile i32 148, i32* %48
store volatile i32 74, i32* %48
store volatile i32 0, i32* %48
%136 = call i64 @floor(double 0x41C0000000400000)
%137 = trunc i64 %136 to i32
store volatile i32 %137, i32* %48
store volatile i32 98, i32* %48
store volatile i32 49, i32* %48
store volatile i32 0, i32* %48
br label %186
138: ; preds = %108
%139 = load volatile i32, i32* %49
%140 = or i32 %139, 1
store volatile i32 %140, i32* %49
%141 = load volatile i32, i32* %49
%142 = and i32 %141, -2
store volatile i32 %142, i32* %49
%143 = load volatile i32, i32* %49
%144 = and i32 %143, -3
store volatile i32 %144, i32* %49
%145 = load volatile i32, i32* %49
%146 = or i32 %145, 2
store volatile i32 %146, i32* %49
br label %147
147: ; preds = %138, %174
%148 = phi i32 [ 0, %138 ], [ %177, %174 ]
%149 = load volatile i32, i32* %55
%150 = icmp slt i32 %149, 20000
br i1 %150, label %151, label %155
151: ; preds = %147, %151
%152 = call i32 @usleep(i32 500)
%153 = load volatile i32, i32* %55
%154 = icmp slt i32 %153, 20000
br i1 %154, label %151, label %155
155: ; preds = %151, %147
br label %156
156: ; preds = %156, %155
%157 = phi i64 [ 0, %155 ], [ %172, %156 ]
%158 = load volatile i32, i32* %39
%159 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 %157
store i32 %158, i32* %159
%160 = add nuw nsw i64 %157, 1
%161 = load volatile i32, i32* %39
%162 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 %160
store i32 %161, i32* %162
%163 = add nuw nsw i64 %157, 2
%164 = load volatile i32, i32* %39
%165 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 %163
store i32 %164, i32* %165
%166 = add nuw nsw i64 %157, 3
%167 = load volatile i32, i32* %39
%168 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 %166
store i32 %167, i32* %168
%169 = add nuw nsw i64 %157, 4
%170 = load volatile i32, i32* %39
%171 = getelementptr inbounds [10000 x i32], [10000 x i32]* %5, i64 0, i64 %169
store i32 %170, i32* %171
%172 = add nuw nsw i64 %157, 5
%173 = icmp eq i64 %172, 10000
br i1 %173, label %174, label %156
174: ; preds = %156
%175 = load i32, i32* @MSG_NOSIGNAL
%176 = call i32 @send(i32 %102, i32* %100, i32 80000, i32 %175)
%177 = add nuw nsw i32 %148, 1
%178 = icmp eq i32 %177, 10
br i1 %178, label %179, label %147
179: ; preds = %174
%180 = load volatile i32, i32* %49
%181 = or i32 %180, 1
store volatile i32 %181, i32* %49
%182 = load volatile i32, i32* %49
%183 = and i32 %182, -3
store volatile i32 %183, i32* %49
%184 = load volatile i32, i32* %57
%185 = or i32 %184, 1
store volatile i32 %185, i32* %57
br label %186
186: ; preds = %114, %129, %179, %108, %122, %128, %127, %126, %125, %124, %112
%187 = load i32, i32* @MSG_WAITALL
%188 = call i64 @recv(i32 %102, i8* %8, i32 4, i32 %187)
%189 = icmp slt i64 %188, 1
br i1 %189, label %190, label %108
190: ; preds = %186, %101
%191 = call i32 @close(i32 %102)
%192 = call i32 @accept(i32 %74, i32* null, i32* null)
%193 = icmp slt i32 %192, 0
br i1 %193, label %106, label %101
194: ; preds = %106, %93, %76, %14
%195 = load i32, i32* @EXIT_FAILURE
ret i32 %195
}