#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*/ STDOUT_FILENO;
int sendHTTPResponseHeader(int, int, int);
int strlen(char const *);
int writeStringToFile(int /*<<< orphan*/, char const *);
int sendHTTPResponse(int i_status, int i_content_type, const char *ccp_body) {
  int i_content_length = 0;
  int i_success = 0;
  if (ccp_body != NULL) {
    i_content_length = strlen(ccp_body);
  }
  i_success =
      sendHTTPResponseHeader(i_status, i_content_type, i_content_length);
  if (i_success == -1)
    return -1;
  if (ccp_body != NULL) {
    i_success = writeStringToFile(STDOUT_FILENO, ccp_body);
  }
  return i_success;
}


x86 assembly (clang, -O0):
<sendHTTPResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1167 <sendHTTPResponse+0x37>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <sendHTTPResponseHeader@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    118e <sendHTTPResponse+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <sendHTTPResponse+0x84>
cmpq   $0x0,-0x18(%rbp)
je     11ae <sendHTTPResponse+0x7e>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <writeStringToFile@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendHTTPResponse>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
test   %rdx,%rdx
je     116f <sendHTTPResponse+0x3f>
mov    %rdx,%rbx
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   1050 <sendHTTPResponseHeader@plt>
cmp    $0xffffffff,%eax
je     117f <sendHTTPResponse+0x4f>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <writeStringToFile@plt>
mov    %ebp,%edi
mov    %r14d,%esi
xor    %edx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <sendHTTPResponseHeader@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
define i32 @sendHTTPResponse(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %8
br label %15
15: ; preds = %12, %3
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = load i32, i32* %8
%19 = call i32 @sendHTTPResponseHeader(i32 %16, i32 %17, i32 %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 -1, i32* %4
br label %32
23: ; preds = %15
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @STDOUT_FILENO
%28 = load i8*, i8** %7
%29 = call i32 @writeStringToFile(i32 %27, i8* %28)
store i32 %29, i32* %9
br label %30
30: ; preds = %26, %23
%31 = load i32, i32* %9
store i32 %31, i32* %4
br label %32
32: ; preds = %30, %22
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
define i32 @sendHTTPResponse(i32 %0, i32 %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @sendHTTPResponseHeader(i32 %0, i32 %1, i32 0)
br label %14
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %2)
%9 = tail call i32 @sendHTTPResponseHeader(i32 %0, i32 %1, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i32, i32* @STDOUT_FILENO
%13 = tail call i32 @writeStringToFile(i32 %12, i8* %2)
br label %14
14: ; preds = %5, %7, %11
%15 = phi i32 [ -1, %7 ], [ %13, %11 ], [ %6, %5 ]
ret i32 %15
}