#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*/ buffer;
typedef int /*<<< orphan*/ argbuf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int authenticate(int /*<<< orphan*/ *, char *, char *);
char *findarg(char *, int);
int /*<<< orphan*/ logData(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int readSock(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int /*<<< orphan*/ userFunctions(int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ writeSock(int, char *, int);
void handleConnection(FILE *logfile, int sock) {
  char buffer[1024];
  char argbuf[1024];
  char *user = NULL;
  char *pass = NULL;
  int len = 0;
  int ret = 0;
  size_t segloop;
  size_t segmentcount;
  size_t segnext;
  size_t argsize;
  char *ptr1;
  char *ptr2;
  memset(buffer, 0, sizeof(buffer));
  len = readSock(sock, buffer, sizeof(buffer));
  logData(logfile, "handling connection");
  if (len == -1) {
    return;
  }
  ptr1 = buffer;
  ptr2 = argbuf;
  memcpy((char *)&segmentcount, ptr1, 4);
  logData(logfile, "Segment count is %i", segmentcount);
  if (segmentcount * 8 > sizeof(argbuf)) {
    logData(logfile, "bad segment count");
    return;
  }
  ptr1 += 4;
  memset(argbuf, 0, sizeof(argbuf));
  for (segloop = 0; segloop < segmentcount; ++segloop) {
    logData(logfile, "adding segment %i", segloop + 1);
    memcpy((char *)&segnext, ptr1, 4);
    logData(logfile, "next segment offset %i", segnext);
    ptr1 += 4;
    memcpy((char *)&argsize, ptr1, 4);
    logData(logfile, "argsize: %i", argsize);
    memcpy(ptr2, ptr1, argsize);
    ptr2 += argsize;
    ptr1 += segnext;
  }
  logData(logfile, "looking up user args");
  user = findarg(argbuf, 0x01);
  pass = findarg(argbuf, 0x02);
  snprintf(buffer, sizeof(buffer) - 1, "User attempting to authenticate: %s",
           user);
  logData(logfile, buffer);
  logData(logfile, "calling authenticate");
  ret = authenticate(logfile, user, pass);
  logData(logfile, "returned from authenticate");
  if (ret != 1) {
    if (ret == 2) {
      writeSock(sock, "\x33\x44 BAD USERNAME!",
                sizeof("\x33\x44 BAD USERNAME!"));
    }
    if (ret == 3) {
      writeSock(sock, "\x33\x45 BAD PASSWORD!",
                sizeof("\x33\x45 BAD PASSWORD!"));
    }
    snprintf(buffer, sizeof(buffer) - 1,
             "user: %s failed to login with password %s", user, pass);
    logData(logfile, buffer);
    return;
  }
  logData(logfile, "user %s authenticated!", user);
  userFunctions(logfile, sock, user);
  return;
}


x86 assembly (clang, -O0):
<handleConnection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x818(%rbp)
movq   $0x0,-0x820(%rbp)
movl   $0x0,-0x824(%rbp)
movl   $0x0,-0x828(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    -0xc(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <readSock@plt>
mov    %eax,-0x824(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
cmpl   $0xffffffff,-0x824(%rbp)
jne    121d <handleConnection+0x8d>
jmp    1538 <handleConnection+0x3a8>
lea    -0x410(%rbp),%rax
mov    %rax,-0x850(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x858(%rbp)
lea    -0x838(%rbp),%rdi
mov    -0x850(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x838(%rbp),%rdx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x838(%rbp),%rax
shl    $0x3,%rax
cmp    $0x400,%rax
jbe    1298 <handleConnection+0x108>
mov    -0x8(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
jmp    1538 <handleConnection+0x3a8>
mov    -0x850(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x850(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
movq   $0x0,-0x830(%rbp)
mov    -0x830(%rbp),%rax
cmp    -0x838(%rbp),%rax
jae    13c8 <handleConnection+0x238>
mov    -0x8(%rbp),%rdi
mov    -0x830(%rbp),%rdx
add    $0x1,%rdx
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
lea    -0x840(%rbp),%rdi
mov    -0x850(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x840(%rbp),%rdx
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x850(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x850(%rbp)
lea    -0x848(%rbp),%rdi
mov    -0x850(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x848(%rbp),%rdx
lea    0xcfd(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x858(%rbp),%rdi
mov    -0x850(%rbp),%rsi
mov    -0x848(%rbp),%rdx
call   10a0 <memcpy@plt>
mov    -0x848(%rbp),%rax
add    -0x858(%rbp),%rax
mov    %rax,-0x858(%rbp)
mov    -0x840(%rbp),%rax
add    -0x850(%rbp),%rax
mov    %rax,-0x850(%rbp)
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    12c8 <handleConnection+0x138>
mov    -0x8(%rbp),%rdi
lea    0xc9c(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
lea    -0x810(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <findarg@plt>
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
mov    $0x2,%esi
call   10b0 <findarg@plt>
mov    %rax,-0x820(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rcx
mov    $0x3ff,%esi
lea    0xc60(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x8(%rbp),%rdi
lea    0xc60(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x8(%rbp),%rdi
mov    -0x818(%rbp),%rsi
mov    -0x820(%rbp),%rdx
call   1050 <authenticate@plt>
mov    %eax,-0x828(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xc46(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
cmpl   $0x1,-0x828(%rbp)
je     150c <handleConnection+0x37c>
cmpl   $0x2,-0x828(%rbp)
jne    14ac <handleConnection+0x31c>
mov    -0xc(%rbp),%edi
lea    0xc36(%rip),%rsi
mov    $0x11,%edx
call   1090 <writeSock@plt>
cmpl   $0x3,-0x828(%rbp)
jne    14cd <handleConnection+0x33d>
mov    -0xc(%rbp),%edi
lea    0xc26(%rip),%rsi
mov    $0x11,%edx
call   1090 <writeSock@plt>
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rcx
mov    -0x820(%rbp),%r8
mov    $0x3ff,%esi
lea    0xc0c(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
jmp    1538 <handleConnection+0x3a8>
mov    -0x8(%rbp),%rdi
mov    -0x818(%rbp),%rdx
lea    0xc06(%rip),%rsi
mov    $0x0,%al
call   1030 <logData@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x818(%rbp),%rdx
call   1080 <userFunctions@plt>
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleConnection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %esi,%ebp
mov    %rdi,%r12
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <readSock@plt>
mov    %eax,%ebx
lea    0xe2e(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <logData@plt>
cmp    $0xffffffff,%ebx
je     1411 <handleConnection+0x281>
lea    0x8(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    0x8(%rsp),%rdx
lea    0xe0f(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <logData@plt>
mov    0x8(%rsp),%rax
shl    $0x3,%rax
cmp    $0x401,%rax
jb     122f <handleConnection+0x9f>
lea    0xe01(%rip),%rsi
mov    %r12,%rdi
jmp    140a <handleConnection+0x27a>
mov    %ebp,0x4(%rsp)
lea    0x420(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
cmpq   $0x0,0x8(%rsp)
je     12fb <handleConnection+0x16b>
lea    0x24(%rsp),%rbx
lea    0x10(%rsp),%r15
lea    0xdfc(%rip),%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    %r12,%rdi
lea    0xdbc(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <logData@plt>
mov    $0x4,%edx
lea    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   10a0 <memcpy@plt>
mov    0x18(%rsp),%rdx
mov    %r12,%rdi
lea    0xda3(%rip),%rsi
xor    %eax,%eax
call   1030 <logData@plt>
add    $0x4,%rbx
mov    $0x4,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <memcpy@plt>
mov    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <logData@plt>
mov    0x10(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10a0 <memcpy@plt>
add    0x10(%rsp),%rbp
add    0x18(%rsp),%rbx
cmp    0x8(%rsp),%r14
jb     1270 <handleConnection+0xe0>
lea    0xd6d(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <logData@plt>
lea    0x420(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   10b0 <findarg@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x2,%esi
call   10b0 <findarg@plt>
mov    %rax,%r15
lea    0xd49(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %rbp,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <logData@plt>
lea    0xd42(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <logData@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1050 <authenticate@plt>
mov    %eax,%ebx
lea    0xd36(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <logData@plt>
cmp    $0x1,%ebx
je     13a9 <handleConnection+0x219>
cmp    $0x2,%ebx
je     13ce <handleConnection+0x23e>
cmp    $0x3,%ebx
jne    13e3 <handleConnection+0x253>
lea    0xd42(%rip),%rsi
jmp    13d5 <handleConnection+0x245>
lea    0xd74(%rip),%rsi
mov    %r12,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <logData@plt>
mov    %r12,%rdi
mov    0x4(%rsp),%esi
mov    %rbp,%rdx
call   1080 <userFunctions@plt>
jmp    1411 <handleConnection+0x281>
lea    0xd03(%rip),%rsi
mov    0x4(%rsp),%edi
mov    $0x11,%edx
call   1090 <writeSock@plt>
lea    0xd10(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %rbp,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <logData@plt>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"handling connection\00"
@.str.1 = [20 x i8] c"Segment count is %i\00"
@.str.2 = [18 x i8] c"bad segment count\00"
@.str.3 = [18 x i8] c"adding segment %i\00"
@.str.4 = [23 x i8] c"next segment offset %i\00"
@.str.5 = [12 x i8] c"argsize: %i\00"
@.str.6 = [21 x i8] c"looking up user args\00"
@.str.7 = [36 x i8] c"User attempting to authenticate: %s\00"
@.str.8 = [21 x i8] c"calling authenticate\00"
@.str.9 = [27 x i8] c"returned from authenticate\00"
@.str.10 = [17 x i8] c"3D BAD USERNAME!\00"
@.str.11 = [17 x i8] c"3E BAD PASSWORD!\00"
@.str.12 = [42 x i8] c"user: %s failed to login with password %s\00"
@.str.13 = [23 x i8] c"user %s authenticated!\00"
define void @handleConnection(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
store i8* null, i8** %7
store i8* null, i8** %8
store i32 0, i32* %9
store i32 0, i32* %10
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 1024)
%19 = load i32, i32* %4
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @readSock(i32 %19, i8* %20, i32 1024)
store i32 %21, i32* %9
%22 = load i32*, i32** %3
%23 = call i32 (i32*, i8*, ...) @logData(i32* %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* %9
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %27
26: ; preds = %2
br label %134
27: ; preds = %2
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
store i8* %28, i8** %15
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8* %29, i8** %16
%30 = bitcast i64* %12 to i8*
%31 = load i8*, i8** %15
%32 = call i32 @memcpy(i8* %30, i8* %31, i64 4)
%33 = load i32*, i32** %3
%34 = load i64, i64* %12
%35 = call i32 (i32*, i8*, ...) @logData(i32* %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 %34)
%36 = load i64, i64* %12
%37 = mul i64 %36, 8
%38 = icmp ugt i64 %37, 1024
br i1 %38, label %39, label %42
39: ; preds = %27
%40 = load i32*, i32** %3
%41 = call i32 (i32*, i8*, ...) @logData(i32* %40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %134
42: ; preds = %27
%43 = load i8*, i8** %15
%44 = getelementptr inbounds i8, i8* %43, i64 4
store i8* %44, i8** %15
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%46 = call i32 @memset(i8* %45, i32 0, i32 1024)
store i64 0, i64* %11
br label %47
47: ; preds = %80, %42
%48 = load i64, i64* %11
%49 = load i64, i64* %12
%50 = icmp ult i64 %48, %49
br i1 %50, label %51, label %83
51: ; preds = %47
%52 = load i32*, i32** %3
%53 = load i64, i64* %11
%54 = add i64 %53, 1
%55 = call i32 (i32*, i8*, ...) @logData(i32* %52, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 %54)
%56 = bitcast i64* %13 to i8*
%57 = load i8*, i8** %15
%58 = call i32 @memcpy(i8* %56, i8* %57, i64 4)
%59 = load i32*, i32** %3
%60 = load i64, i64* %13
%61 = call i32 (i32*, i8*, ...) @logData(i32* %59, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %60)
%62 = load i8*, i8** %15
%63 = getelementptr inbounds i8, i8* %62, i64 4
store i8* %63, i8** %15
%64 = bitcast i64* %14 to i8*
%65 = load i8*, i8** %15
%66 = call i32 @memcpy(i8* %64, i8* %65, i64 4)
%67 = load i32*, i32** %3
%68 = load i64, i64* %14
%69 = call i32 (i32*, i8*, ...) @logData(i32* %67, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 %68)
%70 = load i8*, i8** %16
%71 = load i8*, i8** %15
%72 = load i64, i64* %14
%73 = call i32 @memcpy(i8* %70, i8* %71, i64 %72)
%74 = load i64, i64* %14
%75 = load i8*, i8** %16
%76 = getelementptr inbounds i8, i8* %75, i64 %74
store i8* %76, i8** %16
%77 = load i64, i64* %13
%78 = load i8*, i8** %15
%79 = getelementptr inbounds i8, i8* %78, i64 %77
store i8* %79, i8** %15
br label %80
80: ; preds = %51
%81 = load i64, i64* %11
%82 = add i64 %81, 1
store i64 %82, i64* %11
br label %47
83: ; preds = %47
%84 = load i32*, i32** %3
%85 = call i32 (i32*, i8*, ...) @logData(i32* %84, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%87 = call i8* @findarg(i8* %86, i32 1)
store i8* %87, i8** %7
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%89 = call i8* @findarg(i8* %88, i32 2)
store i8* %89, i8** %8
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%91 = load i8*, i8** %7
%92 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %90, i32 1023, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i8* %91)
%93 = load i32*, i32** %3
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%95 = call i32 (i32*, i8*, ...) @logData(i32* %93, i8* %94)
%96 = load i32*, i32** %3
%97 = call i32 (i32*, i8*, ...) @logData(i32* %96, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%98 = load i32*, i32** %3
%99 = load i8*, i8** %7
%100 = load i8*, i8** %8
%101 = call i32 @authenticate(i32* %98, i8* %99, i8* %100)
store i32 %101, i32* %10
%102 = load i32*, i32** %3
%103 = call i32 (i32*, i8*, ...) @logData(i32* %102, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%104 = load i32, i32* %10
%105 = icmp ne i32 %104, 1
br i1 %105, label %106, label %126
106: ; preds = %83
%107 = load i32, i32* %10
%108 = icmp eq i32 %107, 2
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i32, i32* %4
%111 = call i32 @writeSock(i32 %110, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 17)
br label %112
112: ; preds = %109, %106
%113 = load i32, i32* %10
%114 = icmp eq i32 %113, 3
br i1 %114, label %115, label %118
115: ; preds = %112
%116 = load i32, i32* %4
%117 = call i32 @writeSock(i32 %116, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 17)
br label %118
118: ; preds = %115, %112
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%120 = load i8*, i8** %7
%121 = load i8*, i8** %8
%122 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %119, i32 1023, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i8* %120, i8* %121)
%123 = load i32*, i32** %3
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%125 = call i32 (i32*, i8*, ...) @logData(i32* %123, i8* %124)
br label %134
126: ; preds = %83
%127 = load i32*, i32** %3
%128 = load i8*, i8** %7
%129 = call i32 (i32*, i8*, ...) @logData(i32* %127, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %128)
%130 = load i32*, i32** %3
%131 = load i32, i32* %4
%132 = load i8*, i8** %7
%133 = call i32 @userFunctions(i32* %130, i32 %131, i8* %132)
br label %134
134: ; preds = %126, %118, %39, %26
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"handling connection\00"
@.str.1 = [20 x i8] c"Segment count is %i\00"
@.str.2 = [18 x i8] c"bad segment count\00"
@.str.3 = [18 x i8] c"adding segment %i\00"
@.str.4 = [23 x i8] c"next segment offset %i\00"
@.str.5 = [12 x i8] c"argsize: %i\00"
@.str.6 = [21 x i8] c"looking up user args\00"
@.str.7 = [36 x i8] c"User attempting to authenticate: %s\00"
@.str.8 = [21 x i8] c"calling authenticate\00"
@.str.9 = [27 x i8] c"returned from authenticate\00"
@.str.10 = [17 x i8] c"3D BAD USERNAME!\00"
@.str.11 = [17 x i8] c"3E BAD PASSWORD!\00"
@.str.12 = [42 x i8] c"user: %s failed to login with password %s\00"
@.str.13 = [23 x i8] c"user %s authenticated!\00"
define void @handleConnection(i32* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = bitcast i64* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = call i32 @memset(i8* %8, i32 0, i32 1024)
%14 = call i32 @readSock(i32 %1, i8* %8, i32 1024)
%15 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %14, -1
br i1 %16, label %72, label %17
17: ; preds = %2
%18 = call i32 @memcpy(i8* %10, i8* %8, i64 4)
%19 = load i64, i64* %5
%20 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = load i64, i64* %5
%22 = shl i64 %21, 3
%23 = icmp ugt i64 %22, 1024
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %72
26: ; preds = %17
%27 = call i32 @memset(i8* %9, i32 0, i32 1024)
%28 = load i64, i64* %5
%29 = icmp eq i64 %28, 0
br i1 %29, label %53, label %30
30: ; preds = %26
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 4
br label %32
32: ; preds = %30, %32
%33 = phi i8* [ %48, %32 ], [ %9, %30 ]
%34 = phi i8* [ %50, %32 ], [ %31, %30 ]
%35 = phi i64 [ %36, %32 ], [ 0, %30 ]
%36 = add nuw i64 %35, 1
%37 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 %36)
%38 = call i32 @memcpy(i8* %11, i8* %34, i64 4)
%39 = load i64, i64* %6
%40 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 %39)
%41 = getelementptr inbounds i8, i8* %34, i64 4
%42 = call i32 @memcpy(i8* %12, i8* %41, i64 4)
%43 = load i64, i64* %7
%44 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 %43)
%45 = load i64, i64* %7
%46 = call i32 @memcpy(i8* %33, i8* %41, i64 %45)
%47 = load i64, i64* %7
%48 = getelementptr inbounds i8, i8* %33, i64 %47
%49 = load i64, i64* %6
%50 = getelementptr inbounds i8, i8* %41, i64 %49
%51 = load i64, i64* %5
%52 = icmp ult i64 %36, %51
br i1 %52, label %32, label %53
53: ; preds = %32, %26
%54 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%55 = call i8* @findarg(i8* %9, i32 1)
%56 = call i8* @findarg(i8* %9, i32 2)
%57 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %8, i32 1023, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%58 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* %8)
%59 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%60 = call i32 @authenticate(i32* %0, i8* %55, i8* %56)
%61 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
switch i32 %60, label %66 [
i32 1, label %69
i32 2, label %63
i32 3, label %62
]
62: ; preds = %53
br label %63
63: ; preds = %53, %62
%64 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), %62 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), %53 ]
%65 = call i32 @writeSock(i32 %1, i8* %64, i32 17)
br label %66
66: ; preds = %63, %53
%67 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %8, i32 1023, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i8* %55, i8* %56)
%68 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* %8)
br label %72
69: ; preds = %53
%70 = call i32 (i32*, i8*, ...) @logData(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %55)
%71 = call i32 @userFunctions(i32* %0, i32 %1, i8* %55)
br label %72
72: ; preds = %2, %69, %66, %24
ret void
}