#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 /*<<< orphan*/ tmo;
typedef int pid_t;
typedef int /*<<< orphan*/ pid_file;
typedef scalar_t__ int32_t;
typedef scalar_t__ in_port_t;
typedef int /*<<< orphan*/ environment;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close_terminal();
scalar_t__ errno;
int execv(char *, char **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getpid();
int /*<<< orphan*/ insert_kmod(char *);
int /*<<< orphan*/ putenv(char *);
scalar_t__ remove(char *);
int safe_strtol(char *, scalar_t__ *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ usleep(int);
int waitpid(int, int *, int /*<<< orphan*/);
pid_t start_server(in_port_t *port_out, int timeout) {
  char environment[80];
  snprintf(environment, sizeof(environment),
           "MEMCACHED_PORT_FILENAME=/tmp/ports.%lu", (long)getpid());
  char *filename = environment + strlen("MEMCACHED_PORT_FILENAME=");
  char pid_file[80];
  snprintf(pid_file, sizeof(pid_file), "/tmp/pid.%lu", (long)getpid());
  remove(filename);
  remove(pid_file);
  pid_t pid = fork();
  assert(pid != -1);
  if (pid == 0) {
    char *argv[20];
    int arg = 0;
    char tmo[24];
    snprintf(tmo, sizeof(tmo), "%u", timeout);
    putenv(environment);
    argv[arg++] = "./user/umemcached";
    argv[arg++] = "-A";
    argv[arg++] = "-p";
    argv[arg++] = "-1";
    argv[arg++] = "-U";
    argv[arg++] = "0";
    argv[arg++] = NULL;
    insert_kmod("./kmod/kmemcache.ko");
    close_terminal();
    assert(execv(argv[0], argv) != -1);
  } else {
    int stat;
    pid_t c;
    while ((c = waitpid(pid, &stat, 0)) == (pid_t)-1 && errno == EINTR)
      ;
    assert(c == pid);
    assert(stat == 0);
  }
  while (access(filename, F_OK) == -1) {
    usleep(10);
  }
  FILE *fp = fopen(filename, "r");
  if (fp == NULL) {
    fprintf(stderr, "Failed to open the file containing port numbers: %s\n",
            strerror(errno));
    assert(false);
  }
  *port_out = (in_port_t)-1;
  char buffer[80];
  while ((fgets(buffer, sizeof(buffer), fp)) != NULL) {
    if (strncmp(buffer, "TCP INET: ", 10) == 0) {
      int32_t val;
      assert(safe_strtol(buffer + 10, &val));
      *port_out = (in_port_t)val;
    }
  }
  fclose(fp);
  assert(remove(filename) == 0);
  return pid;
}


x86 assembly (clang, -O0):
<start_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x210(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x210(%rbp),%rdi
mov    %eax,%ecx
mov    $0x50,%esi
lea    0xd87(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x208(%rbp)
lea    0xd97(%rip),%rdi
call   1090 <strlen@plt>
mov    %eax,%ecx
mov    -0x208(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
lea    -0xc0(%rbp),%rax
mov    %rax,-0x200(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x200(%rbp),%rdi
mov    %eax,%ecx
mov    $0x50,%esi
lea    0xd6e(%rip),%rdx
call   10a0 <snprintf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <remove@plt>
lea    -0xc0(%rbp),%rdi
call   1030 <remove@plt>
mov    $0x0,%al
call   1150 <fork@plt>
mov    %eax,-0xc4(%rbp)
cmpl   $0xffffffff,-0xc4(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10e0 <assert@plt>
cmpl   $0x0,-0xc4(%rbp)
jne    146e <start_server+0x22e>
movl   $0x0,-0x174(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    $0x18,%esi
lea    0xd13(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0x60(%rbp),%rdi
call   10d0 <putenv@plt>
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xcee(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xcde(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xcbf(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xca0(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xc81(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
lea    0xc62(%rip),%rcx
mov    %rcx,-0x170(%rbp,%rax,8)
ff
mov    -0x174(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x174(%rbp)
cltq
movq   $0x0,-0x170(%rbp,%rax,8)
lea    0xc36(%rip),%rdi
call   10b0 <insert_kmod@plt>
mov    $0x0,%al
call   1070 <close_terminal@plt>
mov    -0x170(%rbp),%rdi
lea    -0x170(%rbp),%rsi
call   1140 <execv@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10e0 <assert@plt>
jmp    1502 <start_server+0x2c2>
jmp    1473 <start_server+0x233>
mov    -0xc4(%rbp),%edi
lea    -0x194(%rbp),%rsi
xor    %edx,%edx
call   1100 <waitpid@plt>
mov    %eax,%ecx
mov    %ecx,-0x198(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x211(%rbp)
jne    14bd <start_server+0x27d>
mov    0x2b31(%rip),%rax
mov    (%rax),%rax
mov    0x2b1f(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x211(%rbp)
mov    -0x211(%rbp),%al
test   $0x1,%al
jne    14d0 <start_server+0x290>
jmp    14d5 <start_server+0x295>
jmp    1473 <start_server+0x233>
mov    -0x198(%rbp),%eax
cmp    -0xc4(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10e0 <assert@plt>
cmpl   $0x0,-0x194(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10e0 <assert@plt>
jmp    1507 <start_server+0x2c7>
mov    -0x68(%rbp),%rdi
mov    0x2aae(%rip),%rax
mov    (%rax),%esi
call   1110 <access@plt>
cmp    $0xffffffff,%eax
jne    1531 <start_server+0x2f1>
mov    $0xa,%edi
call   1160 <usleep@plt>
jmp    1507 <start_server+0x2c7>
mov    -0x68(%rbp),%rdi
lea    0xb48(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x1a0(%rbp)
cmpq   $0x0,-0x1a0(%rbp)
jne    1590 <start_server+0x350>
mov    0x2a83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x218(%rbp)
mov    0x2a6c(%rip),%rax
mov    (%rax),%rdi
call   1130 <strerror@plt>
mov    -0x218(%rbp),%edi
mov    %rax,%rdx
lea    0xb02(%rip),%rsi
call   10f0 <fprintf@plt>
xor    %edi,%edi
call   10e0 <assert@plt>
mov    -0x8(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
lea    -0x1f0(%rbp),%rdi
mov    -0x1a0(%rbp),%rdx
mov    $0x50,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
je     1610 <start_server+0x3d0>
lea    -0x1f0(%rbp),%rdi
lea    0xaf0(%rip),%rsi
mov    $0xa,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    160b <start_server+0x3cb>
lea    -0x1f0(%rbp),%rdi
add    $0xa,%rdi
lea    -0x1f8(%rbp),%rsi
call   1050 <safe_strtol@plt>
mov    %eax,%edi
call   10e0 <assert@plt>
mov    -0x1f8(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    159b <start_server+0x35b>
mov    -0x1a0(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x68(%rbp),%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10e0 <assert@plt>
mov    -0xc4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
mov    %esi,%ebx
mov    %rdi,(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xd9b(%rip),%rdx
lea    0xd0(%rsp),%rdi
mov    $0x50,%esi
mov    %eax,%ecx
call   10a0 <snprintf@plt>
lea    0xda7(%rip),%rdi
call   1090 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%r15
add    $0xd0,%r15
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xda0(%rip),%rdx
lea    0x120(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %eax,%ecx
call   10a0 <snprintf@plt>
mov    %r15,%rdi
call   1030 <remove@plt>
mov    %rbp,%rdi
call   1030 <remove@plt>
xor    %eax,%eax
call   1150 <fork@plt>
mov    %eax,%r13d
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   10e0 <assert@plt>
test   %r13d,%r13d
je     1339 <start_server+0xf9>
lea    0x30(%rsp),%r14
mov    0x2ce8(%rip),%rbp
mov    0x2cd9(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1100 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    131b <start_server+0xdb>
mov    (%rbx),%rcx
cmp    %rcx,0x0(%rbp)
je     1300 <start_server+0xc0>
xor    %edi,%edi
cmp    %r13d,%eax
sete   %dil
call   10e0 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x30(%rsp)
sete   %dil
jmp    13d8 <start_server+0x198>
lea    0xd0d(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x18,%esi
mov    %ebx,%ecx
call   10a0 <snprintf@plt>
lea    0xd0(%rsp),%rdi
call   10d0 <putenv@plt>
lea    0xceb(%rip),%rbx
mov    %rbx,0x30(%rsp)
lea    0xcf1(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xce8(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xcdf(%rip),%rax
mov    %rax,0x48(%rsp)
lea    0xcd6(%rip),%rax
mov    %rax,0x50(%rsp)
lea    0xccd(%rip),%rax
mov    %rax,0x58(%rsp)
movq   $0x0,0x60(%rsp)
lea    0xcba(%rip),%rdi
call   10b0 <insert_kmod@plt>
xor    %eax,%eax
call   1070 <close_terminal@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1140 <execv@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   10e0 <assert@plt>
mov    0x2bdc(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%esi
mov    %r15,%rdi
call   1110 <access@plt>
cmp    $0xffffffff,%eax
jne    140b <start_server+0x1cb>
mov    $0xa,%edi
call   1160 <usleep@plt>
jmp    13f0 <start_server+0x1b0>
lea    0xc72(%rip),%rsi
mov    %r15,0x8(%rsp)
mov    %r15,%rdi
call   1120 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1457 <start_server+0x217>
mov    0x2bb2(%rip),%rax
mov    (%rax),%ebp
mov    0x2ba1(%rip),%rax
mov    (%rax),%rdi
call   1130 <strerror@plt>
lea    0xc40(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   10f0 <fprintf@plt>
xor    %edi,%edi
call   10e0 <assert@plt>
mov    (%rsp),%rax
movq   $0xffffffffffffffff,(%rax)
lea    0x30(%rsp),%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     14ea <start_server+0x2aa>
lea    0x3a(%rsp),%r12
lea    0xc36(%rip),%rbp
lea    0x30(%rsp),%r14
lea    0x10(%rsp),%r15
jmp    14b5 <start_server+0x275>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     14ea <start_server+0x2aa>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0xa,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    14a0 <start_server+0x260>
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <safe_strtol@plt>
mov    %eax,%edi
call   10e0 <assert@plt>
mov    0x10(%rsp),%rax
mov    (%rsp),%rcx
mov    %rax,(%rcx)
jmp    14a0 <start_server+0x260>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <remove@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10e0 <assert@plt>
mov    %r13d,%eax
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"MEMCACHED_PORT_FILENAME=/tmp/ports.%lu\00"
@.str.1 = [25 x i8] c"MEMCACHED_PORT_FILENAME=\00"
@.str.2 = [13 x i8] c"/tmp/pid.%lu\00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [18 x i8] c"./user/umemcached\00"
@.str.5 = [3 x i8] c"-A\00"
@.str.6 = [3 x i8] c"-p\00"
@.str.7 = [3 x i8] c"-1\00"
@.str.8 = [3 x i8] c"-U\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [20 x i8] c"./kmod/kmemcache.ko\00"
@errno = global i64 0
@EINTR = global i64 0
@F_OK = global i32 0
@.str.11 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.12 = [53 x i8] c"Failed to open the file containing port numbers: %s\0A\00"
@.str.13 = [11 x i8] c"TCP INET: \00"
define i32 @start_server(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca i8*
%7 = alloca [80 x i8]
%8 = alloca i32
%9 = alloca [20 x i8*]
%10 = alloca i32
%11 = alloca [24 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca [80 x i8]
%16 = alloca i64
store i64* %0, i64** %3
store i32 %1, i32* %4
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%18 = call i64 (...) @getpid()
%19 = trunc i64 %18 to i32
%20 = call i32 @snprintf(i8* %17, i32 80, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%22 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8* %24, i8** %6
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%26 = call i64 (...) @getpid()
%27 = trunc i64 %26 to i32
%28 = call i32 @snprintf(i8* %25, i32 80, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %6
%30 = call i64 @remove(i8* %29)
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%32 = call i64 @remove(i8* %31)
%33 = call i32 (...) @fork()
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, -1
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %83
40: ; preds = %2
store i32 0, i32* %10
%41 = getelementptr inbounds [24 x i8], [24 x i8]* %11, i64 0, i64 0
%42 = load i32, i32* %4
%43 = call i32 @snprintf(i8* %41, i32 24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%45 = call i32 @putenv(i8* %44)
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %48
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %49
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %52
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %53
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %56
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %57
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %60
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %61
%62 = load i32, i32* %10
%63 = add nsw i32 %62, 1
store i32 %63, i32* %10
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %64
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %65
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %68
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %69
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
%72 = sext i32 %70 to i64
%73 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 %72
store i8* null, i8** %73
%74 = call i32 @insert_kmod(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%75 = call i32 (...) @close_terminal()
%76 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 0
%77 = load i8*, i8** %76
%78 = getelementptr inbounds [20 x i8*], [20 x i8*]* %9, i64 0, i64 0
%79 = call i32 @execv(i8* %77, i8** %78)
%80 = icmp ne i32 %79, -1
%81 = zext i1 %80 to i32
%82 = call i32 @assert(i32 %81)
br label %105
83: ; preds = %2
br label %84
84: ; preds = %94, %83
%85 = load i32, i32* %8
%86 = call i32 @waitpid(i32 %85, i32* %12, i32 0)
store i32 %86, i32* %13
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = load i64, i64* @errno
%90 = load i64, i64* @EINTR
%91 = icmp eq i64 %89, %90
br label %92
92: ; preds = %88, %84
%93 = phi i1 [ false, %84 ], [ %91, %88 ]
br i1 %93, label %94, label %95
94: ; preds = %92
br label %84
95: ; preds = %92
%96 = load i32, i32* %13
%97 = load i32, i32* %8
%98 = icmp eq i32 %96, %97
%99 = zext i1 %98 to i32
%100 = call i32 @assert(i32 %99)
%101 = load i32, i32* %12
%102 = icmp eq i32 %101, 0
%103 = zext i1 %102 to i32
%104 = call i32 @assert(i32 %103)
br label %105
105: ; preds = %95, %40
br label %106
106: ; preds = %111, %105
%107 = load i8*, i8** %6
%108 = load i32, i32* @F_OK
%109 = call i32 @access(i8* %107, i32 %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = call i32 @usleep(i32 10)
br label %106
113: ; preds = %106
%114 = load i8*, i8** %6
%115 = call i32* @fopen(i8* %114, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %115, i32** %14
%116 = load i32*, i32** %14
%117 = icmp eq i32* %116, null
br i1 %117, label %118, label %124
118: ; preds = %113
%119 = load i32, i32* @stderr
%120 = load i64, i64* @errno
%121 = call i8* @strerror(i64 %120)
%122 = call i32 @fprintf(i32 %119, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0), i8* %121)
%123 = call i32 @assert(i32 0)
br label %124
124: ; preds = %118, %113
%125 = load i64*, i64** %3
store i64 -1, i64* %125
br label %126
126: ; preds = %142, %124
%127 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%128 = load i32*, i32** %14
%129 = call i32* @fgets(i8* %127, i32 80, i32* %128)
%130 = icmp ne i32* %129, null
br i1 %130, label %131, label %143
131: ; preds = %126
%132 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%133 = call i64 @strncmp(i8* %132, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i32 10)
%134 = icmp eq i64 %133, 0
br i1 %134, label %135, label %142
135: ; preds = %131
%136 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%137 = getelementptr inbounds i8, i8* %136, i64 10
%138 = call i32 @safe_strtol(i8* %137, i64* %16)
%139 = call i32 @assert(i32 %138)
%140 = load i64, i64* %16
%141 = load i64*, i64** %3
store i64 %140, i64* %141
br label %142
142: ; preds = %135, %131
br label %126
143: ; preds = %126
%144 = load i32*, i32** %14
%145 = call i32 @fclose(i32* %144)
%146 = load i8*, i8** %6
%147 = call i64 @remove(i8* %146)
%148 = icmp eq i64 %147, 0
%149 = zext i1 %148 to i32
%150 = call i32 @assert(i32 %149)
%151 = load i32, i32* %8
ret i32 %151
}

LLVM IR (-O2):
@.str = [39 x i8] c"MEMCACHED_PORT_FILENAME=/tmp/ports.%lu\00"
@.str.1 = [25 x i8] c"MEMCACHED_PORT_FILENAME=\00"
@.str.2 = [13 x i8] c"/tmp/pid.%lu\00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [18 x i8] c"./user/umemcached\00"
@.str.5 = [3 x i8] c"-A\00"
@.str.6 = [3 x i8] c"-p\00"
@.str.7 = [3 x i8] c"-1\00"
@.str.8 = [3 x i8] c"-U\00"
@.str.9 = [2 x i8] c"0\00"
@.str.10 = [20 x i8] c"./kmod/kmemcache.ko\00"
@errno = global i64 0
@EINTR = global i64 0
@F_OK = global i32 0
@.str.11 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.12 = [53 x i8] c"Failed to open the file containing port numbers: %s\0A\00"
@.str.13 = [11 x i8] c"TCP INET: \00"
define i32 @start_server(i64* nocapture writeonly %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [20 x i8*]
%6 = alloca [24 x i8]
%7 = alloca i32
%8 = alloca [80 x i8]
%9 = alloca i64
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = tail call i64 (...) @getpid()
%12 = trunc i64 %11 to i32
%13 = call i32 @snprintf(i8* %10, i32 80, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %15
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%18 = call i64 (...) @getpid()
%19 = trunc i64 %18 to i32
%20 = call i32 @snprintf(i8* %17, i32 80, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i64 @remove(i8* %16)
%22 = call i64 @remove(i8* %17)
%23 = call i32 (...) @fork()
%24 = icmp ne i32 %23, -1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = icmp eq i32 %23, 0
br i1 %27, label %28, label %46
28: ; preds = %2
%29 = bitcast [20 x i8*]* %5 to i8*
%30 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%31 = call i32 @snprintf(i8* %30, i32 24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%32 = call i32 @putenv(i8* %10)
%33 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %33
%34 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %35
%36 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %36
%37 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %37
%38 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %38
%39 = getelementptr inbounds [20 x i8*], [20 x i8*]* %5, i64 0, i64 6
store i8* null, i8** %39
%40 = call i32 @insert_kmod(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%41 = call i32 (...) @close_terminal()
%42 = call i32 @execv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %33)
%43 = icmp ne i32 %42, -1
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
br label %63
46: ; preds = %2
%47 = bitcast i32* %7 to i8*
br label %48
48: ; preds = %48, %46
%49 = call i32 @waitpid(i32 %23, i32* %7, i32 0)
%50 = icmp eq i32 %49, -1
%51 = load i64, i64* @errno
%52 = load i64, i64* @EINTR
%53 = icmp eq i64 %51, %52
%54 = select i1 %50, i1 %53, i1 false
br i1 %54, label %48, label %55
55: ; preds = %48
%56 = icmp eq i32 %49, %23
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
br label %63
63: ; preds = %55, %28
%64 = load i32, i32* @F_OK
%65 = call i32 @access(i8* %16, i32 %64)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %72
67: ; preds = %63, %67
%68 = call i32 @usleep(i32 10)
%69 = load i32, i32* @F_OK
%70 = call i32 @access(i8* %16, i32 %69)
%71 = icmp eq i32 %70, -1
br i1 %71, label %67, label %72
72: ; preds = %67, %63
%73 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %81
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = load i64, i64* @errno
%78 = call i8* @strerror(i64 %77)
%79 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0), i8* %78)
%80 = call i32 @assert(i32 0)
br label %81
81: ; preds = %75, %72
store i64 -1, i64* %0
%82 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%83 = call i32* @fgets(i8* %82, i32 80, i32* %73)
%84 = icmp eq i32* %83, null
br i1 %84, label %98, label %85
85: ; preds = %81
%86 = bitcast i64* %9 to i8*
%87 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 10
br label %88
88: ; preds = %85, %95
%89 = call i64 @strncmp(i8* %82, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i32 10)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %95
91: ; preds = %88
%92 = call i32 @safe_strtol(i8* %87, i64* %9)
%93 = call i32 @assert(i32 %92)
%94 = load i64, i64* %9
store i64 %94, i64* %0
br label %95
95: ; preds = %91, %88
%96 = call i32* @fgets(i8* %82, i32 80, i32* %73)
%97 = icmp eq i32* %96, null
br i1 %97, label %98, label %88
98: ; preds = %95, %81
%99 = call i32 @fclose(i32* %73)
%100 = call i64 @remove(i8* %16)
%101 = icmp eq i64 %100, 0
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
ret i32 %23
}