#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 /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void GenerateErrorPage(char *mem, int error) {
  char ln[1000], stat[1000], body[1000];
  if (error == 404) {
    sprintf(body, "<HTML><HEAD><TITLE>404 Not found</TITLE></HEAD><BODY>The "
                  "requested page was not found on this Server</BODY></HTML>");
    sprintf(stat, "HTTP/1.1 404 Not found\r\n");
  }
  strcpy(mem, stat);
  strcat(mem, "Date: Sun, 21 Dec 2003 23:10:01 GMT\r\n");
  strcat(mem, "Server: IRTrans 2.0\r\n");
  strcat(mem, "Mime-Version: 1.0\r\n");
  sprintf(ln, "Content-Type: text/html\r\nContent-Length: %6d\r\n",
          strlen(body));
  strcat(mem, ln);
  strcat(mem, "Expires: Sun, 21 Dec 2003 23:10:01 GMT\r\n");
  strcat(mem, "Cache-control: no-cache\r\n");
  strcat(mem, "\r\n");
  strcat(mem, body);
}


x86 assembly (clang, -O0):
<GenerateErrorPage>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x194,-0xc(%rbp)
jne    1189 <GenerateErrorPage+0x49>
lea    -0xbe0(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x7f0(%rbp),%rdi
lea    0xef1(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xee8(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xefe(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xf04(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x400(%rbp),%rax
mov    %rax,-0xbe8(%rbp)
lea    -0xbe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xbe8(%rbp),%rdi
mov    %eax,%edx
lea    0xee9(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xef6(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xf0f(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0xbe0(%rbp),%rsi
call   1050 <strcat@plt>
add    $0xbf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenerateErrorPage>:
push   %r15
push   %r14
push   %rbx
sub    $0xbd0,%rsp
mov    %rdi,%rbx
cmp    $0x194,%esi
jne    11d0 <GenerateErrorPage+0x90>
movups 0xf02(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movups 0xee6(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movups 0xeca(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xeae(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movups 0xe92(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe76(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe5a(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x3e4c4d,0x6f(%rsp)
movups 0xeba(%rip),%xmm0
movaps %xmm0,0x3f0(%rsp)
movups 0xeb4(%rip),%xmm0
movups %xmm0,0x3f9(%rsp)
lea    0x3f0(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xebd(%rip),%rsi
lea    0x7e0(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xee0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
add    $0xbd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [115 x i8] c"<HTML><HEAD><TITLE>404 Not found</TITLE></HEAD><BODY>The requested page was not found on this Server</BODY></HTML>\00"
@.str.1 = [25 x i8] c"HTTP/1.1 404 Not found\0D\0A\00"
@.str.2 = [38 x i8] c"Date: Sun, 21 Dec 2003 23:10:01 GMT\0D\0A\00"
@.str.3 = [22 x i8] c"Server: IRTrans 2.0\0D\0A\00"
@.str.4 = [20 x i8] c"Mime-Version: 1.0\0D\0A\00"
@.str.5 = [47 x i8] c"Content-Type: text/html\0D\0AContent-Length: %6d\0D\0A\00"
@.str.6 = [41 x i8] c"Expires: Sun, 21 Dec 2003 23:10:01 GMT\0D\0A\00"
@.str.7 = [26 x i8] c"Cache-control: no-cache\0D\0A\00"
@.str.8 = [3 x i8] c"\0D\0A\00"
define void @GenerateErrorPage(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 404
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %10, %2
%16 = load i8*, i8** %3
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%21 = load i8*, i8** %3
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8*, i8** %3
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = load i8*, i8** %3
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%34 = load i8*, i8** %3
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%36 = load i8*, i8** %3
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%38 = load i8*, i8** %3
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%40 = call i32 @strcat(i8* %38, i8* %39)
ret void
}

LLVM IR (-O2):
@.str = [115 x i8] c"<HTML><HEAD><TITLE>404 Not found</TITLE></HEAD><BODY>The requested page was not found on this Server</BODY></HTML>\00"
@.str.1 = [25 x i8] c"HTTP/1.1 404 Not found\0D\0A\00"
@.str.2 = [38 x i8] c"Date: Sun, 21 Dec 2003 23:10:01 GMT\0D\0A\00"
@.str.3 = [22 x i8] c"Server: IRTrans 2.0\0D\0A\00"
@.str.4 = [20 x i8] c"Mime-Version: 1.0\0D\0A\00"
@.str.5 = [47 x i8] c"Content-Type: text/html\0D\0AContent-Length: %6d\0D\0A\00"
@.str.6 = [41 x i8] c"Expires: Sun, 21 Dec 2003 23:10:01 GMT\0D\0A\00"
@.str.7 = [26 x i8] c"Cache-control: no-cache\0D\0A\00"
@.str.8 = [3 x i8] c"\0D\0A\00"
define void @GenerateErrorPage(i8* %0, i32 %1) {
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %1, 404
br i1 %9, label %10, label %11
10: ; preds = %2
br label %11
11: ; preds = %10, %2
%12 = call i32 @strcpy(i8* %0, i8* %7)
%13 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @strlen(i8* %8)
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = call i32 @strcat(i8* %0, i8* %6)
%19 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 @strcat(i8* %0, i8* %8)
ret void
}