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

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ parseWebRequest(char *, int, int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void processConnection(void *arg) {
  int r;
  char recvBuff[8192];
  int *conn = (int *)arg;
  bzero(recvBuff, sizeof(recvBuff));
  r = read(*conn, recvBuff, sizeof(recvBuff));
  if (r < 0)
    syslog(LOG_ERR, "Issue reading buffer. Error is: %s", strerror(errno));
  else
    parseWebRequest(recvBuff, *conn, r);
  close(*conn);
  pthread_exit(0);
}


x86 assembly (clang, -O0):
<processConnection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x2018(%rbp)
lea    -0x2010(%rbp),%rdi
mov    $0x2000,%esi
call   1080 <bzero@plt>
mov    -0x2018(%rbp),%rax
mov    (%rax),%edi
lea    -0x2010(%rbp),%rsi
mov    $0x2000,%edx
call   1050 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11f8 <processConnection+0x88>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x201c(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x201c(%rbp),%edi
mov    %eax,%edx
lea    0xe12(%rip),%rsi
call   1070 <syslog@plt>
jmp    1210 <processConnection+0xa0>
lea    -0x2010(%rbp),%rdi
mov    -0x2018(%rbp),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1030 <parseWebRequest@plt>
mov    -0x2018(%rbp),%rax
mov    (%rax),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1060 <pthread_exit@plt>
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processConnection>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2000,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x2000,%esi
call   1080 <bzero@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x2000,%edx
call   1050 <read@plt>
test   %eax,%eax
js     11af <processConnection+0x3f>
mov    (%rbx),%esi
mov    %rsp,%rdi
mov    %eax,%edx
call   1030 <parseWebRequest@plt>
jmp    11d6 <processConnection+0x66>
mov    0x2e1a(%rip),%rax
mov    (%rax),%ebp
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe33(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1070 <syslog@plt>
mov    (%rbx),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1060 <pthread_exit@plt>
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LOG_ERR = global i32 0
@.str = [35 x i8] c"Issue reading buffer. Error is: %s\00"
@errno = global i32 0
define void @processConnection(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [8192 x i8]
%5 = alloca i32*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %5
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%9 = call i32 @bzero(i8* %8, i32 8192)
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 8192)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %1
%17 = load i32, i32* @LOG_ERR
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @syslog(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %27
21: ; preds = %1
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%23 = load i32*, i32** %5
%24 = load i32, i32* %23
%25 = load i32, i32* %3
%26 = call i32 @parseWebRequest(i8* %22, i32 %24, i32 %25)
br label %27
27: ; preds = %21, %16
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = call i32 @pthread_exit(i32 0)
ret void
}

LLVM IR (-O2):
@LOG_ERR = global i32 0
@.str = [35 x i8] c"Issue reading buffer. Error is: %s\00"
@errno = global i32 0
define void @processConnection(i8* nocapture %0) {
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%4 = bitcast i8* %0 to i32*
%5 = call i32 @bzero(i8* %3, i32 8192)
%6 = load i32, i32* %4
%7 = call i32 @read(i32 %6, i8* %3, i32 8192)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* @LOG_ERR
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @syslog(i32 %10, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %1
%15 = load i32, i32* %4
%16 = call i32 @parseWebRequest(i8* %3, i32 %15, i32 %7)
br label %17
17: ; preds = %14, %9
%18 = load i32, i32* %4
%19 = call i32 @close(i32 %18)
%20 = call i32 @pthread_exit(i32 0)
ret void
}