#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 */
scalar_t__ build_headers(char *, int, char *, char *, int, int);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ sprintf(char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
void send_error(int status, char *title, char *text, int sockfd) {
  char buffer[8192];
  int index = 0;
  index += build_headers(buffer + index, status, title, "text/html", -1, -1);
  index += sprintf(
      buffer + index,
      "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
      "\"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n  <head>\n    <meta "
      "http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n    "
      "<title>%d %s</title>\n  </head>\n  <body bgcolor=\"#cc9999\" "
      "text=\"#000000\" link=\"#2020ff\" vlink=\"#4040cc\">\n    <h4>%d "
      "%s</h4>\n\n",
      status, title, status, title);
  index += sprintf(buffer + index, "%s\n\n", text);
  index += sprintf(buffer + index,
                   "    <hr>\n    <address><a href=\"%s\">%s</a></address>\n  "
                   "</body>\n</html>\n",
                   "http://www.acme.com/software/micro_proxy/", "micro_proxy");
  send(sockfd, buffer, strlen(buffer), 0);
}


x86 assembly (clang, -O0):
<send_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x2024(%rbp)
lea    -0x2020(%rbp),%rdi
movslq -0x2024(%rbp),%rax
add    %rax,%rdi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe7e(%rip),%rcx
mov    $0xffffffff,%r9d
mov    %r9d,%r8d
call   1050 <build_headers@plt>
mov    %rax,%rcx
movslq -0x2024(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2024(%rbp)
lea    -0x2020(%rbp),%rdi
movslq -0x2024(%rbp),%rax
add    %rax,%rdi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %rax,%rcx
movslq -0x2024(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2024(%rbp)
lea    -0x2020(%rbp),%rdi
movslq -0x2024(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
lea    0xf49(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %rax,%rcx
movslq -0x2024(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2024(%rbp)
lea    -0x2020(%rbp),%rdi
movslq -0x2024(%rbp),%rax
add    %rax,%rdi
lea    0xf1c(%rip),%rsi
lea    0xf5c(%rip),%rdx
lea    0xf7f(%rip),%rcx
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %rax,%rcx
movslq -0x2024(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2024(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2034(%rbp)
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2030(%rbp)
lea    -0x2020(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2034(%rbp),%edi
mov    -0x2030(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9d(%rip),%rcx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    $0xffffffff,%r8d
mov    $0xffffffff,%r9d
call   1050 <build_headers@plt>
mov    %rax,%r13
movslq %r13d,%rax
lea    (%rsp,%rax,1),%rdi
lea    0xe7a(%rip),%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %rbx,%r9
xor    %eax,%eax
call   1060 <sprintf@plt>
add    %r13,%rax
movslq %eax,%rbx
lea    (%rsp,%rbx,1),%rdi
lea    0xf96(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
add    %eax,%ebx
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rdi
lea    0xf81(%rip),%rsi
lea    0xfc1(%rip),%rdx
lea    0xfe4(%rip),%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"text/html\00"
@.str.1 = [319 x i8] c"<!DOCTYPE html PUBLIC \22-//W3C//DTD HTML 4.01 Transitional//EN\22 \22http://www.w3.org/TR/html4/loose.dtd\22>\0A<html>\0A <head>\0A <meta http-equiv=\22Content-type\22 content=\22text/html;charset=UTF-8\22>\0A <title>%d %s</title>\0A </head>\0A <body bgcolor=\22#cc9999\22 text=\22\22 link=\22ff\22 vlink=\22cc\22>\0A <h4>%d %s</h4>\0A\0A\00"
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.3 = [71 x i8] c" <hr>\0A <address><a href=\22%s\22>%s</a></address>\0A </body>\0A</html>\0A\00"
@.str.4 = [42 x i8] c"http://www.acme.com/software/micro_proxy/\00"
@.str.5 = [12 x i8] c"micro_proxy\00"
define void @send_error(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [8192 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %10
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* %10
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i32, i32* %5
%16 = load i8*, i8** %6
%17 = call i64 @build_headers(i8* %14, i32 %15, i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -1, i32 -1)
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = add nsw i64 %19, %17
%21 = trunc i64 %20 to i32
store i32 %21, i32* %10
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i32, i32* %5
%27 = load i8*, i8** %6
%28 = load i32, i32* %5
%29 = load i8*, i8** %6
%30 = call i64 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([319 x i8], [319 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27, i32 %28, i8* %29)
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = add nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %10
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8*, i8** %7
%40 = call i64 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = add nsw i64 %42, %40
%44 = trunc i64 %43 to i32
store i32 %44, i32* %10
%45 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = call i64 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = add nsw i64 %51, %49
%53 = trunc i64 %52 to i32
store i32 %53, i32* %10
%54 = load i32, i32* %8
%55 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = call i32 @send(i32 %54, i8* %55, i32 %57, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"text/html\00"
@.str.1 = [319 x i8] c"<!DOCTYPE html PUBLIC \22-//W3C//DTD HTML 4.01 Transitional//EN\22 \22http://www.w3.org/TR/html4/loose.dtd\22>\0A<html>\0A <head>\0A <meta http-equiv=\22Content-type\22 content=\22text/html;charset=UTF-8\22>\0A <title>%d %s</title>\0A </head>\0A <body bgcolor=\22#cc9999\22 text=\22\22 link=\22ff\22 vlink=\22cc\22>\0A <h4>%d %s</h4>\0A\0A\00"
@.str.2 = [5 x i8] c"%s\0A\0A\00"
@.str.3 = [71 x i8] c" <hr>\0A <address><a href=\22%s\22>%s</a></address>\0A </body>\0A</html>\0A\00"
@.str.4 = [42 x i8] c"http://www.acme.com/software/micro_proxy/\00"
@.str.5 = [12 x i8] c"micro_proxy\00"
define void @send_error(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [8192 x i8]
%6 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%7 = call i64 @build_headers(i8* %6, i32 %0, i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -1, i32 -1)
%8 = shl i64 %7, 32
%9 = ashr exact i64 %8, 32
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 %9
%11 = call i64 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([319 x i8], [319 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %1, i32 %0, i8* %1)
%12 = add i64 %11, %7
%13 = shl i64 %12, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 %14
%16 = call i64 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%17 = add i64 %12, %16
%18 = shl i64 %17, 32
%19 = ashr exact i64 %18, 32
%20 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 %19
%21 = call i64 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @strlen(i8* %6)
%23 = call i32 @send(i32 %3, i8* %6, i32 %22, i32 0)
ret void
}