#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 */
struct connectiondata {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ set_write_content(struct connectiondata *, char *,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
void write_INTERNAL_SERVER_ERROR(struct connectiondata *cp, char *curr_time) {
  char temp[4096] = {0};
  strcat(temp, "HTTP/1.1 500 Internal Server Error\n");
  strcat(temp, "Date: ");
  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 ");
  strcat(temp, "work</h2>\nI had some sort of problem ");
  strcat(temp, "dealing with your request. Sorry, ");
  strcat(temp, "I'm lame.\n</body></html>");
  set_write_content(cp, temp, strlen(temp));
}


x86 assembly (clang, -O0):
<write_INTERNAL_SERVER_ERROR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x1010(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x1020(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1020(%rbp),%rdi
mov    -0x1018(%rbp),%rsi
mov    %eax,%edx
call   1050 <set_write_content@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_INTERNAL_SERVER_ERROR>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xee9(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <set_write_content@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.connectiondata = type { i32 }
@.str = [36 x i8] c"HTTP/1.1 500 Internal Server Error\0A\00"
@.str.1 = [7 x i8] c"Date: \00"
@.str.2 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.3 = [22 x i8] c"Content-Length: 131\0A\0A\00"
@.str.4 = [36 x i8] c"<html><body>\0A<h2>Oops. That didn't \00"
@.str.5 = [38 x i8] c"work</h2>\0AI had some sort of problem \00"
@.str.6 = [35 x i8] c"dealing with your request. Sorry, \00"
@.str.7 = [25 x i8] c"I'm lame.\0A</body></html>\00"
define void @write_INTERNAL_SERVER_ERROR(%struct.connectiondata* %0, i8* %1) {
%3 = alloca %struct.connectiondata*
%4 = alloca i8*
%5 = alloca [4096 x i8]
store %struct.connectiondata* %0, %struct.connectiondata** %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 ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = call i32 @strcat(i8* %11, i8* %12)
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([26 x i8], [26 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 ([22 x i8], [22 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 ([36 x i8], [36 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 ([38 x i8], [38 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 ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%26 = load %struct.connectiondata*, %struct.connectiondata** %3
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @set_write_content(%struct.connectiondata* %26, i8* %27, i32 %29)
ret void
}

LLVM IR (-O2):
%struct.connectiondata = type { i32 }
@.str = [36 x i8] c"HTTP/1.1 500 Internal Server Error\0A\00"
@.str.1 = [7 x i8] c"Date: \00"
@.str.2 = [26 x i8] c"\0AContent-Type: text/html\0A\00"
@.str.3 = [22 x i8] c"Content-Length: 131\0A\0A\00"
@.str.4 = [36 x i8] c"<html><body>\0A<h2>Oops. That didn't \00"
@.str.5 = [38 x i8] c"work</h2>\0AI had some sort of problem \00"
@.str.6 = [35 x i8] c"dealing with your request. Sorry, \00"
@.str.7 = [25 x i8] c"I'm lame.\0A</body></html>\00"
define void @write_INTERNAL_SERVER_ERROR(%struct.connectiondata* %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 ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @strcat(i8* %4, i8* %1)
%8 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @strlen(i8* %4)
%15 = call i32 @set_write_content(%struct.connectiondata* %0, i8* %4, i32 %14)
ret void
}