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

/* Variables and functions */
int /*<<< orphan*/ logmessage(int, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void handle_request(int fd) {
  int rv;
  char inbuffer[2048];
  rv = recv(fd, inbuffer, sizeof(inbuffer), 0);
  if (rv == -1) {
    logmessage(1, "Error receiving request from client.");
    return;
  }
  if (send(fd, "HTTP/1.1 200 OK\r\n", strlen("HTTP/1.1 200 OK\r\n"), 0) == -1) {
    logmessage(1, "Error sending data to client.");
    return;
  };
  if (send(fd, "Content-Type: text/html\r\n",
           strlen("Content-Type: text/html\r\n"), 0) == -1) {
    logmessage(1, "Error sending data to client.");
    return;
  };
  if (send(fd, "Last-Modified: Sat, 08 Jan 1492 01:12:12 GMT\r\n",
           strlen("Last-Modified: Sat, 08 Jan 1492 01:12:12 GMT\r\n"),
           0) == -1) {
    logmessage(1, "Error sending data to client.");
    return;
  };
  if (send(fd, "Content-Length: 15\r\n\r\n",
           strlen("Content-Length: 15\r\n\r\n"), 0) == -1) {
    logmessage(1, "Error sending data to client.");
    return;
  };
  if (send(fd, "<html> </html>\r\n", strlen("<html> </html>\r\n"), 0) == -1) {
    logmessage(1, "Error sending data to client.");
    return;
  };
}


x86 assembly (clang, -O0):
<handle_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1187 <handle_request+0x47>
mov    $0x1,%edi
lea    0xe83(%rip),%rsi
call   1060 <logmessage@plt>
jmp    12f4 <handle_request+0x1b4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x814(%rbp)
lea    0xe8e(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x814(%rbp),%edi
mov    %eax,%edx
lea    0xe7a(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    11d1 <handle_request+0x91>
mov    $0x1,%edi
lea    0xe70(%rip),%rsi
call   1060 <logmessage@plt>
jmp    12f4 <handle_request+0x1b4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x818(%rbp)
lea    0xe74(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x818(%rbp),%edi
mov    %eax,%edx
lea    0xe60(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    121b <handle_request+0xdb>
mov    $0x1,%edi
lea    0xe26(%rip),%rsi
call   1060 <logmessage@plt>
jmp    12f4 <handle_request+0x1b4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x81c(%rbp)
lea    0xe44(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x81c(%rbp),%edi
mov    %eax,%edx
lea    0xe30(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    1265 <handle_request+0x125>
mov    $0x1,%edi
lea    0xddc(%rip),%rsi
call   1060 <logmessage@plt>
jmp    12f4 <handle_request+0x1b4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x820(%rbp)
lea    0xe29(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x820(%rbp),%edi
mov    %eax,%edx
lea    0xe15(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    12af <handle_request+0x16f>
mov    $0x1,%edi
lea    0xd92(%rip),%rsi
call   1060 <logmessage@plt>
jmp    12f4 <handle_request+0x1b4>
mov    -0x4(%rbp),%eax
mov    %eax,-0x824(%rbp)
lea    0xdf6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x824(%rbp),%edi
mov    %eax,%edx
lea    0xde2(%rip),%rsi
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    12f4 <handle_request+0x1b4>
mov    $0x1,%edi
lea    0xd48(%rip),%rsi
call   1060 <logmessage@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_request>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %edi,%ebp
mov    %rsp,%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     121c <handle_request+0xdc>
lea    0xeb9(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0xeae(%rip),%r14
cmp    $0xffffffff,%eax
je     1223 <handle_request+0xe3>
lea    0xebc(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
je     1223 <handle_request+0xe3>
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
je     1223 <handle_request+0xe3>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
je     1223 <handle_request+0xe3>
lea    0xeb6(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    1230 <handle_request+0xf0>
jmp    1223 <handle_request+0xe3>
lea    0xddd(%rip),%r14
mov    $0x1,%edi
mov    %r14,%rsi
call   1060 <logmessage@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Error receiving request from client.\00"
@.str.1 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.2 = [30 x i8] c"Error sending data to client.\00"
@.str.3 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.4 = [47 x i8] c"Last-Modified: Sat, 08 Jan 1492 01:12:12 GMT\0D\0A\00"
@.str.5 = [23 x i8] c"Content-Length: 15\0D\0A\0D\0A\00"
@.str.6 = [17 x i8] c"<html> </html>\0D\0A\00"
define void @handle_request(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2048 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%7 = call i32 @recv(i32 %5, i8* %6, i32 2048, i32 0)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %47
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @send(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %47
19: ; preds = %12
%20 = load i32, i32* %2
%21 = call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @send(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 0)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %47
26: ; preds = %19
%27 = load i32, i32* %2
%28 = call i32 @strlen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @send(i32 %27, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 0)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %47
33: ; preds = %26
%34 = load i32, i32* %2
%35 = call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 @send(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %35, i32 0)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %47
40: ; preds = %33
%41 = load i32, i32* %2
%42 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%43 = call i32 @send(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %42, i32 0)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %10, %17, %24, %31, %38, %45, %40
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"Error receiving request from client.\00"
@.str.1 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.2 = [30 x i8] c"Error sending data to client.\00"
@.str.3 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.4 = [47 x i8] c"Last-Modified: Sat, 08 Jan 1492 01:12:12 GMT\0D\0A\00"
@.str.5 = [23 x i8] c"Content-Length: 15\0D\0A\0D\0A\00"
@.str.6 = [17 x i8] c"<html> </html>\0D\0A\00"
define void @handle_request(i32 %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = call i32 @recv(i32 %0, i8* %3, i32 2048, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %26, label %6
6: ; preds = %1
%7 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @send(i32 %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %26, label %10
10: ; preds = %6
%11 = call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @send(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %26, label %14
14: ; preds = %10
%15 = call i32 @strlen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @send(i32 %0, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %15, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %26, label %18
18: ; preds = %14
%19 = call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @send(i32 %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %19, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 @send(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %23, i32 0)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %22, %18, %14, %10, %6, %1
%27 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %14 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %18 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %22 ]
%28 = call i32 @logmessage(i32 1, i8* %27)
br label %29
29: ; preds = %26, %22
ret void
}