#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 */

/* Type definitions */
typedef int uint64_t;
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int ApplyIndexFunc(int, int);
int StartEndpointSearch(int, int, int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ load_idx();
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void main(int argc, char **argv) {
  int sockfd, portno, n;
  uint64_t buf[140000];
  uint64_t buf2[140000];
  int iter = 0;
  for (int iter = 0; iter < 10000; iter++) {
    printf("DELTA: PASS: %i\n", iter);
    int tot = 0;
    if (iter == 0) {
      load_idx();
    }
    DIR *dir;
    struct dirent *ent;
    dir = opendir("./");
    int fnum;
    int found = 0;
    if (dir != NULL) {
      while ((ent = readdir(dir)) != NULL) {
        if (!strncmp("cl-endpoints-", ent->d_name, 12)) {
          sscanf(ent->d_name, "cl-endpoints-%d.bin", &fnum);
          printf("%s %i\n", ent->d_name, fnum);
          found++;
        } else {
        }
      }
      closedir(dir);
    }
    if (found) {
      char fname[80];
      sprintf(fname, "cl-endpoints-%09d.bin", fnum);
      char dstf[80];
      sprintf(dstf, "cl/cl-endpoints-%09d.bin", fnum);
      FILE *cfile;
      cfile = fopen(fname, "rb");
      int result = fread(buf, 8, 16321, cfile);
      fclose(cfile);
      rename(fname, dstf);
      printf("result=%i\n", result);
      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;
        }
      }
      sprintf(fname, "cl-startpoints-%09d.bin", fnum);
      cfile = fopen(fname, "w");
      fwrite(buf, 8, 16321, cfile);
      fclose(cfile);
    } else {
      sleep(1);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x111820,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x111724(%rbp)
movl   $0x0,-0x111728(%rbp)
cmpl   $0x2710,-0x111728(%rbp)
jge    1586 <main+0x386>
mov    -0x111728(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x11172c(%rbp)
cmpl   $0x0,-0x111728(%rbp)
jne    1268 <main+0x68>
mov    $0x0,%al
call   10f0 <load_idx@plt>
lea    0xda2(%rip),%rdi
call   1070 <opendir@plt>
mov    %rax,-0x111738(%rbp)
movl   $0x0,-0x111748(%rbp)
cmpq   $0x0,-0x111738(%rbp)
je     133e <main+0x13e>
jmp    1298 <main+0x98>
mov    -0x111738(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x111740(%rbp)
cmp    $0x0,%rax
je     1332 <main+0x132>
mov    -0x111740(%rbp),%rax
mov    (%rax),%rsi
lea    0xd4e(%rip),%rdi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1328 <main+0x128>
mov    -0x111740(%rbp),%rax
mov    (%rax),%rdi
lea    0xd38(%rip),%rsi
lea    -0x111744(%rbp),%rdx
call   10c0 <sscanf@plt>
mov    -0x111740(%rbp),%rax
mov    (%rax),%rsi
mov    -0x111744(%rbp),%edx
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x111748(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111748(%rbp)
jmp    132d <main+0x12d>
jmp    132d <main+0x12d>
jmp    1298 <main+0x98>
mov    -0x111738(%rbp),%rdi
call   1090 <closedir@plt>
cmpl   $0x0,-0x111748(%rbp)
je     1563 <main+0x363>
lea    -0x1117a0(%rbp),%rdi
mov    -0x111744(%rbp),%edx
lea    0xce1(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x1117f0(%rbp),%rdi
mov    -0x111744(%rbp),%edx
lea    0xcc5(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x1117a0(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1117f8(%rbp)
lea    -0x88ba0(%rbp),%rdi
mov    -0x1117f8(%rbp),%rcx
mov    $0x8,%esi
mov    $0x3fc1,%edx
call   1040 <fread@plt>
mov    %eax,-0x1117fc(%rbp)
mov    -0x1117f8(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x1117a0(%rbp),%rdi
lea    -0x1117f0(%rbp),%rsi
call   10e0 <rename@plt>
mov    -0x1117fc(%rbp),%esi
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x88ba0(%rbp),%eax
mov    %eax,-0x111800(%rbp)
mov    -0x111800(%rbp),%esi
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x111804(%rbp)
cmpl   $0x28,-0x111804(%rbp)
jge    1502 <main+0x302>
movl   $0x0,-0x111808(%rbp)
cmpl   $0x198,-0x111808(%rbp)
jge    14e9 <main+0x2e9>
movl   $0x0,-0x11180c(%rbp)
movl   $0x0,-0x111810(%rbp)
mov    -0x111808(%rbp),%eax
imul   $0x198,-0x111804(%rbp),%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x111814(%rbp)
movslq -0x111814(%rbp),%rax
mov    -0x88ba0(%rbp,%rax,4),%eax
mov    %eax,-0x111818(%rbp)
mov    -0x111818(%rbp),%edi
mov    -0x11180c(%rbp),%esi
mov    -0x111804(%rbp),%edx
call   10a0 <StartEndpointSearch@plt>
mov    %eax,-0x111810(%rbp)
cmpl   $0x0,-0x111810(%rbp)
je     14c1 <main+0x2c1>
mov    -0x111810(%rbp),%edi
mov    $0x22,%esi
call   1050 <ApplyIndexFunc@plt>
mov    %eax,-0x111810(%rbp)
mov    -0x111810(%rbp),%ecx
movslq -0x111814(%rbp),%rax
mov    %ecx,-0x88ba0(%rbp,%rax,4)
mov    -0x111808(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111808(%rbp)
jmp    142e <main+0x22e>
jmp    14ee <main+0x2ee>
mov    -0x111804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111804(%rbp)
jmp    1417 <main+0x217>
lea    -0x1117a0(%rbp),%rdi
mov    -0x111744(%rbp),%edx
lea    0xb57(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x1117a0(%rbp),%rdi
lea    0xb5c(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1117f8(%rbp)
lea    -0x88ba0(%rbp),%rdi
mov    -0x1117f8(%rbp),%rcx
mov    $0x8,%esi
mov    $0x3fc1,%edx
call   1110 <fwrite@plt>
mov    -0x1117f8(%rbp),%rdi
call   1060 <fclose@plt>
jmp    156d <main+0x36d>
mov    $0x1,%edi
call   1120 <sleep@plt>
jmp    1572 <main+0x372>
mov    -0x111728(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x111728(%rbp)
jmp    1226 <main+0x26>
add    $0x111820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88c38,%rsp
lea    0xde8(%rip),%r12
lea    0xdf5(%rip),%r13
xor    %r15d,%r15d
jmp    1253 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1090 <closedir@plt>
mov    $0x1,%edi
call   1120 <sleep@plt>
add    $0x1,%r15d
cmp    $0x2710,%r15d
je     1478 <main+0x278>
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r15d,%r15d
jne    126c <main+0x6c>
xor    %eax,%eax
call   10f0 <load_idx@plt>
lea    0xd9e(%rip),%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     1238 <main+0x38>
mov    %rax,%r14
mov    %rax,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     1230 <main+0x30>
mov    %rax,%rbp
xor    %ebx,%ebx
jmp    12b0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   10b0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1300 <main+0x100>
mov    0x0(%rbp),%rsi
mov    %r13,%rdi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12a0 <main+0xa0>
mov    0x0(%rbp),%rdi
lea    0xd52(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10c0 <sscanf@plt>
mov    0x0(%rbp),%rsi
mov    0xc(%rsp),%edx
lea    0xd4d(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%ebx
jmp    12a0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1090 <closedir@plt>
test   %ebx,%ebx
je     1238 <main+0x38>
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
lea    0xd1d(%rip),%rsi
call   1100 <sprintf@plt>
mov    0xc(%rsp),%edx
lea    0x60(%rsp),%r12
mov    %r12,%rdi
lea    0xd02(%rip),%rsi
call   1100 <sprintf@plt>
mov    %r14,%rdi
lea    0xd0c(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
lea    0xb0(%rsp),%rdi
mov    $0x8,%esi
mov    $0x3fc1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   10e0 <rename@plt>
lea    0xcd1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0xb0(%rsp),%esi
lea    0xcc5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb0(%rsp),%rbp
xor    %r14d,%r14d
jmp    13d1 <main+0x1d1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
add    $0x660,%rbp
cmp    $0x28,%r14
je     1420 <main+0x220>
mov    $0x1,%r12d
jmp    13f2 <main+0x1f2>
nopl   0x0(%rax)
mov    %ebx,0x0(%rbp,%r12,4)
add    $0x1,%r12
cmp    $0x199,%r12
je     13c0 <main+0x1c0>
mov    0x0(%rbp,%r12,4),%edi
xor    %ebx,%ebx
xor    %esi,%esi
mov    %r14d,%edx
call   10a0 <StartEndpointSearch@plt>
test   %eax,%eax
je     13e0 <main+0x1e0>
mov    %eax,%edi
mov    $0x22,%esi
call   1050 <ApplyIndexFunc@plt>
mov    %eax,%ebx
jmp    13e0 <main+0x1e0>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
lea    0xc3a(%rip),%rsi
call   1100 <sprintf@plt>
mov    %rbx,%rdi
lea    0xc43(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
lea    0xb0(%rsp),%rdi
mov    $0x8,%esi
mov    $0x3fc1,%edx
mov    %rax,%rcx
call   1110 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xb8d(%rip),%r12
jmp    1242 <main+0x42>
add    $0x88c38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [17 x i8] c"DELTA: PASS: %i\0A\00"
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [14 x i8] c"cl-endpoints-\00"
@.str.3 = [20 x i8] c"cl-endpoints-%d.bin\00"
@.str.4 = [7 x i8] c"%s %i\0A\00"
@.str.5 = [22 x i8] c"cl-endpoints-%09d.bin\00"
@.str.6 = [25 x i8] c"cl/cl-endpoints-%09d.bin\00"
@.str.7 = [3 x i8] c"rb\00"
@.str.8 = [11 x i8] c"result=%i\0A\00"
@.str.9 = [9 x i8] c"bnum=%i\0A\00"
@.str.10 = [24 x i8] c"cl-startpoints-%09d.bin\00"
@.str.11 = [2 x i8] c"w\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 [140000 x i32]
%9 = alloca [140000 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca %struct.dirent*
%15 = alloca i32
%16 = alloca i32
%17 = alloca [80 x i8]
%18 = alloca [80 x i8]
%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 i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %10
store i32 0, i32* %11
br label %28
28: ; preds = %148, %2
%29 = load i32, i32* %11
%30 = icmp slt i32 %29, 10000
br i1 %30, label %31, label %151
31: ; preds = %28
%32 = load i32, i32* %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %32)
store i32 0, i32* %12
%34 = load i32, i32* %11
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (...) @load_idx()
br label %38
38: ; preds = %36, %31
%39 = call i32* @opendir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %13
store i32 0, i32* %16
%40 = load i32*, i32** %13
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %70
42: ; preds = %38
br label %43
43: ; preds = %66, %42
%44 = load i32*, i32** %13
%45 = call %struct.dirent* @readdir(i32* %44)
store %struct.dirent* %45, %struct.dirent** %14
%46 = icmp ne %struct.dirent* %45, null
br i1 %46, label %47, label %67
47: ; preds = %43
%48 = load %struct.dirent*, %struct.dirent** %14
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = call i32 @strncmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %50, i32 12)
%52 = icmp ne i32 %51, 0
br i1 %52, label %65, label %53
53: ; preds = %47
%54 = load %struct.dirent*, %struct.dirent** %14
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = call i32 @sscanf(i8* %56, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32* %15)
%58 = load %struct.dirent*, %struct.dirent** %14
%59 = getelementptr inbounds %struct.dirent, %struct.dirent* %58, i32 0, i32 0
%60 = load i8*, i8** %59
%61 = load i32, i32* %15
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %60, i32 %61)
%63 = load i32, i32* %16
%64 = add nsw i32 %63, 1
store i32 %64, i32* %16
br label %66
65: ; preds = %47
br label %66
66: ; preds = %65, %53
br label %43
67: ; preds = %43
%68 = load i32*, i32** %13
%69 = call i32 @closedir(i32* %68)
br label %70
70: ; preds = %67, %38
%71 = load i32, i32* %16
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %145
73: ; preds = %70
%74 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%75 = load i32, i32* %15
%76 = call i32 @sprintf(i8* %74, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %18, i64 0, i64 0
%78 = load i32, i32* %15
%79 = call i32 @sprintf(i8* %77, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %78)
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %81, i32** %19
%82 = getelementptr inbounds [140000 x i32], [140000 x i32]* %8, i64 0, i64 0
%83 = load i32*, i32** %19
%84 = call i32 @fread(i32* %82, i32 8, i32 16321, i32* %83)
store i32 %84, i32* %20
%85 = load i32*, i32** %19
%86 = call i32 @fclose(i32* %85)
%87 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%88 = getelementptr inbounds [80 x i8], [80 x i8]* %18, i64 0, i64 0
%89 = call i32 @rename(i8* %87, i8* %88)
%90 = load i32, i32* %20
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %90)
%92 = getelementptr inbounds [140000 x i32], [140000 x i32]* %8, i64 0, i64 0
%93 = load i32, i32* %92
store i32 %93, i32* %21
%94 = load i32, i32* %21
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %94)
store i32 0, i32* %22
br label %96
96: ; preds = %131, %73
%97 = load i32, i32* %22
%98 = icmp slt i32 %97, 40
br i1 %98, label %99, label %134
99: ; preds = %96
store i32 0, i32* %23
br label %100
100: ; preds = %127, %99
%101 = load i32, i32* %23
%102 = icmp slt i32 %101, 408
br i1 %102, label %103, label %130
103: ; preds = %100
store i32 0, i32* %24
store i32 0, i32* %25
%104 = load i32, i32* %23
%105 = load i32, i32* %22
%106 = mul nsw i32 %105, 408
%107 = add nsw i32 %104, %106
%108 = add nsw i32 %107, 1
store i32 %108, i32* %26
%109 = load i32, i32* %26
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [140000 x i32], [140000 x i32]* %8, i64 0, i64 %110
%112 = load i32, i32* %111
store i32 %112, i32* %27
%113 = load i32, i32* %27
%114 = load i32, i32* %24
%115 = load i32, i32* %22
%116 = call i32 @StartEndpointSearch(i32 %113, i32 %114, i32 %115)
store i32 %116, i32* %25
%117 = load i32, i32* %25
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %103
%120 = load i32, i32* %25
%121 = call i32 @ApplyIndexFunc(i32 %120, i32 34)
store i32 %121, i32* %25
br label %122
122: ; preds = %119, %103
%123 = load i32, i32* %25
%124 = load i32, i32* %26
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [140000 x i32], [140000 x i32]* %8, i64 0, i64 %125
store i32 %123, i32* %126
br label %127
127: ; preds = %122
%128 = load i32, i32* %23
%129 = add nsw i32 %128, 1
store i32 %129, i32* %23
br label %100
130: ; preds = %100
br label %131
131: ; preds = %130
%132 = load i32, i32* %22
%133 = add nsw i32 %132, 1
store i32 %133, i32* %22
br label %96
134: ; preds = %96
%135 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%136 = load i32, i32* %15
%137 = call i32 @sprintf(i8* %135, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %136)
%138 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%139 = call i32* @fopen(i8* %138, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %139, i32** %19
%140 = getelementptr inbounds [140000 x i32], [140000 x i32]* %8, i64 0, i64 0
%141 = load i32*, i32** %19
%142 = call i32 @fwrite(i32* %140, i32 8, i32 16321, i32* %141)
%143 = load i32*, i32** %19
%144 = call i32 @fclose(i32* %143)
br label %147
145: ; preds = %70
%146 = call i32 @sleep(i32 1)
br label %147
147: ; preds = %145, %134
br label %148
148: ; preds = %147
%149 = load i32, i32* %11
%150 = add nsw i32 %149, 1
store i32 %150, i32* %11
br label %28
151: ; preds = %28
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [17 x i8] c"DELTA: PASS: %i\0A\00"
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [14 x i8] c"cl-endpoints-\00"
@.str.3 = [20 x i8] c"cl-endpoints-%d.bin\00"
@.str.4 = [7 x i8] c"%s %i\0A\00"
@.str.5 = [22 x i8] c"cl-endpoints-%09d.bin\00"
@.str.6 = [25 x i8] c"cl/cl-endpoints-%09d.bin\00"
@.str.7 = [3 x i8] c"rb\00"
@.str.8 = [11 x i8] c"result=%i\0A\00"
@.str.9 = [9 x i8] c"bnum=%i\0A\00"
@.str.10 = [24 x i8] c"cl-startpoints-%09d.bin\00"
@.str.11 = [2 x i8] c"w\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [140000 x i32]
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = bitcast [140000 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [140000 x i32], [140000 x i32]* %3, i64 0, i64 0
br label %13
12: ; preds = %88
ret void
13: ; preds = %2, %88
%14 = phi i32 [ 0, %2 ], [ %89, %88 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %14, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (...) @load_idx()
br label %19
19: ; preds = %17, %13
%20 = call i32* @opendir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %86, label %22
22: ; preds = %19
%23 = call %struct.dirent* @readdir(i32* %20)
%24 = icmp eq %struct.dirent* %23, null
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @closedir(i32* %20)
br label %86
27: ; preds = %22, %41
%28 = phi %struct.dirent* [ %43, %41 ], [ %23, %22 ]
%29 = phi i32 [ %42, %41 ], [ 0, %22 ]
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i64 0, i32 0
%31 = load i8*, i8** %30
%32 = call i32 @strncmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %31, i32 12)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %27
%35 = load i8*, i8** %30
%36 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%37 = load i8*, i8** %30
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %37, i32 %38)
%40 = add nsw i32 %29, 1
br label %41
41: ; preds = %27, %34
%42 = phi i32 [ %29, %27 ], [ %40, %34 ]
%43 = call %struct.dirent* @readdir(i32* %20)
%44 = icmp eq %struct.dirent* %43, null
br i1 %44, label %45, label %27
45: ; preds = %41
%46 = call i32 @closedir(i32* %20)
%47 = icmp eq i32 %42, 0
br i1 %47, label %86, label %48
48: ; preds = %45
%49 = load i32, i32* %4
%50 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %4
%52 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %51)
%53 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 @fread(i32* %11, i32 8, i32 16321, i32* %53)
%55 = call i32 @fclose(i32* %53)
%56 = call i32 @rename(i8* %9, i8* %10)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %54)
%58 = load i32, i32* %11
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %48, %70
%61 = phi i64 [ 0, %48 ], [ %71, %70 ]
%62 = mul nuw nsw i64 %61, 408
%63 = trunc i64 %61 to i32
br label %73
64: ; preds = %70
%65 = load i32, i32* %4
%66 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %65)
%67 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%68 = call i32 @fwrite(i32* %11, i32 8, i32 16321, i32* %67)
%69 = call i32 @fclose(i32* %67)
br label %88
70: ; preds = %83
%71 = add nuw nsw i64 %61, 1
%72 = icmp eq i64 %71, 40
br i1 %72, label %64, label %60
73: ; preds = %60, %83
%74 = phi i64 [ 0, %60 ], [ %75, %83 ]
%75 = add nuw nsw i64 %74, 1
%76 = add nuw nsw i64 %75, %62
%77 = getelementptr inbounds [140000 x i32], [140000 x i32]* %3, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = call i32 @StartEndpointSearch(i32 %78, i32 0, i32 %63)
%80 = icmp eq i32 %79, 0
br i1 %80, label %83, label %81
81: ; preds = %73
%82 = call i32 @ApplyIndexFunc(i32 %79, i32 34)
br label %83
83: ; preds = %81, %73
%84 = phi i32 [ %82, %81 ], [ 0, %73 ]
store i32 %84, i32* %77
%85 = icmp eq i64 %75, 408
br i1 %85, label %70, label %73
86: ; preds = %25, %19, %45
%87 = call i32 @sleep(i32 1)
br label %88
88: ; preds = %86, %64
%89 = add nuw nsw i32 %14, 1
%90 = icmp eq i32 %89, 10000
br i1 %90, label %12, label %13
}