#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serveraddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int ApplyIndexFunc(int, int);
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ SOCK_STREAM;
int StartEndpointSearch(int, int, int);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ load_idx();
int /*<<< orphan*/ printf(char *, ...);
int read(int, int *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(int *, char *);
int strlen(int *);
int write(int, ...);
void main(int argc, char **argv) {
  int sockfd, portno, n;
  struct sockaddr_in serveraddr;
  struct hostent *server;
  uint64_t buf[140000];
  uint64_t buf2[140000];
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  server = gethostbyname("localhost");
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host as\n");
    exit(0);
  }
  bzero((char *)&serveraddr, sizeof(serveraddr));
  serveraddr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serveraddr.sin_addr.s_addr,
        server->h_length);
  serveraddr.sin_port = htons(6666);
  if (connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
    error("ERROR connecting");
  int flags = fcntl(sockfd, F_GETFL, 0);
  fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
  for (int iter = 0; iter < 10000; iter++) {
    printf("DELTA: PASS: %i\n", iter);
    int tot = 0;
    if (iter == 0) {
      load_idx();
    }
    while (tot < 130568) {
      n = read(sockfd, buf + tot / 8, 4096);
      if (n < 0) {
        printf("A\n");
        sleep(1);
        strcpy(buf2, "getdps\n");
        n = write(sockfd, buf2, strlen(buf2));
        if (n < 0) {
          error("ERROR writing to socket");
        }
        tot = 0;
        n = 0;
      }
      tot += n;
      printf("rx tot=%i\n", tot);
      fflush(stdout);
    }
    uint64_t bnum = buf[0];
    printf("bnum=%i\n", bnum);
    for (int tbl = 0; tbl < 40; tbl++) {
      for (int i = 0; i < 408; i++) {
        uint64_t sta = 0;
        uint64_t re = 0;
        int j = i + (tbl * 408) + 1;
        uint64_t tg = buf[j];
        re = StartEndpointSearch(tg, sta, tbl);
        if (re) {
          re = ApplyIndexFunc(re, 34);
        }
        buf[j] = re;
      }
    }
    n = write(sockfd, "retsta", 6);
    tot = 0;
    while (tot < 130568) {
      n = write(sockfd, buf + tot / 8, (130568 - tot));
      tot += n;
      printf("tx tot=%i\n", tot);
      fflush(stdout);
    }
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x111770,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1284 <main+0x44>
lea    0xd81(%rip),%rdi
call   1100 <error@plt>
lea    0xd8a(%rip),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12bb <main+0x7b>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xd70(%rip),%rsi
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1130 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   10f0 <bcopy@plt>
mov    $0x1a0a,%edi
call   1080 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1140 <connect@plt>
cmp    $0x0,%rax
jge    1324 <main+0xe4>
lea    0xd18(%rip),%rdi
call   1100 <error@plt>
mov    -0x14(%rbp),%edi
mov    0x2c8a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x111734(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c81(%rip),%rax
mov    (%rax),%esi
mov    -0x111734(%rbp),%edx
mov    0x2c8a(%rip),%rax
or     (%rax),%edx
call   1040 <fcntl@plt>
movl   $0x0,-0x111738(%rbp)
cmpl   $0x2710,-0x111738(%rbp)
jge    168c <main+0x44c>
mov    -0x111738(%rbp),%esi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x11173c(%rbp)
cmpl   $0x0,-0x111738(%rbp)
jne    13a9 <main+0x169>
mov    $0x0,%al
call   1120 <load_idx@plt>
jmp    13ae <main+0x16e>
cmpl   $0x1fe08,-0x11173c(%rbp)
jge    14ba <main+0x27a>
mov    -0x14(%rbp),%edi
lea    -0x88bb0(%rbp),%rsi
mov    -0x11173c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x1000,%edx
call   10a0 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1484 <main+0x244>
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
lea    -0x111730(%rbp),%rdi
lea    0xc40(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x111764(%rbp)
lea    -0x111730(%rbp),%rax
mov    %rax,-0x111760(%rbp)
lea    -0x111730(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x111764(%rbp),%edi
mov    -0x111760(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1473 <main+0x233>
lea    0xbf6(%rip),%rdi
call   1100 <error@plt>
movl   $0x0,-0x11173c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x11173c(%rbp),%eax
mov    %eax,-0x11173c(%rbp)
mov    -0x11173c(%rbp),%esi
lea    0xbdc(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
jmp    13ae <main+0x16e>
mov    -0x88bb0(%rbp),%eax
mov    %eax,-0x111740(%rbp)
mov    -0x111740(%rbp),%esi
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x0,-0x111744(%rbp)
cmpl   $0x28,-0x111744(%rbp)
jge    15cf <main+0x38f>
movl   $0x0,-0x111748(%rbp)
cmpl   $0x198,-0x111748(%rbp)
jge    15b6 <main+0x376>
movl   $0x0,-0x11174c(%rbp)
movl   $0x0,-0x111750(%rbp)
mov    -0x111748(%rbp),%eax
imul   $0x198,-0x111744(%rbp),%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x111754(%rbp)
movslq -0x111754(%rbp),%rax
mov    -0x88bb0(%rbp,%rax,4),%eax
mov    %eax,-0x111758(%rbp)
mov    -0x111758(%rbp),%edi
mov    -0x11174c(%rbp),%esi
mov    -0x111744(%rbp),%edx
call   10d0 <StartEndpointSearch@plt>
mov    %eax,-0x111750(%rbp)
cmpl   $0x0,-0x111750(%rbp)
je     158e <main+0x34e>
mov    -0x111750(%rbp),%edi
mov    $0x22,%esi
call   1060 <ApplyIndexFunc@plt>
mov    %eax,-0x111750(%rbp)
mov    -0x111750(%rbp),%ecx
movslq -0x111754(%rbp),%rax
mov    %ecx,-0x88bb0(%rbp,%rax,4)
mov    -0x111748(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111748(%rbp)
jmp    14fb <main+0x2bb>
jmp    15bb <main+0x37b>
mov    -0x111744(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111744(%rbp)
jmp    14e4 <main+0x2a4>
mov    -0x14(%rbp),%edi
lea    0xab7(%rip),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x11173c(%rbp)
cmpl   $0x1fe08,-0x11173c(%rbp)
jge    166e <main+0x42e>
mov    -0x14(%rbp),%edi
lea    -0x88bb0(%rbp),%rsi
mov    -0x11173c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x1fe08,%edx
sub    -0x11173c(%rbp),%edx
mov    $0x0,%al
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x11173c(%rbp),%eax
mov    %eax,-0x11173c(%rbp)
mov    -0x11173c(%rbp),%esi
lea    0xa43(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x294e(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
jmp    15f2 <main+0x3b2>
mov    $0x1,%edi
call   1150 <sleep@plt>
mov    -0x111738(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111738(%rbp)
jmp    1367 <main+0x127>
add    $0x111770,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x111728,%rsp
mov    0x2d80(%rip),%r15
mov    (%r15),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    128e <main+0x3e>
lea    0xd77(%rip),%rdi
call   1110 <error@plt>
lea    0xd80(%rip),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
je     1560 <main+0x310>
mov    %rax,%rbp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1120 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rbp),%rsi
lea    0x14(%rsp),%rdi
mov    0x0(%rbp),%edx
call   1100 <memmove@plt>
mov    $0x1a0a,%edi
call   1090 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1150 <connect@plt>
test   %rax,%rax
jns    12ff <main+0xaf>
lea    0xd3d(%rip),%rdi
call   1110 <error@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    0x2caf(%rip),%rcx
mov    (%rcx),%esi
mov    0x2cbe(%rip),%rcx
or     (%rcx),%eax
mov    %r14d,%edi
mov    %eax,%edx
call   1050 <fcntl@plt>
lea    0xd6a(%rip),%r13
lea    0xd1d(%rip),%rbp
lea    0x88ba0(%rsp),%rbx
mov    0x2c65(%rip),%r15
xor    %r12d,%r12d
xchg   %ax,%ax
lea    0xcf1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %r12d,0xc(%rsp)
test   %r12d,%r12d
jne    1372 <main+0x122>
xor    %eax,%eax
call   1130 <load_idx@plt>
xor    %r12d,%r12d
jmp    13ab <main+0x15b>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
add    %eax,%r12d
lea    0xced(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    (%r15),%edi
call   10f0 <fflush@plt>
cmp    $0x1fe08,%r12d
jge    1430 <main+0x1e0>
lea    0x7(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
sar    $0x3,%eax
cltq
lea    (%rsp,%rax,4),%rsi
add    $0x20,%rsi
mov    %r14d,%edi
mov    $0x1000,%edx
call   10b0 <read@plt>
test   %eax,%eax
jns    1382 <main+0x132>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1160 <sleep@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
xor    %r12d,%r12d
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <write@plt>
test   %eax,%eax
jns    1380 <main+0x130>
lea    0xc46(%rip),%rdi
call   1110 <error@plt>
jmp    1380 <main+0x130>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x20(%rsp),%esi
lea    0xc49(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0x20(%rsp),%rbp
xor    %r12d,%r12d
jmp    1461 <main+0x211>
nopl   0x0(%rax)
add    $0x1,%r12
add    $0x660,%rbp
cmp    $0x28,%r12
je     14b0 <main+0x260>
mov    $0x1,%r13d
jmp    1482 <main+0x232>
nopl   0x0(%rax)
mov    %ebx,0x0(%rbp,%r13,4)
add    $0x1,%r13
cmp    $0x199,%r13
je     1450 <main+0x200>
mov    0x0(%rbp,%r13,4),%edi
xor    %ebx,%ebx
xor    %esi,%esi
mov    %r12d,%edx
call   10e0 <StartEndpointSearch@plt>
test   %eax,%eax
je     1470 <main+0x220>
mov    %eax,%edi
mov    $0x22,%esi
call   1070 <ApplyIndexFunc@plt>
mov    %eax,%ebx
jmp    1470 <main+0x220>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    %r14d,%edi
lea    0xbd1(%rip),%rsi
mov    $0x6,%edx
xor    %eax,%eax
call   1060 <write@plt>
lea    0xbc5(%rip),%r12
nop
lea    0x7(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
sar    $0x3,%eax
cltq
lea    (%rsp,%rax,4),%rsi
add    $0x20,%rsi
mov    $0x1fe08,%edx
sub    %ebp,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1060 <write@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    (%r15),%edi
call   10f0 <fflush@plt>
mov    %ebx,%ebp
cmp    $0x1fe08,%ebx
jl     14d0 <main+0x280>
mov    $0x1,%edi
call   1160 <sleep@plt>
mov    0xc(%rsp),%r12d
add    $0x1,%r12d
cmp    $0x2710,%r12d
lea    0xb66(%rip),%r13
lea    0xb19(%rip),%rbp
lea    0x88ba0(%rsp),%rbx
jne    1350 <main+0x100>
add    $0x111728,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
lea    0xaaf(%rip),%rsi
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR opening socket\00"
@.str.1 = [10 x i8] c"localhost\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"ERROR, no such host as\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [17 x i8] c"DELTA: PASS: %i\0A\00"
@.str.5 = [3 x i8] c"A\0A\00"
@.str.6 = [8 x i8] c"getdps\0A\00"
@.str.7 = [24 x i8] c"ERROR writing to socket\00"
@.str.8 = [11 x i8] c"rx tot=%i\0A\00"
@stdout = global i32 0
@.str.9 = [9 x i8] c"bnum=%i\0A\00"
@.str.10 = [7 x i8] c"retsta\00"
@.str.11 = [11 x i8] c"tx tot=%i\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.hostent*
%10 = alloca [140000 x i32]
%11 = alloca [140000 x 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 i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%22 = load i32, i32* @AF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = call i32 @socket(i32 %22, i32 %23, i32 0)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %2
%30 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store %struct.hostent* %30, %struct.hostent** %9
%31 = load %struct.hostent*, %struct.hostent** %9
%32 = icmp eq %struct.hostent* %31, null
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %29
%38 = bitcast %struct.sockaddr_in* %8 to i8*
%39 = call i32 @bzero(i8* %38, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %40, i32* %41
%42 = load %struct.hostent*, %struct.hostent** %9
%43 = getelementptr inbounds %struct.hostent, %struct.hostent* %42, i32 0, i32 1
%44 = load i64, i64* %43
%45 = inttoptr i64 %44 to i8*
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 0
%48 = bitcast i32* %47 to i8*
%49 = load %struct.hostent*, %struct.hostent** %9
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @bcopy(i8* %45, i8* %48, i32 %51)
%53 = call i32 @htons(i32 6666)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %53, i32* %54
%55 = load i32, i32* %5
%56 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%57 = call i64 @connect(i32 %55, %struct.sockaddr* %56, i32 12)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %37
%60 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %37
%62 = load i32, i32* %5
%63 = load i32, i32* @F_GETFL
%64 = call i32 @fcntl(i32 %62, i32 %63, i32 0)
store i32 %64, i32* %12
%65 = load i32, i32* %5
%66 = load i32, i32* @F_SETFL
%67 = load i32, i32* %12
%68 = load i32, i32* @O_NONBLOCK
%69 = or i32 %67, %68
%70 = call i32 @fcntl(i32 %65, i32 %66, i32 %69)
store i32 0, i32* %13
br label %71
71: ; preds = %186, %61
%72 = load i32, i32* %13
%73 = icmp slt i32 %72, 10000
br i1 %73, label %74, label %189
74: ; preds = %71
%75 = load i32, i32* %13
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %75)
store i32 0, i32* %14
%77 = load i32, i32* %13
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = call i32 (...) @load_idx()
br label %81
81: ; preds = %79, %74
br label %82
82: ; preds = %110, %81
%83 = load i32, i32* %14
%84 = icmp slt i32 %83, 130568
br i1 %84, label %85, label %118
85: ; preds = %82
%86 = load i32, i32* %5
%87 = getelementptr inbounds [140000 x i32], [140000 x i32]* %10, i64 0, i64 0
%88 = load i32, i32* %14
%89 = sdiv i32 %88, 8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %87, i64 %90
%92 = call i32 @read(i32 %86, i32* %91, i32 4096)
store i32 %92, i32* %7
%93 = load i32, i32* %7
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %110
95: ; preds = %85
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%97 = call i32 @sleep(i32 1)
%98 = getelementptr inbounds [140000 x i32], [140000 x i32]* %11, i64 0, i64 0
%99 = call i32 @strcpy(i32* %98, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%100 = load i32, i32* %5
%101 = getelementptr inbounds [140000 x i32], [140000 x i32]* %11, i64 0, i64 0
%102 = getelementptr inbounds [140000 x i32], [140000 x i32]* %11, i64 0, i64 0
%103 = call i32 @strlen(i32* %102)
%104 = call i32 (i32, ...) @write(i32 %100, i32* %101, i32 %103)
store i32 %104, i32* %7
%105 = load i32, i32* %7
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %109
107: ; preds = %95
%108 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %109
109: ; preds = %107, %95
store i32 0, i32* %14
store i32 0, i32* %7
br label %110
110: ; preds = %109, %85
%111 = load i32, i32* %7
%112 = load i32, i32* %14
%113 = add nsw i32 %112, %111
store i32 %113, i32* %14
%114 = load i32, i32* %14
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %114)
%116 = load i32, i32* @stdout
%117 = call i32 @fflush(i32 %116)
br label %82
118: ; preds = %82
%119 = getelementptr inbounds [140000 x i32], [140000 x i32]* %10, i64 0, i64 0
%120 = load i32, i32* %119
store i32 %120, i32* %15
%121 = load i32, i32* %15
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %121)
store i32 0, i32* %16
br label %123
123: ; preds = %158, %118
%124 = load i32, i32* %16
%125 = icmp slt i32 %124, 40
br i1 %125, label %126, label %161
126: ; preds = %123
store i32 0, i32* %17
br label %127
127: ; preds = %154, %126
%128 = load i32, i32* %17
%129 = icmp slt i32 %128, 408
br i1 %129, label %130, label %157
130: ; preds = %127
store i32 0, i32* %18
store i32 0, i32* %19
%131 = load i32, i32* %17
%132 = load i32, i32* %16
%133 = mul nsw i32 %132, 408
%134 = add nsw i32 %131, %133
%135 = add nsw i32 %134, 1
store i32 %135, i32* %20
%136 = load i32, i32* %20
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [140000 x i32], [140000 x i32]* %10, i64 0, i64 %137
%139 = load i32, i32* %138
store i32 %139, i32* %21
%140 = load i32, i32* %21
%141 = load i32, i32* %18
%142 = load i32, i32* %16
%143 = call i32 @StartEndpointSearch(i32 %140, i32 %141, i32 %142)
store i32 %143, i32* %19
%144 = load i32, i32* %19
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %130
%147 = load i32, i32* %19
%148 = call i32 @ApplyIndexFunc(i32 %147, i32 34)
store i32 %148, i32* %19
br label %149
149: ; preds = %146, %130
%150 = load i32, i32* %19
%151 = load i32, i32* %20
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [140000 x i32], [140000 x i32]* %10, i64 0, i64 %152
store i32 %150, i32* %153
br label %154
154: ; preds = %149
%155 = load i32, i32* %17
%156 = add nsw i32 %155, 1
store i32 %156, i32* %17
br label %127
157: ; preds = %127
br label %158
158: ; preds = %157
%159 = load i32, i32* %16
%160 = add nsw i32 %159, 1
store i32 %160, i32* %16
br label %123
161: ; preds = %123
%162 = load i32, i32* %5
%163 = call i32 (i32, ...) @write(i32 %162, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 6)
store i32 %163, i32* %7
store i32 0, i32* %14
br label %164
164: ; preds = %167, %161
%165 = load i32, i32* %14
%166 = icmp slt i32 %165, 130568
br i1 %166, label %167, label %184
167: ; preds = %164
%168 = load i32, i32* %5
%169 = getelementptr inbounds [140000 x i32], [140000 x i32]* %10, i64 0, i64 0
%170 = load i32, i32* %14
%171 = sdiv i32 %170, 8
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i32, i32* %169, i64 %172
%174 = load i32, i32* %14
%175 = sub nsw i32 130568, %174
%176 = call i32 (i32, ...) @write(i32 %168, i32* %173, i32 %175)
store i32 %176, i32* %7
%177 = load i32, i32* %7
%178 = load i32, i32* %14
%179 = add nsw i32 %178, %177
store i32 %179, i32* %14
%180 = load i32, i32* %14
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %180)
%182 = load i32, i32* @stdout
%183 = call i32 @fflush(i32 %182)
br label %164
184: ; preds = %164
%185 = call i32 @sleep(i32 1)
br label %186
186: ; preds = %184
%187 = load i32, i32* %13
%188 = add nsw i32 %187, 1
store i32 %188, i32* %13
br label %71
189: ; preds = %71
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR opening socket\00"
@.str.1 = [10 x i8] c"localhost\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"ERROR, no such host as\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [17 x i8] c"DELTA: PASS: %i\0A\00"
@.str.6 = [8 x i8] c"getdps\0A\00"
@.str.7 = [24 x i8] c"ERROR writing to socket\00"
@.str.8 = [11 x i8] c"rx tot=%i\0A\00"
@stdout = global i32 0
@.str.9 = [9 x i8] c"bnum=%i\0A\00"
@.str.10 = [7 x i8] c"retsta\00"
@.str.11 = [11 x i8] c"tx tot=%i\0A\00"
@str = [2 x i8] c"A\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [140000 x i32]
%5 = alloca [140000 x i32]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = bitcast [140000 x i32]* %4 to i8*
%8 = bitcast [140000 x i32]* %5 to i8*
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = tail call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq %struct.hostent* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %15
%23 = call i32 @bzero(i8* %6, i32 12)
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 1
%27 = load i64, i64* %26
%28 = inttoptr i64 %27 to i8*
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%30 = bitcast i32* %29 to i8*
%31 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i32 @htons(i32 6666)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %33, i32* %34
%35 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%36 = call i64 @connect(i32 %11, %struct.sockaddr* %35, i32 12)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %22
%39 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %22
%41 = load i32, i32* @F_GETFL
%42 = call i32 @fcntl(i32 %11, i32 %41, i32 0)
%43 = load i32, i32* @F_SETFL
%44 = load i32, i32* @O_NONBLOCK
%45 = or i32 %44, %42
%46 = call i32 @fcntl(i32 %11, i32 %43, i32 %45)
%47 = getelementptr inbounds [140000 x i32], [140000 x i32]* %5, i64 0, i64 0
%48 = getelementptr inbounds [140000 x i32], [140000 x i32]* %4, i64 0, i64 0
br label %50
49: ; preds = %118
ret void
50: ; preds = %40, %118
%51 = phi i32 [ 0, %40 ], [ %120, %118 ]
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = icmp eq i32 %51, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 (...) @load_idx()
br label %56
56: ; preds = %54, %50
br label %57
57: ; preds = %56, %73
%58 = phi i32 [ %76, %73 ], [ 0, %56 ]
%59 = sdiv i32 %58, 8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [140000 x i32], [140000 x i32]* %4, i64 0, i64 %60
%62 = call i32 @read(i32 %11, i32* %61, i32 4096)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %57
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%66 = call i32 @sleep(i32 1)
%67 = call i32 @strcpy(i32* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 @strlen(i32* %47)
%69 = call i32 (i32, ...) @write(i32 %11, i32* %47, i32 %68)
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %64
%72 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %73
73: ; preds = %64, %71, %57
%74 = phi i32 [ %58, %57 ], [ 0, %71 ], [ 0, %64 ]
%75 = phi i32 [ %62, %57 ], [ 0, %71 ], [ 0, %64 ]
%76 = add nsw i32 %75, %74
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %76)
%78 = load i32, i32* @stdout
%79 = call i32 @fflush(i32 %78)
%80 = icmp slt i32 %76, 130568
br i1 %80, label %57, label %81
81: ; preds = %73
%82 = load i32, i32* %48
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %81, %90
%85 = phi i64 [ 0, %81 ], [ %91, %90 ]
%86 = mul nuw nsw i64 %85, 408
%87 = trunc i64 %85 to i32
br label %93
88: ; preds = %90
%89 = call i32 (i32, ...) @write(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 6)
br label %106
90: ; preds = %103
%91 = add nuw nsw i64 %85, 1
%92 = icmp eq i64 %91, 40
br i1 %92, label %88, label %84
93: ; preds = %84, %103
%94 = phi i64 [ 0, %84 ], [ %95, %103 ]
%95 = add nuw nsw i64 %94, 1
%96 = add nuw nsw i64 %95, %86
%97 = getelementptr inbounds [140000 x i32], [140000 x i32]* %4, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = call i32 @StartEndpointSearch(i32 %98, i32 0, i32 %87)
%100 = icmp eq i32 %99, 0
br i1 %100, label %103, label %101
101: ; preds = %93
%102 = call i32 @ApplyIndexFunc(i32 %99, i32 34)
br label %103
103: ; preds = %101, %93
%104 = phi i32 [ %102, %101 ], [ 0, %93 ]
store i32 %104, i32* %97
%105 = icmp eq i64 %95, 408
br i1 %105, label %90, label %93
106: ; preds = %88, %106
%107 = phi i32 [ 0, %88 ], [ %113, %106 ]
%108 = sdiv i32 %107, 8
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [140000 x i32], [140000 x i32]* %4, i64 0, i64 %109
%111 = sub nsw i32 130568, %107
%112 = call i32 (i32, ...) @write(i32 %11, i32* %110, i32 %111)
%113 = add nsw i32 %112, %107
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i32 %113)
%115 = load i32, i32* @stdout
%116 = call i32 @fflush(i32 %115)
%117 = icmp slt i32 %113, 130568
br i1 %117, label %106, label %118
118: ; preds = %106
%119 = call i32 @sleep(i32 1)
%120 = add nuw nsw i32 %51, 1
%121 = icmp eq i32 %120, 10000
br i1 %121, label %49, label %50
}