#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*/ close(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
void not_found(int sockfd, char *filename) {
  char buf[1024];
  char *err_404 = NULL;
  err_404 = (char *)malloc(1000 * sizeof(char));
  strcpy(err_404, "<html>\r\n<head><title>404 File Not "
                  "Exists</title></head><body "
                  "bgcolor=\"white\">\r\n<center><h1>404 file :");
  strcat(err_404, filename);
  strcat(err_404,
         "; you request is not exists</h1></center>\r\n</body>\r\n</html>");
  sprintf(buf, "HTTP/1.1 404 Not Found\r\n");
  send(sockfd, buf, strlen(buf), 0);
  sprintf(buf, "Content-Length: %lu\r\n", strlen(err_404));
  send(sockfd, buf, strlen(buf), 0);
  sprintf(buf, "Connection: close\r\n");
  send(sockfd, buf, strlen(buf), 0);
  strcpy(buf, "\r\n");
  send(sockfd, buf, strlen(buf), 0);
  strcpy(buf, err_404);
  send(sockfd, buf, strlen(err_404), 0);
  close(sockfd);
  free(err_404);
  err_404 = NULL;
}


x86 assembly (clang, -O0):
<not_found>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x418(%rbp)
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x418(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x418(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x46c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x468(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x46c(%rbp),%edi
mov    -0x468(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x460(%rbp)
mov    -0x418(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x460(%rbp),%rdi
mov    %eax,%edx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x454(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x454(%rbp),%edi
mov    -0x450(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x444(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x444(%rbp),%edi
mov    -0x440(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    -0x410(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x434(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x424(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x418(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x424(%rbp),%edi
mov    -0x420(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    -0x4(%rbp),%edi
call   1070 <close@plt>
mov    -0x418(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x418(%rbp)
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<not_found>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe5b(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <strcat@plt>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
movups 0xed4(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xed2(%rip),%xmm0
movups %xmm0,0x9(%rsp)
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xeb4(%rip),%rsi
mov    %rbp,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
movups 0xea0(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa0d65,0x10(%rsp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    0xe5d(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [102 x i8] c"<html>\0D\0A<head><title>404 File Not Exists</title></head><body bgcolor=\22white\22>\0D\0A<center><h1>404 file :\00"
@.str.1 = [60 x i8] c"; you request is not exists</h1></center>\0D\0A</body>\0D\0A</html>\00"
@.str.2 = [25 x i8] c"HTTP/1.1 404 Not Found\0D\0A\00"
@.str.3 = [22 x i8] c"Content-Length: %lu\0D\0A\00"
@.str.4 = [20 x i8] c"Connection: close\0D\0A\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @not_found(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* null, i8** %6
%7 = call i64 @malloc(i32 1000)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %6
%12 = load i8*, i8** %4
%13 = call i32 @strcat(i8* %11, i8* %12)
%14 = load i8*, i8** %6
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %3
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @send(i32 %18, i8* %19, i32 %21, i32 0)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @send(i32 %27, i8* %28, i32 %30, i32 0)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* %3
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = call i32 @send(i32 %34, i8* %35, i32 %37, i32 0)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%40 = call i32 @strcpy(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* %3
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = call i32 @send(i32 %41, i8* %42, i32 %44, i32 0)
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%47 = load i8*, i8** %6
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = load i32, i32* %3
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%51 = load i8*, i8** %6
%52 = call i32 @strlen(i8* %51)
%53 = call i32 @send(i32 %49, i8* %50, i32 %52, i32 0)
%54 = load i32, i32* %3
%55 = call i32 @close(i32 %54)
%56 = load i8*, i8** %6
%57 = call i32 @free(i8* %56)
store i8* null, i8** %6
ret void
}

LLVM IR (-O2):
@.str = [102 x i8] c"<html>\0D\0A<head><title>404 File Not Exists</title></head><body bgcolor=\22white\22>\0D\0A<center><h1>404 file :\00"
@.str.1 = [60 x i8] c"; you request is not exists</h1></center>\0D\0A</body>\0D\0A</html>\00"
@.str.2 = [25 x i8] c"HTTP/1.1 404 Not Found\0D\0A\00"
@.str.3 = [22 x i8] c"Content-Length: %lu\0D\0A\00"
@.str.4 = [20 x i8] c"Connection: close\0D\0A\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @not_found(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @malloc(i32 1000)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %6, i8* %1)
%9 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strlen(i8* %4)
%11 = call i32 @send(i32 %0, i8* %4, i32 %10, i32 0)
%12 = call i32 @strlen(i8* %6)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 @strlen(i8* %4)
%15 = call i32 @send(i32 %0, i8* %4, i32 %14, i32 0)
%16 = call i32 @strlen(i8* %4)
%17 = call i32 @send(i32 %0, i8* %4, i32 %16, i32 0)
%18 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @strlen(i8* %4)
%20 = call i32 @send(i32 %0, i8* %4, i32 %19, i32 0)
%21 = call i32 @strcpy(i8* %4, i8* %6)
%22 = call i32 @strlen(i8* %6)
%23 = call i32 @send(i32 %0, i8* %4, i32 %22, i32 0)
%24 = call i32 @close(i32 %0)
%25 = call i32 @free(i8* %6)
ret void
}