#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 */
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ParseRequest(int, struct sockaddr_in, char *);
int /*<<< orphan*/ SendError(int, int, char *, char *, char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
void HandleClient(int client_sock, struct sockaddr_in client_addr) {
  char buf[10240];
  if (read(client_sock, buf, 10240) < 0) {
    SendError(client_sock, 500, "Internal Server Error", "",
              "Client request not success.");
    die("read sock");
  }
  ParseRequest(client_sock, client_addr, buf);
  close(client_sock);
  exit(0);
}


x86 assembly (clang, -O0):
<HandleClient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2810,%rsp
mov    %esi,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x2810(%rbp),%rsi
mov    $0x2800,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jge    11bd <HandleClient+0x5d>
mov    -0xc(%rbp),%edi
mov    $0x1f4,%esi
lea    0xe62(%rip),%rdx
lea    0xe8c(%rip),%rcx
lea    0xe6a(%rip),%r8
call   1030 <SendError@plt>
lea    0xe7a(%rip),%rdi
call   1070 <die@plt>
mov    -0xc(%rbp),%edi
lea    -0x2810(%rbp),%rdx
mov    -0x8(%rbp),%esi
call   1060 <ParseRequest@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<HandleClient>:
push   %rbp
push   %rbx
sub    $0x2808,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%rsi
mov    $0x2800,%edx
call   1050 <read@plt>
test   %rax,%rax
jns    11ac <HandleClient+0x4c>
lea    0xe7a(%rip),%rdx
lea    0xea4(%rip),%rcx
lea    0xe82(%rip),%r8
mov    %ebx,%edi
mov    $0x1f4,%esi
call   1030 <SendError@plt>
lea    0xe8b(%rip),%rdi
call   1070 <die@plt>
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <ParseRequest@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@.str = [22 x i8] c"Internal Server Error\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [28 x i8] c"Client request not success.\00"
@.str.3 = [10 x i8] c"read sock\00"
define void @HandleClient(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [10240 x i8]
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
store i32 %1, i32* %6
store i32 %0, i32* %4
%7 = load i32, i32* %4
%8 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%9 = call i64 @read(i32 %7, i8* %8, i32 10240)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %4
%13 = call i32 @SendError(i32 %12, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* %4
%17 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @ParseRequest(i32 %16, i32 %19, i8* %17)
%21 = load i32, i32* %4
%22 = call i32 @close(i32 %21)
%23 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"Internal Server Error\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [28 x i8] c"Client request not success.\00"
@.str.3 = [10 x i8] c"read sock\00"
define void @HandleClient(i32 %0, i32 %1) {
%3 = alloca [10240 x i8]
%4 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%5 = call i64 @read(i32 %0, i8* %4, i32 10240)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @SendError(i32 %0, i32 500, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %7, %2
%11 = call i32 @ParseRequest(i32 %0, i32 %1, i8* %4)
%12 = call i32 @close(i32 %0)
%13 = call i32 @exit(i32 0)
unreachable
}