#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*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ writeTo(int, char *);
void err_dump(int fd, int status, char *err_msg) {
  char line[1024];
  snprintf(line, 1024, "HTTP/1.1 %d %s\r\n\r\n", status, err_msg);
  writeTo(fd, line);
  snprintf(line, 1024, "ERROR: %d\r\n", status);
  writeTo(fd, line);
  snprintf(line, 1024, "ERROR MESSAGE: %s\r\n\r\n", err_msg);
  writeTo(fd, line);
}


x86 assembly (clang, -O0):
<err_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    $0x400,%esi
lea    0xeb1(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <writeTo@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x400,%esi
lea    0xe98(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <writeTo@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x400,%esi
lea    0xe77(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1040 <writeTo@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xec5(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x400,%esi
mov    %ebp,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <writeTo@plt>
lea    0xeb0(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <writeTo@plt>
lea    0xe9a(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <writeTo@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"HTTP/1.1 %d %s\0D\0A\0D\0A\00"
@.str.1 = [12 x i8] c"ERROR: %d\0D\0A\00"
@.str.2 = [22 x i8] c"ERROR MESSAGE: %s\0D\0A\0D\0A\00"
define void @err_dump(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [1024 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = load i32, i32* %5
%10 = load i8*, i8** %6
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %10)
%12 = load i32, i32* %4
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = call i32 @writeTo(i32 %12, i8* %13)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%16 = load i32, i32* %5
%17 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %15, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%20 = call i32 @writeTo(i32 %18, i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %21, i32 1024, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %4
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%26 = call i32 @writeTo(i32 %24, i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"HTTP/1.1 %d %s\0D\0A\0D\0A\00"
@.str.1 = [12 x i8] c"ERROR: %d\0D\0A\00"
@.str.2 = [22 x i8] c"ERROR MESSAGE: %s\0D\0A\0D\0A\00"
define void @err_dump(i32 %0, i32 %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %2)
%7 = call i32 @writeTo(i32 %0, i8* %5)
%8 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%9 = call i32 @writeTo(i32 %0, i8* %5)
%10 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%11 = call i32 @writeTo(i32 %0, i8* %5)
ret void
}