#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*/ strcat(char *, char *);
int /*<<< orphan*/ write_to_client(int, char *);
void write_INTERNAL_SERVER_ERROR(int clientsd, char *curr_time) {
  char temp[4096] = {0};
  strcat(temp, "HTTP/1.1 500 Internal Server Error\nDate: ");
  strcat(temp, curr_time);
  strcat(temp, "\nContent-Type: text/html\n");
  strcat(temp, "Content-Length: 131\n\n");
  strcat(temp, "<html><body>\n<h2>Oops. That didn't work");
  strcat(temp, "</h2>\nI had some sort of problem dealing with ");
  strcat(temp, "your request. Sorry, I'm lame.\n");
  strcat(temp, "</body></html>");
  write_to_client(clientsd, temp);
}


x86 assembly (clang, -O0):
<write_INTERNAL_SERVER_ERROR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xedf(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xeec(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x4(%rbp),%edi
lea    -0x1010(%rbp),%rsi
call   1030 <write_to_client@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_INTERNAL_SERVER_ERROR>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcat@plt>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xee1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xf01(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xf12(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <write_to_client@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"HTTP/1.1 500 Internal Server Error\0ADate: \00"
@.str.1 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.2 = [22 x i8] c"Content-Length: 131\0A\0A\00"
@.str.3 = [40 x i8] c"<html><body>\0A<h2>Oops. That didn't work\00"
@.str.4 = [47 x i8] c"</h2>\0AI had some sort of problem dealing with \00"
@.str.5 = [32 x i8] c"your request. Sorry, I'm lame.\0A\00"
@.str.6 = [15 x i8] c"</body></html>\00"
define void @write_INTERNAL_SERVER_ERROR(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [4096 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = bitcast [4096 x i8]* %5 to i8*
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strcat(i8* %9, i8* %10)
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%13 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%26 = call i32 @write_to_client(i32 %24, i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"HTTP/1.1 500 Internal Server Error\0ADate: \00"
@.str.1 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.2 = [22 x i8] c"Content-Length: 131\0A\0A\00"
@.str.3 = [40 x i8] c"<html><body>\0A<h2>Oops. That didn't work\00"
@.str.4 = [47 x i8] c"</h2>\0AI had some sort of problem dealing with \00"
@.str.5 = [32 x i8] c"your request. Sorry, I'm lame.\0A\00"
@.str.6 = [15 x i8] c"</body></html>\00"
define void @write_INTERNAL_SERVER_ERROR(i32 %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcat(i8* %4, i8* %1)
%7 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @write_to_client(i32 %0, i8* %4)
ret void
}