#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 *, ...);
int http_error(int error) {
  char *p;
  switch (error) {
  case 400:
    p = "Bad Request";
    break;
  case 404:
    p = "Not Found";
    break;
  default:
    p = "Error";
  }
  printf("HTTP/1.0 %d %s\r\n", error, p);
  printf("MIME-version: 1.0\r\n");
  printf("Content-Type: text/html\r\n\r\n");
  printf("<head><title>%d %s</title></head>\r\n", error, p);
  printf("<body><h1>%d %s</h1></body>\r\n", error, p);
  return 0;
}


x86 assembly (clang, -O0):
<http_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x190,%eax
je     1144 <http_error+0x34>
jmp    1131 <http_error+0x21>
mov    -0x14(%rbp),%eax
sub    $0x194,%eax
je     1154 <http_error+0x44>
jmp    1164 <http_error+0x54>
lea    0xeb5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    116f <http_error+0x5f>
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    116f <http_error+0x5f>
lea    0xeab(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_error>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x194,%edi
lea    0xeda(%rip),%rax
lea    0xedd(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x190,%edi
lea    0xeb6(%rip),%rbx
cmovne %rcx,%rbx
lea    0xec7(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Bad Request\00"
@.str.1 = [10 x i8] c"Not Found\00"
@.str.2 = [6 x i8] c"Error\00"
@.str.3 = [17 x i8] c"HTTP/1.0 %d %s\0D\0A\00"
@.str.4 = [20 x i8] c"MIME-version: 1.0\0D\0A\00"
@.str.5 = [28 x i8] c"Content-Type: text/html\0D\0A\0D\0A\00"
@.str.6 = [36 x i8] c"<head><title>%d %s</title></head>\0D\0A\00"
@.str.7 = [30 x i8] c"<body><h1>%d %s</h1></body>\0D\0A\00"
define i32 @http_error(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %7 [
i32 400, label %5
i32 404, label %6
]
5: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %3
br label %8
6: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %8
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %8
8: ; preds = %7, %6, %5
%9 = load i32, i32* %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %9, i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = load i8*, i8** %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %15)
%17 = load i32, i32* %2
%18 = load i8*, i8** %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %17, i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Bad Request\00"
@.str.1 = [10 x i8] c"Not Found\00"
@.str.2 = [6 x i8] c"Error\00"
@.str.3 = [17 x i8] c"HTTP/1.0 %d %s\0D\0A\00"
@.str.6 = [36 x i8] c"<head><title>%d %s</title></head>\0D\0A\00"
@.str.7 = [30 x i8] c"<body><h1>%d %s</h1></body>\0D\0A\00"
@str = [19 x i8] c"MIME-version: 1.0\0D\00"
@str.8 = [27 x i8] c"Content-Type: text/html\0D\0A\0D\00"
define i32 @http_error(i32 %0) {
%2 = icmp eq i32 %0, 404
%3 = select i1 %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%4 = icmp eq i32 %0, 400
%5 = select i1 %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %0, i8* %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %0, i8* %5)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %0, i8* %5)
ret i32 0
}