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

/* Variables and functions */
size_t pullFromSocket(int, char *, size_t);
int /*<<< orphan*/ pushToSocket(int, char *, size_t);
size_t handleServerConnection(int clientFd, int encryptionMode, char *keyBuffer,
                              char *msgBuffer, char *resultBuffer,
                              size_t size) {
  size_t sizeBuf[] = {(size_t)encryptionMode, size};
  pushToSocket(clientFd, (char *)sizeBuf, sizeof(size_t) * 2);
  pushToSocket(clientFd, keyBuffer, size);
  pushToSocket(clientFd, msgBuffer, size);
  return pullFromSocket(clientFd, resultBuffer, size);
}


x86 assembly (clang, -O0):
<handleServerConnection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movslq -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1040 <pushToSocket@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <pushToSocket@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <pushToSocket@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <pullFromSocket@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleServerConnection>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %edi,%ebp
movslq %esi,%rax
mov    %rax,(%rsp)
mov    %r9,0x8(%rsp)
mov    %rsp,%rsi
mov    $0x10,%edx
call   1040 <pushToSocket@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <pushToSocket@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <pushToSocket@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <pullFromSocket@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @handleServerConnection(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4, i64 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca [2 x i64]
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i64 %5, i64* %12
%14 = getelementptr inbounds [2 x i64], [2 x i64]* %13, i64 0, i64 0
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
store i64 %16, i64* %14
%17 = getelementptr inbounds i64, i64* %14, i64 1
%18 = load i64, i64* %12
store i64 %18, i64* %17
%19 = load i32, i32* %7
%20 = getelementptr inbounds [2 x i64], [2 x i64]* %13, i64 0, i64 0
%21 = bitcast i64* %20 to i8*
%22 = call i32 @pushToSocket(i32 %19, i8* %21, i64 16)
%23 = load i32, i32* %7
%24 = load i8*, i8** %9
%25 = load i64, i64* %12
%26 = call i32 @pushToSocket(i32 %23, i8* %24, i64 %25)
%27 = load i32, i32* %7
%28 = load i8*, i8** %10
%29 = load i64, i64* %12
%30 = call i32 @pushToSocket(i32 %27, i8* %28, i64 %29)
%31 = load i32, i32* %7
%32 = load i8*, i8** %11
%33 = load i64, i64* %12
%34 = call i64 @pullFromSocket(i32 %31, i8* %32, i64 %33)
ret i64 %34
}

LLVM IR (-O2):
define i64 @handleServerConnection(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4, i64 %5) {
%7 = alloca [2 x i64]
%8 = bitcast [2 x i64]* %7 to i8*
%9 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%10 = sext i32 %1 to i64
store i64 %10, i64* %9
%11 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 %5, i64* %11
%12 = call i32 @pushToSocket(i32 %0, i8* %8, i64 16)
%13 = call i32 @pushToSocket(i32 %0, i8* %2, i64 %5)
%14 = call i32 @pushToSocket(i32 %0, i8* %3, i64 %5)
%15 = call i64 @pullFromSocket(i32 %0, i8* %4, i64 %5)
ret i64 %15
}