#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 *, char *, scalar_t__, int,
                   char const *);
int /*<<< orphan*/ send_status(int /*<<< orphan*/ *, int, char const *);
scalar_t__ 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-Type: %s\r\nContent-Length: "
              "%lu\r\n\r\n%d %s",
              "text/plain", strlen(message_body) + 4, code, 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    %rax,%rcx
add    $0x4,%rcx
mov    -0xc(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xe6e(%rip),%rsi
lea    0xea9(%rip),%rdx
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jge    11b2 <send_response+0x72>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_response>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <send_status@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x4(%rax),%rcx
lea    0xe9c(%rip),%rsi
lea    0xed7(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%r8d
mov    %r14,%r9
call   1050 <fprintf@plt>
test   %rax,%rax
js     1183 <send_response+0x43>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [66 x i8] c"Connection: close\0D\0AContent-Type: %s\0D\0AContent-Length: %lu\0D\0A\0D\0A%d %s\00"
@.str.1 = [11 x i8] c"text/plain\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 i64 @strlen(i8* %14)
%16 = add nsw i64 %15, 4
%17 = load i32, i32* %6
%18 = load i8*, i8** %8
%19 = call i64 @fprintf(i32* %13, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %16, i32 %17, i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"Connection: close\0D\0AContent-Type: %s\0D\0AContent-Length: %lu\0D\0A\0D\0A%d %s\00"
@.str.1 = [11 x i8] c"text/plain\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 i64 @strlen(i8* dereferenceable(1) %3)
%7 = add nsw i64 %6, 4
%8 = tail call i64 @fprintf(i32* %0, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %7, i32 %1, i8* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %4
ret void
}