#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*/ fdputs(int, char *);
int /*<<< orphan*/ fdputsf(int, char *, char const *);
int /*<<< orphan*/ send_header_textplain(int);
int /*<<< orphan*/ send_http_response(int, char const *);
void send_http_error(int clientsock, const char *code, const char *message) {
  send_http_response(clientsock, code);
  send_header_textplain(clientsock);
  if (message) {
    fdputsf(clientsock, "X-Error: %s\n", message);
  }
  fdputs(clientsock, "\n");
  fdputsf(clientsock, "%s\n", message ? message : code);
}


x86 assembly (clang, -O0):
<send_http_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <send_http_response@plt>
mov    -0x4(%rbp),%edi
call   1030 <send_header_textplain@plt>
cmpq   $0x0,-0x18(%rbp)
je     1185 <send_http_error+0x45>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1050 <fdputsf@plt>
mov    -0x4(%rbp),%edi
lea    0xe7c(%rip),%rsi
call   1060 <fdputs@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b2 <send_http_error+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11ba <send_http_error+0x7a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rdx
lea    0xe41(%rip),%rsi
call   1050 <fdputsf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_http_error>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%ebx
call   1040 <send_http_response@plt>
mov    %ebx,%edi
call   1030 <send_header_textplain@plt>
test   %r15,%r15
je     1172 <send_http_error+0x32>
lea    0xe9b(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
call   1050 <fdputsf@plt>
mov    %r15,%r14
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
call   1060 <fdputs@plt>
lea    0xe82(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fdputsf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"X-Error: %s\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @send_http_error(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* %4
%8 = load i8*, i8** %5
%9 = call i32 @send_http_response(i32 %7, i8* %8)
%10 = load i32, i32* %4
%11 = call i32 @send_header_textplain(i32 %10)
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i8*, i8** %6
%17 = call i32 @fdputsf(i32 %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %3
%19 = load i32, i32* %4
%20 = call i32 @fdputs(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %4
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = load i8*, i8** %6
br label %28
26: ; preds = %18
%27 = load i8*, i8** %5
br label %28
28: ; preds = %26, %24
%29 = phi i8* [ %25, %24 ], [ %27, %26 ]
%30 = call i32 @fdputsf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"X-Error: %s\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @send_http_error(i32 %0, i8* %1, i8* %2) {
%4 = tail call i32 @send_http_response(i32 %0, i8* %1)
%5 = tail call i32 @send_header_textplain(i32 %0)
%6 = icmp eq i8* %2, null
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @fdputsf(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %7, %3
%10 = phi i8* [ %2, %7 ], [ %1, %3 ]
%11 = tail call i32 @fdputs(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @fdputsf(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %10)
ret void
}