#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*/ SendHeaders(int, int, char *, char *, char *, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int SendError(int client_sock, int status, char *title, char *extra_header,
              char *text) {
  char buf[8192], buf_all[10240];
  SendHeaders(client_sock, status, title, extra_header, "text/html", -1, -1);
  memset(buf, 0, strlen(buf));
  sprintf(buf,
          "<html>\n<head>\n<title>%d %s - %s</title>\n</head>\n<body>\n<h2>%d "
          "%s</h2>\n",
          status, title, "tmhttpd/1.0.0_alpha", status, title);
  strcat(buf_all, buf);
  memset(buf, 0, strlen(buf));
  sprintf(buf, "%s\n", text);
  strcat(buf_all, buf);
  memset(buf, 0, strlen(buf));
  sprintf(buf,
          "\n<br /><br /><hr />\n<address>%s</address>\n</body>\n</html>\n",
          "tmhttpd/1.0.0_alpha");
  strcat(buf_all, buf);
  write(client_sock, buf_all, strlen(buf_all));
  exit(0);
}


x86 assembly (clang, -O0):
<SendError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4850,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe5e(%rip),%r8
mov    $0xffffffff,%r9d
movl   $0xffffffff,(%rsp)
call   1050 <SendHeaders@plt>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x4848(%rbp)
lea    -0x2020(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4848(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    -0x2020(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r9d
mov    -0x10(%rbp),%rax
lea    0xe0f(%rip),%rsi
lea    0xe4f(%rip),%r8
mov    %rax,(%rsp)
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x4820(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x4840(%rbp)
lea    -0x2020(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4840(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    -0x2020(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x4820(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x2020(%rbp),%rax
mov    %rax,-0x4838(%rbp)
lea    -0x2020(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x4838(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    -0x2020(%rbp),%rdi
lea    0xdbb(%rip),%rsi
lea    0xd9c(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x4820(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x482c(%rbp)
lea    -0x4820(%rbp),%rax
mov    %rax,-0x4828(%rbp)
lea    -0x4820(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x482c(%rbp),%edi
mov    -0x4828(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<SendError>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4818,%rsp
mov    %r8,%r14
mov    %rdx,%rbp
mov    %esi,%r13d
mov    %edi,%r15d
movl   $0xffffffff,(%rsp)
lea    0xe65(%rip),%r8
mov    $0xffffffff,%r9d
call   1050 <SendHeaders@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1060 <memset@plt>
mov    %rbp,(%rsp)
lea    0xe40(%rip),%rsi
lea    0xe80(%rip),%r12
mov    %rbx,%rdi
mov    %r13d,%edx
mov    %rbp,%rcx
mov    %r12,%r8
mov    %r13d,%r9d
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0x2010(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1060 <memset@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1060 <memset@plt>
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"text/html\00"
@.str.1 = [71 x i8] c"<html>\0A<head>\0A<title>%d %s - %s</title>\0A</head>\0A<body>\0A<h2>%d %s</h2>\0A\00"
@.str.2 = [20 x i8] c"tmhttpd/1.0.0_alpha\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [59 x i8] c"\0A<br /><br /><hr />\0A<address>%s</address>\0A</body>\0A</html>\0A\00"
define i32 @SendError(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [8192 x i8]
%12 = alloca [10240 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = call i32 @SendHeaders(i32 %13, i32 %14, i8* %15, i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -1, i32 -1)
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @memset(i8* %18, i32 0, i32 %20)
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%23 = load i32, i32* %7
%24 = load i8*, i8** %8
%25 = load i32, i32* %7
%26 = load i8*, i8** %8
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %25, i8* %26)
%28 = getelementptr inbounds [10240 x i8], [10240 x i8]* %12, i64 0, i64 0
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%32 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = call i32 @memset(i8* %31, i32 0, i32 %33)
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%36 = load i8*, i8** %10
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [10240 x i8], [10240 x i8]* %12, i64 0, i64 0
%39 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%40 = call i32 @strcat(i8* %38, i8* %39)
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%42 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @memset(i8* %41, i32 0, i32 %43)
%45 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%47 = getelementptr inbounds [10240 x i8], [10240 x i8]* %12, i64 0, i64 0
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%49 = call i32 @strcat(i8* %47, i8* %48)
%50 = load i32, i32* %6
%51 = getelementptr inbounds [10240 x i8], [10240 x i8]* %12, i64 0, i64 0
%52 = getelementptr inbounds [10240 x i8], [10240 x i8]* %12, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = call i32 @write(i32 %50, i8* %51, i32 %53)
%55 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"text/html\00"
@.str.1 = [71 x i8] c"<html>\0A<head>\0A<title>%d %s - %s</title>\0A</head>\0A<body>\0A<h2>%d %s</h2>\0A\00"
@.str.2 = [20 x i8] c"tmhttpd/1.0.0_alpha\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [59 x i8] c"\0A<br /><br /><hr />\0A<address>%s</address>\0A</body>\0A</html>\0A\00"
define i32 @SendError(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [8192 x i8]
%7 = alloca [10240 x i8]
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 0
%10 = tail call i32 @SendHeaders(i32 %0, i32 %1, i8* %2, i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -1, i32 -1)
%11 = call i32 @strlen(i8* %8)
%12 = call i32 @memset(i8* %8, i32 0, i32 %11)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %1, i8* %2)
%14 = call i32 @strcat(i8* %9, i8* %8)
%15 = call i32 @strlen(i8* %8)
%16 = call i32 @memset(i8* %8, i32 0, i32 %15)
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%18 = call i32 @strcat(i8* %9, i8* %8)
%19 = call i32 @strlen(i8* %8)
%20 = call i32 @memset(i8* %8, i32 0, i32 %19)
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @strcat(i8* %9, i8* %8)
%23 = call i32 @strlen(i8* %9)
%24 = call i32 @write(i32 %0, i8* %9, i32 %23)
%25 = call i32 @exit(i32 0)
unreachable
}