#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*/ async_read(int, int);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ printf(char *, char *);
int process_request(char *);
int /*<<< orphan*/ read(int, char *, int);
int server_init(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int s, c;
  char buffer[2048];
  s = server_init(atoi(argv[1]));
  read(s, buffer, 2048);
  printf("Request: '%s'\n", buffer);
  c = process_request(buffer);
  async_read(s, c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <server_init@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1050 <read@plt>
lea    -0x820(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x820(%rbp),%rdi
call   1030 <process_request@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <async_read@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <server_init@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x800,%edx
call   1050 <read@plt>
lea    0xe6b(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <process_request@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <async_read@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Request: '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
%13 = call i32 @server_init(i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%16 = call i32 @read(i32 %14, i8* %15, i32 2048)
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%20 = call i32 @process_request(i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @async_read(i32 %21, i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Request: '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = tail call i32 @server_init(i32 %7)
%9 = call i32 @read(i32 %8, i8* %4, i32 2048)
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i32 @process_request(i8* %4)
%12 = call i32 @async_read(i32 %8, i32 %11)
ret i32 0
}