#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 */
#define EACCES 130
#define EMFILE 129
#define ENOENT 128
int errno;
const char *errno_to_http_status() {
  switch (errno) {
  case EACCES:
    return "403 Permission Denied";
  case EMFILE:
    return "503 Service Unavailable";
  case ENOENT:
    return "404 File Not Found";
  default:
    return "500 Internal Server Error";
  }
}


x86 assembly (clang, -O0):
<errno_to_http_status>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ed5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
sub    $0x80,%eax
je     1166 <errno_to_http_status+0x66>
jmp    1120 <errno_to_http_status+0x20>
mov    -0xc(%rbp),%eax
sub    $0x81,%eax
je     1156 <errno_to_http_status+0x56>
jmp    1133 <errno_to_http_status+0x33>
mov    -0xc(%rbp),%eax
sub    $0x82,%eax
jne    1176 <errno_to_http_status+0x76>
jmp    1146 <errno_to_http_status+0x46>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <errno_to_http_status+0x81>
lea    0xeb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <errno_to_http_status+0x81>
lea    0xec1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <errno_to_http_status+0x81>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<errno_to_http_status>:
mov    0x2ed9(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
cmp    $0x2,%eax
ja     1122 <errno_to_http_status+0x22>
cltq
lea    0xf42(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf18(%rip),%rax
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [22 x i8] c"403 Permission Denied\00"
@.str.1 = [24 x i8] c"503 Service Unavailable\00"
@.str.2 = [19 x i8] c"404 File Not Found\00"
@.str.3 = [26 x i8] c"500 Internal Server Error\00"
define i8* @errno_to_http_status() {
%1 = alloca i8*
%2 = load i32, i32* @errno
switch i32 %2, label %6 [
i32 130, label %3
i32 129, label %4
i32 128, label %5
]
3: ; preds = %0
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8** %1
br label %7
4: ; preds = %0
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %7
5: ; preds = %0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %7
6: ; preds = %0
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %7
7: ; preds = %6, %5, %4, %3
%8 = load i8*, i8** %1
ret i8* %8
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [22 x i8] c"403 Permission Denied\00"
@.str.1 = [24 x i8] c"503 Service Unavailable\00"
@.str.2 = [19 x i8] c"404 File Not Found\00"
@.str.3 = [26 x i8] c"500 Internal Server Error\00"
@reltable.errno_to_http_status = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.errno_to_http_status to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.errno_to_http_status to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.errno_to_http_status to i64)) to i32)]
define i8* @errno_to_http_status() {
%1 = load i32, i32* @errno
%2 = add i32 %1, -128
%3 = icmp ult i32 %2, 3
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.errno_to_http_status to i8*), i64 %6)
br label %8
8: ; preds = %0, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %0 ]
ret i8* %9
}