#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 */
int /*<<< orphan*/ errorClose2Sock(char *, int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int getMessage(int aSock, int lSock, char *msg) {
  char buffer[32768];
  int bits = read(aSock, buffer, 32768);
  printf("got: '%s'\n", buffer);
  if (bits < 0)
    errorClose2Sock("recv error", aSock, lSock);
  strcpy(msg, buffer);
  memset(buffer, 0, 32768);
  return bits;
}


x86 assembly (clang, -O0):
<getMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8020,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8010(%rbp),%rsi
mov    $0x8000,%edx
call   1060 <read@plt>
mov    %eax,-0x8014(%rbp)
lea    -0x8010(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x8014(%rbp)
jge    11b1 <getMessage+0x61>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5f(%rip),%rdi
call   1070 <errorClose2Sock@plt>
mov    -0x10(%rbp),%rdi
lea    -0x8010(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x8010(%rbp),%rdi
xor    %esi,%esi
mov    $0x8000,%edx
call   1050 <memset@plt>
mov    -0x8014(%rbp),%eax
add    $0x8020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMessage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x8000,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebp
mov    %rsp,%r12
mov    %r12,%rsi
mov    $0x8000,%edx
call   1060 <read@plt>
mov    %eax,%ebx
lea    0xe80(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
test   %ebx,%ebx
jns    119d <getMessage+0x4d>
lea    0xe78(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1070 <errorClose2Sock@plt>
mov    %rsp,%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8000,%edx
call   1050 <memset@plt>
mov    %ebx,%eax
add    $0x8000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"got: '%s'\0A\00"
@.str.1 = [11 x i8] c"recv error\00"
define i32 @getMessage(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [32768 x i8]
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %4
%10 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%11 = call i32 @read(i32 %9, i8* %10, i32 32768)
store i32 %11, i32* %8
%12 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @errorClose2Sock(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
br label %20
20: ; preds = %16, %3
%21 = load i8*, i8** %6
%22 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 32768)
%26 = load i32, i32* %8
ret i32 %26
}

LLVM IR (-O2):
@.str = [11 x i8] c"got: '%s'\0A\00"
@.str.1 = [11 x i8] c"recv error\00"
define i32 @getMessage(i32 %0, i32 %1, i8* %2) {
%4 = alloca [32768 x i8]
%5 = getelementptr inbounds [32768 x i8], [32768 x i8]* %4, i64 0, i64 0
%6 = call i32 @read(i32 %0, i8* %5, i32 32768)
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = icmp slt i32 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @errorClose2Sock(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
br label %11
11: ; preds = %9, %3
%12 = call i32 @strcpy(i8* %2, i8* %5)
%13 = call i32 @memset(i8* %5, i32 0, i32 32768)
ret i32 %6
}