#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 my_write(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int error_page(int sock_fd) {
  char err_str[1024];
  sprintf(err_str, "HTTP/1.1 404 Not Exsit\r\n");
  if (my_write(sock_fd, err_str, strlen(err_str)) == -1)
    return -1;
  if (my_write(sock_fd, "Content-Type: text/html\r\n\r\n",
               strlen("Content-Type: text/html\r\n\r\n")) == -1)
    return -1;
  if (my_write(sock_fd, "<html><body> the file dose not exsit </body></html>",
               strlen("<html><body> the file dose not exsit </body></html>")) ==
      -1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<error_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x41c(%rbp),%edi
mov    -0x418(%rbp),%rsi
mov    %eax,%edx
call   1040 <my_write@plt>
cmp    $0xffffffff,%eax
jne    119d <error_page+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <error_page+0xf0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x420(%rbp)
lea    0xe6c(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x420(%rbp),%edi
mov    %eax,%edx
lea    0xe58(%rip),%rsi
call   1040 <my_write@plt>
cmp    $0xffffffff,%eax
jne    11db <error_page+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <error_page+0xf0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x424(%rbp)
lea    0xe4a(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x424(%rbp),%edi
mov    %eax,%edx
lea    0xe36(%rip),%rsi
call   1040 <my_write@plt>
cmp    $0xffffffff,%eax
jne    1219 <error_page+0xe9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <error_page+0xf0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_page>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edi,%ebx
movups 0xed5(%rip),%xmm0
movups %xmm0,0x9(%rsp)
movups 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <my_write@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     11ab <error_page+0x8b>
lea    0xead(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <my_write@plt>
cmp    $0xffffffff,%eax
je     11ab <error_page+0x8b>
lea    0xea9(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <my_write@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
sete   %bpl
neg    %ebp
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"HTTP/1.1 404 Not Exsit\0D\0A\00"
@.str.1 = [28 x i8] c"Content-Type: text/html\0D\0A\0D\0A\00"
@.str.2 = [52 x i8] c"<html><body> the file dose not exsit </body></html>\00"
define i32 @error_page(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
store i32 %0, i32* %3
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %3
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @my_write(i32 %7, i8* %8, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %27
14: ; preds = %1
%15 = load i32, i32* %3
%16 = call i32 @strlen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @my_write(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 -1, i32* %2
br label %27
20: ; preds = %14
%21 = load i32, i32* %3
%22 = call i32 @strlen(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @my_write(i32 %21, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -1, i32* %2
br label %27
26: ; preds = %20
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %19, %13
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [25 x i8] c"HTTP/1.1 404 Not Exsit\0D\0A\00"
@.str.1 = [28 x i8] c"Content-Type: text/html\0D\0A\0D\0A\00"
@.str.2 = [52 x i8] c"<html><body> the file dose not exsit </body></html>\00"
define i32 @error_page(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = call i32 @my_write(i32 %0, i8* %3, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %16, label %7
7: ; preds = %1
%8 = call i32 @strlen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @my_write(i32 %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = call i32 @strlen(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @my_write(i32 %0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, -1
%15 = sext i1 %14 to i32
br label %16
16: ; preds = %11, %7, %1
%17 = phi i32 [ -1, %1 ], [ -1, %7 ], [ %15, %11 ]
ret i32 %17
}