#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 uint;

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ forbidden_response(char *, int);
int /*<<< orphan*/ internal_error(char *, int);
int /*<<< orphan*/ unimplmented_response(char *, int);
char *http_response(const uint status) {
  char *buffer = calloc(1, 1024);
  if (403 == status) {
    forbidden_response(buffer, 1024);
    return buffer;
  } else if (501 == status) {
    unimplmented_response(buffer, 1024);
    return buffer;
  } else if (500 == status) {
    internal_error(buffer, 1024);
    return buffer;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<http_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    $0x1,%edi
mov    $0x400,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x193,%eax
cmp    -0xc(%rbp),%eax
jne    1187 <http_response+0x47>
mov    -0x18(%rbp),%rdi
mov    $0x400,%esi
call   1030 <forbidden_response@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <http_response+0xab>
mov    $0x1f5,%eax
cmp    -0xc(%rbp),%eax
jne    11b0 <http_response+0x70>
mov    -0x18(%rbp),%rdi
mov    $0x400,%esi
call   1060 <unimplmented_response@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <http_response+0xab>
mov    $0x1f4,%eax
cmp    -0xc(%rbp),%eax
jne    11d9 <http_response+0x99>
mov    -0x18(%rbp),%rdi
mov    $0x400,%esi
call   1050 <internal_error@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <http_response+0xab>
jmp    11de <http_response+0x9e>
jmp    11e3 <http_response+0xa3>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_response>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x1,%edi
mov    $0x400,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
cmp    $0x1f5,%ebp
je     117e <http_response+0x3e>
cmp    $0x1f4,%ebp
je     118d <http_response+0x4d>
cmp    $0x193,%ebp
jne    119c <http_response+0x5c>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1030 <forbidden_response@plt>
jmp    119e <http_response+0x5e>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <unimplmented_response@plt>
jmp    119e <http_response+0x5e>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <internal_error@plt>
jmp    119e <http_response+0x5e>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @http_response(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = call i8* @calloc(i32 1, i32 1024)
store i8* %5, i8** %4
%6 = load i32, i32* %3
%7 = icmp eq i32 403, %6
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %4
%10 = call i32 @forbidden_response(i8* %9, i32 1024)
%11 = load i8*, i8** %4
store i8* %11, i8** %2
br label %29
12: ; preds = %1
%13 = load i32, i32* %3
%14 = icmp eq i32 501, %13
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = call i32 @unimplmented_response(i8* %16, i32 1024)
%18 = load i8*, i8** %4
store i8* %18, i8** %2
br label %29
19: ; preds = %12
%20 = load i32, i32* %3
%21 = icmp eq i32 500, %20
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = call i32 @internal_error(i8* %23, i32 1024)
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %29
26: ; preds = %19
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
store i8* null, i8** %2
br label %29
29: ; preds = %28, %22, %15, %8
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
define i8* @http_response(i32 %0) {
%2 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1, i32 1024)
switch i32 %0, label %9 [
i32 403, label %3
i32 501, label %5
i32 500, label %7
]
3: ; preds = %1
%4 = tail call i32 @forbidden_response(i8* %2, i32 1024)
br label %9
5: ; preds = %1
%6 = tail call i32 @unimplmented_response(i8* %2, i32 1024)
br label %9
7: ; preds = %1
%8 = tail call i32 @internal_error(i8* %2, i32 1024)
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i8* [ %2, %3 ], [ %2, %5 ], [ %2, %7 ], [ null, %1 ]
ret i8* %10
}