#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 uint64_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ status;
typedef int ssize_t;
typedef int /*<<< orphan*/ magic;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int bind(int, struct sockaddr *, int);
int close(int);
int current_time();
int /*<<< orphan*/ fatal(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int recvfrom(int, void *, int, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/);
int /*<<< orphan*/ send(int, int *, int, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void run_server(int port, uint64_t max_time, uint64_t max_pkts,
                uint64_t max_bytes, bool verbose) {
  struct sockaddr_in addr;
  int fd, cfd, serverfd, status;
  uint64_t now, last_ts, last_seq, preceived, breceived, errors;
  uint64_t start, tot_delay, max_delay, min_delay, last_delay;
  double jitter = 0.0L;
  ssize_t pkt_size = -1, buffer_sz = 1 << 17;
  void *buffer;
  uint64_t magic = 0xdeadbeef;
  buffer = malloc(buffer_sz);
  if (!buffer)
    fatal("malloc", NULL);
  fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (fd == -1)
    fatal("socket", "Unable to create udp socket");
  serverfd = socket(AF_INET, SOCK_STREAM, 0);
  if (serverfd == -1)
    fatal("socket", "Unable to create tcp socket");
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  status = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
  if (status == -1)
    fatal("bind", "Unable to bind to specified port");
  status = 1;
  status =
      setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, &status, sizeof(status));
  if (status == -1)
    fatal("setsockopt", "Unable to set SO_REUSEADDR");
  status = bind(serverfd, (struct sockaddr *)&addr, sizeof(addr));
  if (status == -1)
    fatal("bind", "Unable to bind to specified port");
  status = listen(serverfd, 1);
  if (status == -1)
    fatal("listen", "Unable to receive connections");
  cfd = accept(serverfd, NULL, 0);
  if (cfd == -1)
    fatal("accept", "Unable to receive connection");
  preceived = breceived = errors = 0;
  last_ts = last_seq = start = 0;
  tot_delay = max_delay = 0;
  last_delay = min_delay = -1;
  while (true) {
    uint64_t ts = 0, seq = 0;
    ssize_t received;
    received = recvfrom(fd, buffer, buffer_sz, 0, 0, 0);
    now = current_time();
    if (received >= sizeof(uint64_t))
      ts = ((uint64_t *)buffer)[0];
    if (received >= 2 * sizeof(uint64_t))
      seq = ((uint64_t *)buffer)[1];
    if (pkt_size == -1) {
      pkt_size = received;
      last_ts = ts;
      last_seq = seq;
      start = now;
    } else {
      if (pkt_size != received) {
        errors++;
        fprintf(stderr, "Received packet of invalid size %ld.\n", received);
      } else {
        preceived++;
        breceived += received;
        breceived += (14 + 20 + 8);
        if (ts) {
          if (last_delay >= 0) {
            double delta;
            if (last_delay > now - ts)
              delta = last_delay - (now - ts);
            else
              delta = (now - ts) - last_delay;
            jitter += (delta - jitter) / 16.0;
          }
          last_delay = now - ts;
          tot_delay += last_delay;
          if (last_delay < min_delay)
            min_delay = last_delay;
          if (last_delay > max_delay)
            max_delay = last_delay;
        }
        if ((ts && ts <= last_ts) || (seq && seq <= last_seq)) {
          errors++;
          fprintf(stderr, "Packet received out of order.\n");
        }
        last_ts = ts;
        last_seq = seq;
      }
      if ((max_pkts && preceived + errors >= max_pkts) ||
          (max_time && now - start >= max_time) ||
          (max_bytes && breceived >= max_bytes))
        break;
    }
  }
  free(buffer);
  send(cfd, &magic, sizeof(magic), 0);
  status = close(cfd);
  if (status == -1)
    fatal("close", "Unable to close socket");
  status = close(serverfd);
  if (status == -1)
    fatal("close", "Unable to close socket");
  if (verbose) {
    printf("Received: %ld bytes %ld packets (size %ld/%ld) %ld errors.\n",
           breceived, preceived, pkt_size + (14 + 20 + 8), pkt_size, errors);
    printf("Delay: %ld/%ld/%ld (min/avg/max). Jitter: %lf. Time: %ld us\n",
           min_delay, tot_delay / preceived, max_delay, jitter, now - start);
    printf("Bandwidth: %ld bit/s.\n",
           (long)(1.0L * (breceived * 8000000) / (now - start)));
  } else {
    printf("brx:%ld prx:%ld pksz:%ld plsz:%ld err:%ld ", breceived, preceived,
           pkt_size + (14 + 20 + 8), pkt_size, errors);
    printf("mind:%ld avgd:%ld maxd:%ld jit:%lf time:%ld ", min_delay,
           tot_delay / preceived, max_delay, jitter, now - start);
  }
  status = close(fd);
  if (status == -1)
    fatal("close", "Unable to close socket");
}


x86 assembly (clang, -O0):
<run_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0xffffffff,-0x6c(%rbp)
movl   $0x20000,-0x70(%rbp)
movl   $0xdeadbeef,-0x7c(%rbp)
mov    -0x70(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    125f <run_server+0x5f>
lea    0xdb2(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1110 <fatal@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1298 <run_server+0x98>
lea    0xeab(%rip),%rdi
lea    0xd7c(%rip),%rsi
call   1110 <fatal@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    12d1 <run_server+0xd1>
lea    0xe72(%rip),%rdi
lea    0xd5f(%rip),%rsi
call   1110 <fatal@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    132a <run_server+0x12a>
lea    0xd29(%rip),%rdi
lea    0xd27(%rip),%rsi
call   1110 <fatal@plt>
movl   $0x1,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
mov    0x2c6c(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1375 <run_server+0x175>
lea    0xd04(%rip),%rdi
lea    0xd08(%rip),%rsi
call   1110 <fatal@plt>
mov    -0x2c(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    13a6 <run_server+0x1a6>
lea    0xcad(%rip),%rdi
lea    0xcab(%rip),%rsi
call   1110 <fatal@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   10d0 <listen@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    13d3 <run_server+0x1d3>
lea    0xccc(%rip),%rdi
lea    0xccc(%rip),%rsi
call   1110 <fatal@plt>
mov    -0x2c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1100 <accept@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1401 <run_server+0x201>
lea    0xcc3(%rip),%rdi
lea    0xcc3(%rip),%rsi
call   1110 <fatal@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0xffffffff,-0x58(%rbp)
movl   $0xffffffff,-0x5c(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    -0x70(%rbp),%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
call   10e0 <recvfrom@plt>
mov    %eax,-0x88(%rbp)
mov    $0x0,%al
call   10a0 <current_time@plt>
mov    %eax,-0x34(%rbp)
movslq -0x88(%rbp),%rax
cmp    $0x4,%rax
jb     149a <run_server+0x29a>
mov    -0x78(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
movslq -0x88(%rbp),%rax
cmp    $0x8,%rax
jb     14b8 <run_server+0x2b8>
mov    -0x78(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x84(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    14e5 <run_server+0x2e5>
mov    -0x88(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x80(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    16a4 <run_server+0x4a4>
mov    -0x6c(%rbp),%eax
cmp    -0x88(%rbp),%eax
je     151f <run_server+0x31f>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    0x2abc(%rip),%rax
mov    (%rax),%edi
mov    -0x88(%rbp),%edx
lea    0xbc9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    1652 <run_server+0x452>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x88(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x2a,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x80(%rbp)
je     15f1 <run_server+0x3f1>
cmpl   $0x0,-0x5c(%rbp)
jl     15b6 <run_server+0x3b6>
mov    -0x5c(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    -0x80(%rbp),%ecx
cmp    %ecx,%eax
jle    157e <run_server+0x37e>
mov    -0x5c(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    -0x80(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    1593 <run_server+0x393>
mov    -0x34(%rbp),%eax
sub    -0x80(%rbp),%eax
sub    -0x5c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
subsd  -0x68(%rbp),%xmm0
movsd  0xa58(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x80(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    15da <run_server+0x3da>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    15ec <run_server+0x3ec>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    15f1 <run_server+0x3f1>
cmpl   $0x0,-0x80(%rbp)
je     1607 <run_server+0x407>
mov    -0x80(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    1623 <run_server+0x423>
cmpl   $0x0,-0x84(%rbp)
je     1643 <run_server+0x443>
mov    -0x84(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1643 <run_server+0x443>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    0x298d(%rip),%rax
mov    (%rax),%edi
lea    0xac6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x80(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     166b <run_server+0x46b>
mov    -0x40(%rbp),%eax
add    -0x48(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    169a <run_server+0x49a>
cmpl   $0x0,-0x8(%rbp)
je     1684 <run_server+0x484>
mov    -0x34(%rbp),%eax
sub    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    169a <run_server+0x49a>
cmpl   $0x0,-0x10(%rbp)
je     169f <run_server+0x49f>
mov    -0x44(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     169f <run_server+0x49f>
jmp    16a9 <run_server+0x4a9>
jmp    16a4 <run_server+0x4a4>
jmp    1447 <run_server+0x247>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%edi
lea    -0x7c(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    16ed <run_server+0x4ed>
lea    0xa40(%rip),%rdi
lea    0xa3f(%rip),%rsi
call   1110 <fatal@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1715 <run_server+0x515>
lea    0xa18(%rip),%rdi
lea    0xa17(%rip),%rsi
call   1110 <fatal@plt>
cmpl   $0x0,-0x14(%rbp)
je     17e1 <run_server+0x5e1>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x6c(%rbp),%r8d
mov    %r8d,%ecx
add    $0x2a,%ecx
mov    -0x48(%rbp),%r9d
lea    0xa04(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x58(%rbp),%esi
mov    -0x50(%rbp),%eax
mov    -0x40(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x54(%rbp),%ecx
movsd  -0x68(%rbp),%xmm0
mov    -0x34(%rbp),%r8d
mov    -0x4c(%rbp),%eax
sub    %eax,%r8d
lea    0xa12(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x44(%rbp),%eax
imul   $0x7a1200,%eax,%eax
mov    %eax,-0x9c(%rbp)
fildl  -0x9c(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0xa0(%rbp)
fildl  -0xa0(%rbp)
fdivrp %st,%st(1)
fnstcw -0xa2(%rbp)
movzwl -0xa2(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0xa4(%rbp)
fldcw  -0xa4(%rbp)
fistpll -0x98(%rbp)
fldcw  -0xa2(%rbp)
mov    -0x98(%rbp),%rax
mov    %eax,%esi
lea    0x9e2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    182d <run_server+0x62d>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x6c(%rbp),%ecx
add    $0x2a,%ecx
mov    -0x6c(%rbp),%r8d
mov    -0x48(%rbp),%r9d
lea    0x9d2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%esi
mov    -0x50(%rbp),%eax
cltd
idivl  -0x40(%rbp)
mov    %eax,%edx
mov    -0x54(%rbp),%ecx
movsd  -0x68(%rbp),%xmm0
mov    -0x34(%rbp),%r8d
sub    -0x4c(%rbp),%r8d
lea    0x9d3(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    1855 <run_server+0x655>
lea    0x8d8(%rip),%rdi
lea    0x8d7(%rip),%rsi
call   1110 <fatal@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r8d,0x64(%rsp)
mov    %ecx,0x40(%rsp)
mov    %edx,0x48(%rsp)
mov    %esi,0x44(%rsp)
mov    %edi,%r14d
movl   $0xdeadbeef,0x74(%rsp)
de
mov    $0x20000,%edi
call   10c0 <malloc@plt>
mov    %rax,0x88(%rsp)
test   %rax,%rax
jne    1252 <run_server+0x52>
lea    0xdbd(%rip),%rdi
xor    %esi,%esi
call   1110 <fatal@plt>
mov    0x2d87(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,0x28(%rsp)
cmp    $0xffffffff,%eax
jne    1287 <run_server+0x87>
lea    0xebc(%rip),%rdi
lea    0xd8d(%rip),%rsi
call   1110 <fatal@plt>
mov    (%rbx),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    12b3 <run_server+0xb3>
lea    0xe90(%rip),%rdi
lea    0xd7d(%rip),%rsi
call   1110 <fatal@plt>
mov    (%rbx),%eax
mov    %eax,0x80(%rsp)
mov    %r14d,%edi
call   1050 <htons@plt>
mov    %eax,0x7c(%rsp)
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x78(%rsp)
lea    0x78(%rsp),%rsi
mov    0x28(%rsp),%edi
mov    $0xc,%edx
call   10f0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1305 <run_server+0x105>
lea    0xd4e(%rip),%rdi
lea    0xd4c(%rip),%rsi
call   1110 <fatal@plt>
movl   $0x1,0x8(%rsp)
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
mov    0x2c93(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    134d <run_server+0x14d>
lea    0xd2c(%rip),%rdi
lea    0xd30(%rip),%rsi
call   1110 <fatal@plt>
lea    0x78(%rsp),%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    137a <run_server+0x17a>
lea    0xcd9(%rip),%rdi
lea    0xcd7(%rip),%rsi
call   1110 <fatal@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   10d0 <listen@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    13a2 <run_server+0x1a2>
lea    0xcfd(%rip),%rdi
lea    0xcfd(%rip),%rsi
call   1110 <fatal@plt>
mov    %ebp,0x60(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
mov    %eax,0x5c(%rsp)
cmp    $0xffffffff,%eax
jne    13cd <run_server+0x1cd>
lea    0xcf7(%rip),%rdi
lea    0xcf7(%rip),%rsi
call   1110 <fatal@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x50(%rsp)
movl   $0xffffffff,0x18(%rsp)
ff
xor    %eax,%eax
mov    %rax,0x30(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %r15d,%r15d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0xffffffff,0x1c(%rsp)
ff
mov    $0xffffffff,%r14d
xor    %eax,%eax
mov    %rax,0x38(%rsp)
xor    %ebx,%ebx
xor    %ebp,%ebp
mov    0x88(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%r8d
mov    %r14d,%r15d
jmp    144e <run_server+0x24e>
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    %r14,%rcx
mov    %r12,%r14
cmp    $0xffffffff,%r14d
jne    14a0 <run_server+0x2a0>
mov    %ebp,%r13d
mov    %ebx,0x4c(%rsp)
mov    %r15d,%r12d
mov    %r8d,0x68(%rsp)
xor    %ebx,%ebx
mov    0x28(%rsp),%edi
mov    %rcx,%r14
mov    %rcx,%rsi
mov    $0x20000,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10e0 <recvfrom@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   10a0 <current_time@plt>
mov    %eax,%r8d
cmp    $0x4,%r15d
jb     1440 <run_server+0x240>
mov    (%r14),%ebp
cmp    $0x8,%r15d
mov    %r14,%rcx
jb     1445 <run_server+0x245>
mov    0x4(%rcx),%ebx
jmp    1445 <run_server+0x245>
nop
cmp    %r15d,%r14d
jne    1540 <run_server+0x340>
mov    0x38(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x38(%rsp)
mov    0x30(%rsp),%rax
add    %r14d,%eax
add    $0x2a,%eax
mov    %rax,0x30(%rsp)
test   %ebp,%ebp
mov    0x1c(%rsp),%ecx
je     1576 <run_server+0x376>
mov    %r8d,%r15d
sub    %ebp,%r15d
test   %ecx,%ecx
js     1509 <run_server+0x309>
mov    %ecx,%eax
sub    %r15d,%eax
neg    %eax
sub    %r15d,%ecx
cmovle %eax,%ecx
cvtsi2sd %ecx,%xmm0
movsd  0x50(%rsp),%xmm1
subsd  %xmm1,%xmm0
mulsd  0xb01(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
mov    0xc(%rsp),%eax
add    %r15d,%eax
mov    %eax,0xc(%rsp)
mov    0x18(%rsp),%eax
cmp    %eax,%r15d
cmovl  %r15d,%eax
mov    %eax,0x18(%rsp)
mov    0x14(%rsp),%eax
cmp    %eax,%r15d
cmovg  %r15d,%eax
mov    %eax,0x14(%rsp)
cmp    %r13d,%ebp
jle    1583 <run_server+0x383>
test   %ebx,%ebx
jne    157d <run_server+0x37d>
jmp    15ad <run_server+0x3ad>
nopl   (%rax)
mov    0x20(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x20(%rsp)
mov    0x2a6c(%rip),%rax
mov    (%rax),%edi
lea    0xb7f(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
mov    %r8d,%ebp
call   10b0 <fprintf@plt>
mov    %ebp,%r8d
mov    0x4c(%rsp),%ebx
mov    %r13d,%ebp
jmp    15b2 <run_server+0x3b2>
mov    %ecx,%r15d
test   %ebx,%ebx
je     15ad <run_server+0x3ad>
cmp    0x4c(%rsp),%ebx
jg     15ad <run_server+0x3ad>
mov    0x20(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x20(%rsp)
mov    0x2a29(%rip),%rax
mov    (%rax),%edi
lea    0xb62(%rip),%rsi
xor    %eax,%eax
mov    %r8d,%r12d
call   10b0 <fprintf@plt>
mov    %r12d,%r8d
mov    %r15d,0x1c(%rsp)
cmpl   $0x0,0x48(%rsp)
mov    0x88(%rsp),%rcx
mov    0x68(%rsp),%r15d
je     15d8 <run_server+0x3d8>
mov    0x38(%rsp),%rax
mov    0x20(%rsp),%rdx
add    %edx,%eax
cmp    0x48(%rsp),%eax
jge    1605 <run_server+0x405>
cmpl   $0x0,0x44(%rsp)
je     15eb <run_server+0x3eb>
mov    %r8d,%eax
sub    %r15d,%eax
cmp    0x44(%rsp),%eax
jge    1605 <run_server+0x405>
cmpl   $0x0,0x40(%rsp)
je     1430 <run_server+0x230>
mov    0x30(%rsp),%rax
cmp    0x40(%rsp),%eax
jl     1430 <run_server+0x230>
mov    %r8d,%ebp
mov    %rcx,%rdi
call   1030 <free@plt>
lea    0x74(%rsp),%rsi
mov    0x5c(%rsp),%ebx
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    164a <run_server+0x44a>
lea    0xae3(%rip),%rdi
lea    0xae2(%rip),%rsi
call   1110 <fatal@plt>
mov    0x60(%rsp),%edi
call   1090 <close@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    166f <run_server+0x46f>
lea    0xabe(%rip),%rdi
lea    0xabd(%rip),%rsi
call   1110 <fatal@plt>
lea    0x2a(%r14),%ecx
cmpl   $0x0,0x64(%rsp)
je     1720 <run_server+0x520>
lea    0xab9(%rip),%rdi
mov    %r14,%r8
mov    0x30(%rsp),%r14
mov    %r14d,%esi
mov    0x38(%rsp),%rbx
mov    %ebx,%edx
mov    0x20(%rsp),%r9
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%eax
cltd
idiv   %ebx
mov    %ebp,%ebx
sub    %r15d,%ebx
lea    0xac4(%rip),%rdi
mov    0x18(%rsp),%esi
mov    %eax,%edx
mov    0x14(%rsp),%ecx
movsd  0x50(%rsp),%xmm0
mov    %ebx,%r8d
mov    $0x1,%al
call   1070 <printf@plt>
imul   $0x7a1200,%r14d,%eax
mov    %eax,0x6c(%rsp)
fildl  0x6c(%rsp)
mov    %ebx,0x70(%rsp)
fidivl 0x70(%rsp)
fnstcw 0x12(%rsp)
movzwl 0x12(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x2e(%rsp)
fldcw  0x2e(%rsp)
fistpll 0x90(%rsp)
fldcw  0x12(%rsp)
mov    0x90(%rsp),%esi
lea    0xaa0(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    176d <run_server+0x56d>
lea    0xaa7(%rip),%rdi
mov    0x30(%rsp),%rsi
mov    0x38(%rsp),%rbx
mov    %ebx,%edx
mov    %r14d,%r8d
mov    0x20(%rsp),%r9
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%eax
cltd
idiv   %ebx
mov    %ebp,%r8d
sub    %r15d,%r8d
lea    0xaa3(%rip),%rdi
mov    0x18(%rsp),%esi
mov    %eax,%edx
mov    0x14(%rsp),%ecx
movsd  0x50(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
mov    0x28(%rsp),%edi
call   1090 <close@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    1792 <run_server+0x592>
lea    0x99b(%rip),%rdi
lea    0x99a(%rip),%rsi
call   1110 <fatal@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"malloc\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [28 x i8] c"Unable to create udp socket\00"
@SOCK_STREAM = global i32 0
@.str.3 = [28 x i8] c"Unable to create tcp socket\00"
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [33 x i8] c"Unable to bind to specified port\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.6 = [11 x i8] c"setsockopt\00"
@.str.7 = [27 x i8] c"Unable to set SO_REUSEADDR\00"
@.str.8 = [7 x i8] c"listen\00"
@.str.9 = [30 x i8] c"Unable to receive connections\00"
@.str.10 = [7 x i8] c"accept\00"
@.str.11 = [29 x i8] c"Unable to receive connection\00"
@stderr = global i32 0
@.str.12 = [38 x i8] c"Received packet of invalid size %ld.\0A\00"
@.str.13 = [31 x i8] c"Packet received out of order.\0A\00"
@.str.14 = [6 x i8] c"close\00"
@.str.15 = [23 x i8] c"Unable to close socket\00"
@.str.16 = [60 x i8] c"Received: %ld bytes %ld packets (size %ld/%ld) %ld errors.\0A\00"
@.str.17 = [61 x i8] c"Delay: %ld/%ld/%ld (min/avg/max). Jitter: %lf. Time: %ld us\0A\00"
@.str.18 = [23 x i8] c"Bandwidth: %ld bit/s.\0A\00"
@.str.19 = [43 x i8] c"brx:%ld prx:%ld pksz:%ld plsz:%ld err:%ld \00"
@.str.20 = [45 x i8] c"mind:%ld avgd:%ld maxd:%ld jit:%lf time:%ld \00"
define void @run_server(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%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 i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
%30 = alloca i8*
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %27
store i32 -1, i32* %28
store i32 131072, i32* %29
store i32 -559038737, i32* %31
%36 = load i32, i32* %29
%37 = call i8* @malloc(i32 %36)
store i8* %37, i8** %30
%38 = load i8*, i8** %30
%39 = icmp ne i8* %38, null
br i1 %39, label %42, label %40
40: ; preds = %5
%41 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* null)
br label %42
42: ; preds = %40, %5
%43 = load i32, i32* @AF_INET
%44 = load i32, i32* @SOCK_DGRAM
%45 = call i32 @socket(i32 %43, i32 %44, i32 0)
store i32 %45, i32* %12
%46 = load i32, i32* %12
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
%51 = load i32, i32* @AF_INET
%52 = load i32, i32* @SOCK_STREAM
%53 = call i32 @socket(i32 %51, i32 %52, i32 0)
store i32 %53, i32* %14
%54 = load i32, i32* %14
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %50
%59 = load i32, i32* @AF_INET
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %59, i32* %60
%61 = load i32, i32* %6
%62 = call i32 @htons(i32 %61)
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %62, i32* %63
%64 = load i32, i32* @INADDR_ANY
%65 = call i32 @htonl(i32 %64)
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%67 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %66, i32 0, i32 0
store i32 %65, i32* %67
%68 = load i32, i32* %12
%69 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%70 = call i32 @bind(i32 %68, %struct.sockaddr* %69, i32 12)
store i32 %70, i32* %15
%71 = load i32, i32* %15
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %58
%74 = call i32 @fatal(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %73, %58
store i32 1, i32* %15
%76 = load i32, i32* %14
%77 = load i32, i32* @SOL_SOCKET
%78 = load i32, i32* @SO_REUSEADDR
%79 = call i32 @setsockopt(i32 %76, i32 %77, i32 %78, i32* %15, i32 4)
store i32 %79, i32* %15
%80 = load i32, i32* %15
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %84
82: ; preds = %75
%83 = call i32 @fatal(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %84
84: ; preds = %82, %75
%85 = load i32, i32* %14
%86 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%87 = call i32 @bind(i32 %85, %struct.sockaddr* %86, i32 12)
store i32 %87, i32* %15
%88 = load i32, i32* %15
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %92
90: ; preds = %84
%91 = call i32 @fatal(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %84
%93 = load i32, i32* %14
%94 = call i32 @listen(i32 %93, i32 1)
store i32 %94, i32* %15
%95 = load i32, i32* %15
%96 = icmp eq i32 %95, -1
br i1 %96, label %97, label %99
97: ; preds = %92
%98 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
br label %99
99: ; preds = %97, %92
%100 = load i32, i32* %14
%101 = call i32 @accept(i32 %100, i32* null, i32 0)
store i32 %101, i32* %13
%102 = load i32, i32* %13
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %106
106: ; preds = %104, %99
store i32 0, i32* %21
store i32 0, i32* %20
store i32 0, i32* %19
store i32 0, i32* %22
store i32 0, i32* %18
store i32 0, i32* %17
store i32 0, i32* %24
store i32 0, i32* %23
store i32 -1, i32* %25
store i32 -1, i32* %26
br label %107
107: ; preds = %106, %256
store i32 0, i32* %32
store i32 0, i32* %33
%108 = load i32, i32* %12
%109 = load i8*, i8** %30
%110 = load i32, i32* %29
%111 = call i32 @recvfrom(i32 %108, i8* %109, i32 %110, i32 0, i32 0, i32 0)
store i32 %111, i32* %34
%112 = call i32 (...) @current_time()
store i32 %112, i32* %16
%113 = load i32, i32* %34
%114 = sext i32 %113 to i64
%115 = icmp uge i64 %114, 4
br i1 %115, label %116, label %121
116: ; preds = %107
%117 = load i8*, i8** %30
%118 = bitcast i8* %117 to i32*
%119 = getelementptr inbounds i32, i32* %118, i64 0
%120 = load i32, i32* %119
store i32 %120, i32* %32
br label %121
121: ; preds = %116, %107
%122 = load i32, i32* %34
%123 = sext i32 %122 to i64
%124 = icmp uge i64 %123, 8
br i1 %124, label %125, label %130
125: ; preds = %121
%126 = load i8*, i8** %30
%127 = bitcast i8* %126 to i32*
%128 = getelementptr inbounds i32, i32* %127, i64 1
%129 = load i32, i32* %128
store i32 %129, i32* %33
br label %130
130: ; preds = %125, %121
%131 = load i32, i32* %28
%132 = icmp eq i32 %131, -1
br i1 %132, label %133, label %138
133: ; preds = %130
%134 = load i32, i32* %34
store i32 %134, i32* %28
%135 = load i32, i32* %32
store i32 %135, i32* %17
%136 = load i32, i32* %33
store i32 %136, i32* %18
%137 = load i32, i32* %16
store i32 %137, i32* %22
br label %256
138: ; preds = %130
%139 = load i32, i32* %28
%140 = load i32, i32* %34
%141 = icmp ne i32 %139, %140
br i1 %141, label %142, label %148
142: ; preds = %138
%143 = load i32, i32* %21
%144 = add nsw i32 %143, 1
store i32 %144, i32* %21
%145 = load i32, i32* @stderr
%146 = load i32, i32* %34
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i32 %146)
br label %229
148: ; preds = %138
%149 = load i32, i32* %19
%150 = add nsw i32 %149, 1
store i32 %150, i32* %19
%151 = load i32, i32* %34
%152 = load i32, i32* %20
%153 = add nsw i32 %152, %151
store i32 %153, i32* %20
%154 = load i32, i32* %20
%155 = add nsw i32 %154, 42
store i32 %155, i32* %20
%156 = load i32, i32* %32
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %207
158: ; preds = %148
%159 = load i32, i32* %26
%160 = icmp sge i32 %159, 0
br i1 %160, label %161, label %188
161: ; preds = %158
%162 = load i32, i32* %26
%163 = load i32, i32* %16
%164 = load i32, i32* %32
%165 = sub nsw i32 %163, %164
%166 = icmp sgt i32 %162, %165
br i1 %166, label %167, label %174
167: ; preds = %161
%168 = load i32, i32* %26
%169 = load i32, i32* %16
%170 = load i32, i32* %32
%171 = sub nsw i32 %169, %170
%172 = sub nsw i32 %168, %171
%173 = sitofp i32 %172 to double
store double %173, double* %35
br label %181
174: ; preds = %161
%175 = load i32, i32* %16
%176 = load i32, i32* %32
%177 = sub nsw i32 %175, %176
%178 = load i32, i32* %26
%179 = sub nsw i32 %177, %178
%180 = sitofp i32 %179 to double
store double %180, double* %35
br label %181
181: ; preds = %174, %167
%182 = load double, double* %35
%183 = load double, double* %27
%184 = fsub double %182, %183
%185 = fdiv double %184, 1.600000e+01
%186 = load double, double* %27
%187 = fadd double %186, %185
store double %187, double* %27
br label %188
188: ; preds = %181, %158
%189 = load i32, i32* %16
%190 = load i32, i32* %32
%191 = sub nsw i32 %189, %190
store i32 %191, i32* %26
%192 = load i32, i32* %26
%193 = load i32, i32* %23
%194 = add nsw i32 %193, %192
store i32 %194, i32* %23
%195 = load i32, i32* %26
%196 = load i32, i32* %25
%197 = icmp slt i32 %195, %196
br i1 %197, label %198, label %200
198: ; preds = %188
%199 = load i32, i32* %26
store i32 %199, i32* %25
br label %200
200: ; preds = %198, %188
%201 = load i32, i32* %26
%202 = load i32, i32* %24
%203 = icmp sgt i32 %201, %202
br i1 %203, label %204, label %206
204: ; preds = %200
%205 = load i32, i32* %26
store i32 %205, i32* %24
br label %206
206: ; preds = %204, %200
br label %207
207: ; preds = %206, %148
%208 = load i32, i32* %32
%209 = icmp ne i32 %208, 0
br i1 %209, label %210, label %214
210: ; preds = %207
%211 = load i32, i32* %32
%212 = load i32, i32* %17
%213 = icmp sle i32 %211, %212
br i1 %213, label %221, label %214
214: ; preds = %210, %207
%215 = load i32, i32* %33
%216 = icmp ne i32 %215, 0
br i1 %216, label %217, label %226
217: ; preds = %214
%218 = load i32, i32* %33
%219 = load i32, i32* %18
%220 = icmp sle i32 %218, %219
br i1 %220, label %221, label %226
221: ; preds = %217, %210
%222 = load i32, i32* %21
%223 = add nsw i32 %222, 1
store i32 %223, i32* %21
%224 = load i32, i32* @stderr
%225 = call i32 (i32, i8*, ...) @fprintf(i32 %224, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %226
226: ; preds = %221, %217, %214
%227 = load i32, i32* %32
store i32 %227, i32* %17
%228 = load i32, i32* %33
store i32 %228, i32* %18
br label %229
229: ; preds = %226, %142
%230 = load i32, i32* %8
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %238
232: ; preds = %229
%233 = load i32, i32* %19
%234 = load i32, i32* %21
%235 = add nsw i32 %233, %234
%236 = load i32, i32* %8
%237 = icmp sge i32 %235, %236
br i1 %237, label %254, label %238
238: ; preds = %232, %229
%239 = load i32, i32* %7
%240 = icmp ne i32 %239, 0
br i1 %240, label %241, label %247
241: ; preds = %238
%242 = load i32, i32* %16
%243 = load i32, i32* %22
%244 = sub nsw i32 %242, %243
%245 = load i32, i32* %7
%246 = icmp sge i32 %244, %245
br i1 %246, label %254, label %247
247: ; preds = %241, %238
%248 = load i32, i32* %9
%249 = icmp ne i32 %248, 0
br i1 %249, label %250, label %255
250: ; preds = %247
%251 = load i32, i32* %20
%252 = load i32, i32* %9
%253 = icmp sge i32 %251, %252
br i1 %253, label %254, label %255
254: ; preds = %250, %241, %232
br label %257
255: ; preds = %250, %247
br label %256
256: ; preds = %255, %133
br label %107
257: ; preds = %254
%258 = load i8*, i8** %30
%259 = call i32 @free(i8* %258)
%260 = load i32, i32* %13
%261 = call i32 @send(i32 %260, i32* %31, i32 4, i32 0)
%262 = load i32, i32* %13
%263 = call i32 @close(i32 %262)
store i32 %263, i32* %15
%264 = load i32, i32* %15
%265 = icmp eq i32 %264, -1
br i1 %265, label %266, label %268
266: ; preds = %257
%267 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %268
268: ; preds = %266, %257
%269 = load i32, i32* %14
%270 = call i32 @close(i32 %269)
store i32 %270, i32* %15
%271 = load i32, i32* %15
%272 = icmp eq i32 %271, -1
br i1 %272, label %273, label %275
273: ; preds = %268
%274 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %275
275: ; preds = %273, %268
%276 = load i32, i32* %10
%277 = icmp ne i32 %276, 0
br i1 %277, label %278, label %308
278: ; preds = %275
%279 = load i32, i32* %20
%280 = load i32, i32* %19
%281 = load i32, i32* %28
%282 = add nsw i32 %281, 42
%283 = load i32, i32* %28
%284 = load i32, i32* %21
%285 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0), i32 %279, i32 %280, i32 %282, i32 %283, i32 %284)
%286 = load i32, i32* %25
%287 = load i32, i32* %23
%288 = load i32, i32* %19
%289 = sdiv i32 %287, %288
%290 = load i32, i32* %24
%291 = load double, double* %27
%292 = load i32, i32* %16
%293 = load i32, i32* %22
%294 = sub nsw i32 %292, %293
%295 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.17, i64 0, i64 0), i32 %286, i32 %289, i32 %290, double %291, i32 %294)
%296 = load i32, i32* %20
%297 = mul nsw i32 %296, 8000000
%298 = sitofp i32 %297 to x86_fp80
%299 = fmul x86_fp80 0xK3FFF8000000000000000, %298
%300 = load i32, i32* %16
%301 = load i32, i32* %22
%302 = sub nsw i32 %300, %301
%303 = sitofp i32 %302 to x86_fp80
%304 = fdiv x86_fp80 %299, %303
%305 = fptosi x86_fp80 %304 to i64
%306 = trunc i64 %305 to i32
%307 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %306)
br label %326
308: ; preds = %275
%309 = load i32, i32* %20
%310 = load i32, i32* %19
%311 = load i32, i32* %28
%312 = add nsw i32 %311, 42
%313 = load i32, i32* %28
%314 = load i32, i32* %21
%315 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0), i32 %309, i32 %310, i32 %312, i32 %313, i32 %314)
%316 = load i32, i32* %25
%317 = load i32, i32* %23
%318 = load i32, i32* %19
%319 = sdiv i32 %317, %318
%320 = load i32, i32* %24
%321 = load double, double* %27
%322 = load i32, i32* %16
%323 = load i32, i32* %22
%324 = sub nsw i32 %322, %323
%325 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.20, i64 0, i64 0), i32 %316, i32 %319, i32 %320, double %321, i32 %324)
br label %326
326: ; preds = %308, %278
%327 = load i32, i32* %12
%328 = call i32 @close(i32 %327)
store i32 %328, i32* %15
%329 = load i32, i32* %15
%330 = icmp eq i32 %329, -1
br i1 %330, label %331, label %333
331: ; preds = %326
%332 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %333
333: ; preds = %331, %326
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"malloc\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [28 x i8] c"Unable to create udp socket\00"
@SOCK_STREAM = global i32 0
@.str.3 = [28 x i8] c"Unable to create tcp socket\00"
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [33 x i8] c"Unable to bind to specified port\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.6 = [11 x i8] c"setsockopt\00"
@.str.7 = [27 x i8] c"Unable to set SO_REUSEADDR\00"
@.str.8 = [7 x i8] c"listen\00"
@.str.9 = [30 x i8] c"Unable to receive connections\00"
@.str.10 = [7 x i8] c"accept\00"
@.str.11 = [29 x i8] c"Unable to receive connection\00"
@stderr = global i32 0
@.str.12 = [38 x i8] c"Received packet of invalid size %ld.\0A\00"
@.str.13 = [31 x i8] c"Packet received out of order.\0A\00"
@.str.14 = [6 x i8] c"close\00"
@.str.15 = [23 x i8] c"Unable to close socket\00"
@.str.16 = [60 x i8] c"Received: %ld bytes %ld packets (size %ld/%ld) %ld errors.\0A\00"
@.str.17 = [61 x i8] c"Delay: %ld/%ld/%ld (min/avg/max). Jitter: %lf. Time: %ld us\0A\00"
@.str.18 = [23 x i8] c"Bandwidth: %ld bit/s.\0A\00"
@.str.19 = [43 x i8] c"brx:%ld prx:%ld pksz:%ld plsz:%ld err:%ld \00"
@.str.20 = [45 x i8] c"mind:%ld avgd:%ld maxd:%ld jit:%lf time:%ld \00"
define void @run_server(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i32
%9 = bitcast %struct.sockaddr_in* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = bitcast i32* %8 to i8*
store i32 -559038737, i32* %8
%12 = tail call dereferenceable_or_null(131072) i8* @malloc(i32 131072)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = tail call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* null)
br label %16
16: ; preds = %14, %5
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_DGRAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = tail call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = tail call i32 @socket(i32 %24, i32 %25, i32 0)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = tail call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %23
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %31, i32* %32
%33 = tail call i32 @htons(i32 %0)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %33, i32* %34
%35 = load i32, i32* @INADDR_ANY
%36 = tail call i32 @htonl(i32 %35)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 %36, i32* %37
%38 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%39 = call i32 @bind(i32 %19, %struct.sockaddr* %38, i32 12)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %30
%42 = call i32 @fatal(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %43
43: ; preds = %41, %30
store i32 1, i32* %7
%44 = load i32, i32* @SOL_SOCKET
%45 = load i32, i32* @SO_REUSEADDR
%46 = call i32 @setsockopt(i32 %26, i32 %44, i32 %45, i32* %7, i32 4)
store i32 %46, i32* %7
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 @fatal(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
%51 = call i32 @bind(i32 %26, %struct.sockaddr* %38, i32 12)
store i32 %51, i32* %7
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @fatal(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = call i32 @listen(i32 %26, i32 1)
store i32 %56, i32* %7
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
%61 = call i32 @accept(i32 %26, i32* null, i32 0)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 @fatal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %65
65: ; preds = %63, %60
%66 = bitcast i8* %12 to i32*
%67 = getelementptr inbounds i32, i32* %66, i64 1
%68 = icmp eq i32 %2, 0
%69 = icmp eq i32 %1, 0
%70 = icmp eq i32 %3, 0
br label %71
71: ; preds = %168, %65
%72 = phi i32 [ %151, %168 ], [ 0, %65 ]
%73 = phi i32 [ %152, %168 ], [ 0, %65 ]
%74 = phi i32 [ %85, %168 ], [ 0, %65 ]
%75 = phi i32 [ %153, %168 ], [ 0, %65 ]
%76 = phi i32 [ %154, %168 ], [ 0, %65 ]
%77 = phi i32 [ %155, %168 ], [ -1, %65 ]
%78 = phi i32 [ %156, %168 ], [ -1, %65 ]
%79 = phi double [ %157, %168 ], [ 0.000000e+00, %65 ]
%80 = phi i32 [ %86, %168 ], [ -1, %65 ]
%81 = phi i32 [ %158, %168 ], [ 0, %65 ]
%82 = phi i32 [ %159, %168 ], [ 0, %65 ]
%83 = phi i32 [ %160, %168 ], [ 0, %65 ]
br label %84
84: ; preds = %71, %97
%85 = phi i32 [ %90, %97 ], [ %74, %71 ]
%86 = phi i32 [ %89, %97 ], [ %80, %71 ]
%87 = phi i32 [ %99, %97 ], [ %82, %71 ]
%88 = phi i32 [ %98, %97 ], [ %83, %71 ]
%89 = call i32 @recvfrom(i32 %19, i8* %12, i32 131072, i32 0, i32 0, i32 0)
%90 = call i32 (...) @current_time()
%91 = icmp ugt i32 %89, 3
br i1 %91, label %92, label %97
92: ; preds = %84
%93 = load i32, i32* %66
%94 = icmp ugt i32 %89, 7
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = load i32, i32* %67
br label %97
97: ; preds = %84, %95, %92
%98 = phi i32 [ %93, %95 ], [ %93, %92 ], [ 0, %84 ]
%99 = phi i32 [ %96, %95 ], [ 0, %92 ], [ 0, %84 ]
%100 = icmp eq i32 %86, -1
br i1 %100, label %84, label %101
101: ; preds = %97
%102 = icmp eq i32 %86, %89
br i1 %102, label %107, label %103
103: ; preds = %101
%104 = add nsw i32 %73, 1
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i32 %89)
br label %150
107: ; preds = %101
%108 = add nsw i32 %81, 1
%109 = add i32 %72, 42
%110 = add i32 %109, %86
%111 = icmp eq i32 %98, 0
br i1 %111, label %132, label %112
112: ; preds = %107
%113 = icmp sgt i32 %78, -1
%114 = sub nsw i32 %90, %98
br i1 %113, label %115, label %124
115: ; preds = %112
%116 = icmp sgt i32 %78, %114
%117 = sub nsw i32 %78, %114
%118 = sub nsw i32 %114, %78
%119 = select i1 %116, i32 %117, i32 %118
%120 = sitofp i32 %119 to double
%121 = fsub double %120, %79
%122 = fmul double %121, 6.250000e-02
%123 = fadd double %79, %122
br label %124
124: ; preds = %112, %115
%125 = phi double [ %123, %115 ], [ %79, %112 ]
%126 = add nsw i32 %114, %75
%127 = icmp slt i32 %114, %77
%128 = select i1 %127, i32 %114, i32 %77
%129 = icmp sgt i32 %114, %76
%130 = select i1 %129, i32 %114, i32 %76
%131 = icmp sgt i32 %98, %88
br i1 %131, label %132, label %141
132: ; preds = %107, %124
%133 = phi double [ %125, %124 ], [ %79, %107 ]
%134 = phi i32 [ %114, %124 ], [ %78, %107 ]
%135 = phi i32 [ %128, %124 ], [ %77, %107 ]
%136 = phi i32 [ %130, %124 ], [ %76, %107 ]
%137 = phi i32 [ %126, %124 ], [ %75, %107 ]
%138 = icmp eq i32 %99, 0
%139 = icmp sgt i32 %99, %87
%140 = select i1 %138, i1 true, i1 %139
br i1 %140, label %150, label %141
141: ; preds = %132, %124
%142 = phi double [ %133, %132 ], [ %125, %124 ]
%143 = phi i32 [ %134, %132 ], [ %114, %124 ]
%144 = phi i32 [ %135, %132 ], [ %128, %124 ]
%145 = phi i32 [ %136, %132 ], [ %130, %124 ]
%146 = phi i32 [ %137, %132 ], [ %126, %124 ]
%147 = add nsw i32 %73, 1
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %150
150: ; preds = %132, %141, %103
%151 = phi i32 [ %72, %103 ], [ %110, %141 ], [ %110, %132 ]
%152 = phi i32 [ %104, %103 ], [ %147, %141 ], [ %73, %132 ]
%153 = phi i32 [ %75, %103 ], [ %146, %141 ], [ %137, %132 ]
%154 = phi i32 [ %76, %103 ], [ %145, %141 ], [ %136, %132 ]
%155 = phi i32 [ %77, %103 ], [ %144, %141 ], [ %135, %132 ]
%156 = phi i32 [ %78, %103 ], [ %143, %141 ], [ %134, %132 ]
%157 = phi double [ %79, %103 ], [ %142, %141 ], [ %133, %132 ]
%158 = phi i32 [ %81, %103 ], [ %108, %141 ], [ %108, %132 ]
%159 = phi i32 [ %87, %103 ], [ %99, %141 ], [ %99, %132 ]
%160 = phi i32 [ %88, %103 ], [ %98, %141 ], [ %98, %132 ]
%161 = add nsw i32 %158, %152
%162 = icmp slt i32 %161, %2
%163 = select i1 %68, i1 true, i1 %162
br i1 %163, label %164, label %171
164: ; preds = %150
%165 = sub nsw i32 %90, %85
%166 = icmp slt i32 %165, %1
%167 = select i1 %69, i1 true, i1 %166
br i1 %167, label %168, label %171
168: ; preds = %164
%169 = icmp slt i32 %151, %3
%170 = select i1 %70, i1 true, i1 %169
br i1 %170, label %71, label %171
171: ; preds = %168, %164, %150
%172 = call i32 @free(i8* %12)
%173 = call i32 @send(i32 %61, i32* %8, i32 4, i32 0)
%174 = call i32 @close(i32 %61)
store i32 %174, i32* %7
%175 = icmp eq i32 %174, -1
br i1 %175, label %176, label %178
176: ; preds = %171
%177 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %178
178: ; preds = %176, %171
%179 = call i32 @close(i32 %26)
store i32 %179, i32* %7
%180 = icmp eq i32 %179, -1
br i1 %180, label %181, label %183
181: ; preds = %178
%182 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %183
183: ; preds = %181, %178
%184 = icmp eq i32 %4, 0
%185 = add nsw i32 %86, 42
br i1 %184, label %198, label %186
186: ; preds = %183
%187 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0), i32 %151, i32 %158, i32 %185, i32 %86, i32 %152)
%188 = sdiv i32 %153, %158
%189 = sub nsw i32 %90, %85
%190 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.17, i64 0, i64 0), i32 %155, i32 %188, i32 %154, double %157, i32 %189)
%191 = mul nsw i32 %151, 8000000
%192 = sitofp i32 %191 to x86_fp80
%193 = sitofp i32 %189 to x86_fp80
%194 = fdiv x86_fp80 %192, %193
%195 = fptosi x86_fp80 %194 to i64
%196 = trunc i64 %195 to i32
%197 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %196)
br label %203
198: ; preds = %183
%199 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0), i32 %151, i32 %158, i32 %185, i32 %86, i32 %152)
%200 = sdiv i32 %153, %158
%201 = sub nsw i32 %90, %85
%202 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.20, i64 0, i64 0), i32 %155, i32 %200, i32 %154, double %157, i32 %201)
br label %203
203: ; preds = %198, %186
%204 = call i32 @close(i32 %19)
store i32 %204, i32* %7
%205 = icmp eq i32 %204, -1
br i1 %205, label %206, label %208
206: ; preds = %203
%207 = call i32 @fatal(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
br label %208
208: ; preds = %206, %203
ret void
}