#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, char const *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ send_statu(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_statu(client, code, reason_phrase);
  if (fprintf(client, "Content-length: %d\nmessage-body: %s",
              (int)strlen(message_body), message_body) < 0) {
    perror("write message");
    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   1040 <send_statu@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
cmp    $0x0,%rax
jge    11be <send_response+0x6e>
lea    0xe75(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <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   1040 <send_statu@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
mov    %r14,%rcx
call   1050 <fprintf@plt>
test   %rax,%rax
js     1188 <send_response+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe95(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Content-length: %d\0Amessage-body: %s\00"
@.str.1 = [14 x i8] c"write message\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_statu(i32* %9, i32 %10, i8* %11)
%13 = load i32*, i32** %5
%14 = load i8*, i8** %8
%15 = call i64 @strlen(i8* %14)
%16 = trunc i64 %15 to i32
%17 = load i8*, i8** %8
%18 = call i64 @fprintf(i32* %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %4
%21 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Content-length: %d\0Amessage-body: %s\00"
@.str.1 = [14 x i8] c"write message\00"
define void @send_response(i32* %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i32 @send_statu(i32* %0, i32 %1, i8* %2)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%7 = trunc i64 %6 to i32
%8 = tail call i64 @fprintf(i32* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %4
ret void
}