#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*/ http_send(int, char *, ...);
int strlen(char const *);
int send_error(int socket, int code, const char *msg) {
  char *body = ""
               "<html>\n"
               "  <head>\n"
               "    <title>No.</title>\n"
               "  </head>\n"
               "  <body>\n"
               "    <center><h1>%d %s</h1></center>\n"
               "    <hr><center>Super Secure Web Server v.3.1.33.7</center>\n"
               "  </body>\n"
               "</html>";
  http_send(socket,
            "HTTP/1.1 %d %s"
            "\r\n",
            code, msg);
  http_send(socket, "Content-Type: text/html"
                    "\r\n");
  http_send(socket,
            "Content-Length: %d"
            "\r\n\r\n",
            strlen(body) + 3 + strlen(msg) - 4);
  http_send(socket, body, code, msg);
  return code;
}


x86 assembly (clang, -O0):
<send_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xf5e(%rip),%rsi
mov    $0x0,%al
call   1040 <http_send@plt>
mov    -0x4(%rbp),%edi
lea    0xf5e(%rip),%rsi
mov    $0x0,%al
call   1040 <http_send@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x3,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%edi
add    %eax,%edx
sub    $0x4,%edx
lea    0xf41(%rip),%rsi
mov    $0x0,%al
call   1040 <http_send@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1040 <http_send@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_error>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xf75(%rip),%rsi
mov    %r14d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <http_send@plt>
lea    0xf72(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <http_send@plt>
lea    0xea5(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%edx
add    $0xffffffff,%edx
lea    0xf5d(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <http_send@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <http_send@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [172 x i8] c"<html>\0A <head>\0A <title>No.</title>\0A </head>\0A <body>\0A <center><h1>%d %s</h1></center>\0A <hr><center>Super Secure Web Server v.3.1.33.7</center>\0A </body>\0A</html>\00"
@.str.1 = [17 x i8] c"HTTP/1.1 %d %s\0D\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.3 = [23 x i8] c"Content-Length: %d\0D\0A\0D\0A\00"
define i32 @send_error(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i8*, i8** %6
%11 = call i32 (i32, i8*, ...) @http_send(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %10)
%12 = load i32, i32* %4
%13 = call i32 (i32, i8*, ...) @http_send(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %4
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 3
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = sub nsw i32 %20, 4
%22 = call i32 (i32, i8*, ...) @http_send(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %4
%24 = load i8*, i8** %7
%25 = load i32, i32* %5
%26 = load i8*, i8** %6
%27 = call i32 (i32, i8*, ...) @http_send(i32 %23, i8* %24, i32 %25, i8* %26)
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
@.str = [172 x i8] c"<html>\0A <head>\0A <title>No.</title>\0A </head>\0A <body>\0A <center><h1>%d %s</h1></center>\0A <hr><center>Super Secure Web Server v.3.1.33.7</center>\0A </body>\0A</html>\00"
@.str.1 = [17 x i8] c"HTTP/1.1 %d %s\0D\0A\00"
@.str.2 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.3 = [23 x i8] c"Content-Length: %d\0D\0A\0D\0A\00"
define i32 @send_error(i32 %0, i32 returned %1, i8* %2) {
%4 = tail call i32 (i32, i8*, ...) @http_send(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2)
%5 = tail call i32 (i32, i8*, ...) @http_send(i32 %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strlen(i8* %2)
%8 = add i32 %6, -1
%9 = add i32 %8, %7
%10 = tail call i32 (i32, i8*, ...) @http_send(i32 %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = tail call i32 (i32, i8*, ...) @http_send(i32 %0, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %2)
ret i32 %1
}