#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*/ printf(char *, ...);
void cgi_headers(const int status, const char *mimetype) {
  switch (status) {
  case 500:
    printf("Status: 500 Internal Server Error\n");
    break;
  case 404:
    printf("Status: 404 Not Found\n");
    break;
  case 403:
    printf("Status: 403 Forbidden\n");
    break;
  case 401:
    printf("Status: 401 Authorization Required\n");
    break;
  case 200:
  default:
    printf("Status: 200 OK\n");
  }
  printf("Content-Type: %s; charset=ISO-8859-1\n", mimetype);
  printf("\n");
}


x86 assembly (clang, -O0):
<cgi_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0xc8,%eax
je     11cd <cgi_headers+0xbd>
jmp    1135 <cgi_headers+0x25>
mov    -0x14(%rbp),%eax
sub    $0x191,%eax
je     11ba <cgi_headers+0xaa>
jmp    1148 <cgi_headers+0x38>
mov    -0x14(%rbp),%eax
sub    $0x193,%eax
je     11a7 <cgi_headers+0x97>
jmp    115b <cgi_headers+0x4b>
mov    -0x14(%rbp),%eax
sub    $0x194,%eax
je     1194 <cgi_headers+0x84>
jmp    116e <cgi_headers+0x5e>
mov    -0x14(%rbp),%eax
sub    $0x1f4,%eax
jne    11d2 <cgi_headers+0xc2>
jmp    1181 <cgi_headers+0x71>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <cgi_headers+0xd0>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <cgi_headers+0xd0>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <cgi_headers+0xd0>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <cgi_headers+0xd0>
jmp    11d2 <cgi_headers+0xc2>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_headers>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x193,%edi
jg     1155 <cgi_headers+0x25>
cmp    $0x191,%edi
je     1177 <cgi_headers+0x47>
cmp    $0x193,%edi
jne    116e <cgi_headers+0x3e>
lea    0xef6(%rip),%rdi
jmp    1187 <cgi_headers+0x57>
cmp    $0x1f4,%edi
je     1180 <cgi_headers+0x50>
cmp    $0x194,%edi
jne    116e <cgi_headers+0x3e>
lea    0xef3(%rip),%rdi
jmp    1187 <cgi_headers+0x57>
lea    0xf22(%rip),%rdi
jmp    1187 <cgi_headers+0x57>
lea    0xea8(%rip),%rdi
jmp    1187 <cgi_headers+0x57>
lea    0xeee(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"Status: 500 Internal Server Error\0A\00"
@.str.1 = [23 x i8] c"Status: 404 Not Found\0A\00"
@.str.2 = [23 x i8] c"Status: 403 Forbidden\0A\00"
@.str.3 = [36 x i8] c"Status: 401 Authorization Required\0A\00"
@.str.4 = [16 x i8] c"Status: 200 OK\0A\00"
@.str.5 = [38 x i8] c"Content-Type: %s; charset=ISO-8859-1\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @cgi_headers(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %15 [
i32 500, label %6
i32 404, label %8
i32 403, label %10
i32 401, label %12
i32 200, label %14
]
6: ; preds = %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %17
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %17
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %17
14: ; preds = %2
br label %15
15: ; preds = %2, %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %15, %12, %10, %8, %6
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.5 = [38 x i8] c"Content-Type: %s; charset=ISO-8859-1\0A\00"
@str = [35 x i8] c"Status: 401 Authorization Required\00"
@str.7 = [22 x i8] c"Status: 403 Forbidden\00"
@str.8 = [22 x i8] c"Status: 404 Not Found\00"
@str.9 = [34 x i8] c"Status: 500 Internal Server Error\00"
@str.10 = [15 x i8] c"Status: 200 OK\00"
define void @cgi_headers(i32 %0, i8* %1) {
switch i32 %0, label %6 [
i32 500, label %7
i32 404, label %3
i32 403, label %4
i32 401, label %5
]
3: ; preds = %2
br label %7
4: ; preds = %2
br label %7
5: ; preds = %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %6, %5, %4, %3
%8 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0), %6 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0), %4 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0), %3 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0), %2 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%11 = tail call i32 @putchar(i32 10)
ret void
}