#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*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ write_socket(int, char *, int);
void not_found(int client_sockfd) {
  char buffer[8096];
  char body[8096];
  sprintf(buffer, "HTTP/1.1 404 File Not Found\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Server: httpServer/0.1.1\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Content-Type: text/html\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(body, "<HTML><HEAD><TITLE>File Not Found</TITLE></HEAD>\r\n");
  sprintf(body + strlen(body),
          "<BODY><P>File not found.</P></BODY></HTML>\r\n");
  sprintf(buffer, "Content-Length: %ld\r\n", strlen(body));
  write_socket(client_sockfd, buffer, strlen(buffer));
  write_socket(client_sockfd, "\r\n", strlen("\r\n"));
  write_socket(client_sockfd, body, strlen(body));
}


x86 assembly (clang, -O0):
<not_found>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3fb0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x1fb0(%rbp),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3fac(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3fa8(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3fac(%rbp),%edi
mov    -0x3fa8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f9c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f98(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f9c(%rbp),%edi
mov    -0x3f98(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f8c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f88(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f8c(%rbp),%edi
mov    -0x3f88(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x3f50(%rbp),%rdi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f80(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f80(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f78(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f78(%rbp),%rdi
mov    %eax,%edx
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f6c(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f68(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f6c(%rbp),%edi
mov    -0x3f68(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f60(%rbp)
lea    0xd53(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x3f60(%rbp),%edi
mov    %eax,%edx
lea    0xd3f(%rip),%rsi
call   1030 <write_socket@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f5c(%rbp)
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f58(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f5c(%rbp),%edi
mov    -0x3f58(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3fb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<not_found>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f40,%rsp
mov    %edi,%ebx
movups 0xebb(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xeba(%rip),%xmm0
movups %xmm0,0x1fae(%rsp)
lea    0x1fa0(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe9f(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xe9b(%rip),%xmm0
movups %xmm0,0x1fab(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe88(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xe83(%rip),%xmm0
movups %xmm0,0x1faa(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe70(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe75(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe79(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0xa0d3e,0x2f(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movups 0xe6b(%rip),%xmm0
movups %xmm0,(%rsp,%rax,1)
movups 0xe70(%rip),%xmm0
movups %xmm0,0x10(%rsp,%rax,1)
movups 0xe71(%rip),%xmm0
movups %xmm0,0x1d(%rsp,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    0xdc9(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3f40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"HTTP/1.1 404 File Not Found\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.3 = [51 x i8] c"<HTML><HEAD><TITLE>File Not Found</TITLE></HEAD>\0D\0A\00"
@.str.4 = [45 x i8] c"<BODY><P>File not found.</P></BODY></HTML>\0D\0A\00"
@.str.5 = [22 x i8] c"Content-Length: %ld\0D\0A\00"
@.str.6 = [3 x i8] c"\0D\0A\00"
define void @not_found(i32 %0) {
%2 = alloca i32
%3 = alloca [8096 x i8]
%4 = alloca [8096 x i8]
store i32 %0, i32* %2
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @write_socket(i32 %7, i8* %8, i32 %10)
%12 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @write_socket(i32 %14, i8* %15, i32 %17)
%19 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @write_socket(i32 %21, i8* %22, i32 %24)
%26 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%29 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%34 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%35 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %2
%39 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%40 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = call i32 @write_socket(i32 %38, i8* %39, i32 %41)
%43 = load i32, i32* %2
%44 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%45 = call i32 @write_socket(i32 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %2
%47 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%48 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @write_socket(i32 %46, i8* %47, i32 %49)
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"HTTP/1.1 404 File Not Found\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.3 = [51 x i8] c"<HTML><HEAD><TITLE>File Not Found</TITLE></HEAD>\0D\0A\00"
@.str.4 = [45 x i8] c"<BODY><P>File not found.</P></BODY></HTML>\0D\0A\00"
@.str.5 = [22 x i8] c"Content-Length: %ld\0D\0A\00"
@.str.6 = [3 x i8] c"\0D\0A\00"
define void @not_found(i32 %0) {
%2 = alloca [8096 x i8]
%3 = alloca [8096 x i8]
%4 = getelementptr inbounds [8096 x i8], [8096 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 @strlen(i8* %4)
%7 = call i32 @write_socket(i32 %0, i8* %4, i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @write_socket(i32 %0, i8* %4, i32 %8)
%10 = call i32 @strlen(i8* %4)
%11 = call i32 @write_socket(i32 %0, i8* %4, i32 %10)
%12 = call i32 @strlen(i8* %5)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 %13
%15 = call i32 @strlen(i8* %5)
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = call i32 @strlen(i8* %4)
%18 = call i32 @write_socket(i32 %0, i8* %4, i32 %17)
%19 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @write_socket(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %19)
%21 = call i32 @strlen(i8* %5)
%22 = call i32 @write_socket(i32 %0, i8* %5, i32 %21)
ret void
}