#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                   char const *);
int /*<<< orphan*/ send_status(int /*<<< orphan*/ *, int, char const *);
int /*<<< orphan*/ strlen(char const *);
void send_response(FILE *client, int code, const char *reason_phrase,
                   const char *message_body) {
  send_status(client, code, reason_phrase);
  if (fprintf(client,
              "Connection: close\r\nContent-Length: %ld\r\nContent-Type: "
              "text/plain\r\n\r\n%s",
              strlen(message_body), message_body) < 0)
    exit(-1);
}


x86 assembly (clang, -O0):
<send_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <send_status@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
lea    0xe77(%rip),%rsi
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jge    11a2 <send_response+0x62>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_response>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdi,%rbx
call   1030 <send_status@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
mov    %r14,%rcx
call   1050 <fprintf@plt>
test   %rax,%rax
js     1178 <send_response+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [71 x i8] c"Connection: close\0D\0AContent-Length: %ld\0D\0AContent-Type: text/plain\0D\0A\0D\0A%s\00"
define void @send_response(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i32*, i32** %5
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = call i32 @send_status(i32* %9, i32 %10, i8* %11)
%13 = load i32*, i32** %5
%14 = load i8*, i8** %8
%15 = call i32 @strlen(i8* %14)
%16 = load i8*, i8** %8
%17 = call i64 @fprintf(i32* %13, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [71 x i8] c"Connection: close\0D\0AContent-Length: %ld\0D\0AContent-Type: text/plain\0D\0A\0D\0A%s\00"
define void @send_response(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i32 @send_status(i32* %0, i32 %1, i8* %2)
%6 = tail call i32 @strlen(i8* %3)
%7 = tail call i64 @fprintf(i32* %0, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i32 %6, i8* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %4
ret void
}