#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*/ exit(int);
int /*<<< orphan*/ write(int, char *, int);
void handle_error(int type, int socket_fd) {
  switch (type) {
  case 500:
    write(
        socket_fd,
        "HTTP/1.1 500 Internal Server Error\nContent-Length: 129\nConnection: "
        "close\nContent-Type: text/html\n\n<html><head>\n<title>403 "
        "Forbidden</title>\n</head><body>\n<h1>Internal Server "
        "Error</h1>\nOperation gone bad. Sorry.\n</body></html>\n",
        227);
    break;
  case 404:
    write(socket_fd,
          "HTTP/1.1 404 Not Found\nContent-Length: 137\nConnection: "
          "close\nContent-Type: text/html\n\n<html><head>\n<title>404 Not "
          "Found</title>\n</head><body>\n<h1>Not Found</h1>\nThe requested URL "
          "was not found on this server.\n</body></html>\n",
          224);
    break;
  case 403:
    write(socket_fd,
          "HTTP/1.1 403 Forbidden\nContent-Length: 185\nConnection: "
          "close\nContent-Type: text/html\n\n<html><head>\n<title>403 "
          "Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\nThe requested "
          "URL, file type or operation is not allowed on this simple static "
          "file webserver.\n</body></html>\n",
          271);
    break;
  }
  exit(3);
}


x86 assembly (clang, -O0):
<handle_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x193,%eax
je     119c <handle_error+0x7c>
jmp    1144 <handle_error+0x24>
mov    -0xc(%rbp),%eax
sub    $0x194,%eax
je     1183 <handle_error+0x63>
jmp    1157 <handle_error+0x37>
mov    -0xc(%rbp),%eax
sub    $0x1f4,%eax
jne    11b0 <handle_error+0x90>
jmp    116a <handle_error+0x4a>
mov    -0x8(%rbp),%edi
lea    0xe8c(%rip),%rsi
mov    $0xe3,%edx
call   1030 <write@plt>
jmp    11b0 <handle_error+0x90>
mov    -0x8(%rbp),%edi
lea    0xf57(%rip),%rsi
mov    $0xe0,%edx
call   1030 <write@plt>
jmp    11b0 <handle_error+0x90>
mov    -0x8(%rbp),%edi
lea    0x101f(%rip),%rsi
mov    $0x10f,%edx
call   1030 <write@plt>
mov    $0x3,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<handle_error>:
push   %rax
cmp    $0x193,%edi
je     1147 <handle_error+0x27>
cmp    $0x1f4,%edi
je     1155 <handle_error+0x35>
cmp    $0x194,%edi
jne    116b <handle_error+0x4b>
lea    0xfa4(%rip),%rax
mov    $0xe0,%edx
jmp    1161 <handle_error+0x41>
lea    0x1077(%rip),%rax
mov    $0x10f,%edx
jmp    1161 <handle_error+0x41>
lea    0xea4(%rip),%rax
mov    $0xe3,%edx
mov    %esi,%edi
mov    %rax,%rsi
call   1030 <write@plt>
mov    $0x3,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [228 x i8] c"HTTP/1.1 500 Internal Server Error\0AContent-Length: 129\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>403 Forbidden</title>\0A</head><body>\0A<h1>Internal Server Error</h1>\0AOperation gone bad. Sorry.\0A</body></html>\0A\00"
@.str.1 = [225 x i8] c"HTTP/1.1 404 Not Found\0AContent-Length: 137\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>404 Not Found</title>\0A</head><body>\0A<h1>Not Found</h1>\0AThe requested URL was not found on this server.\0A</body></html>\0A\00"
@.str.2 = [272 x i8] c"HTTP/1.1 403 Forbidden\0AContent-Length: 185\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>403 Forbidden</title>\0A</head><body>\0A<h1>Forbidden</h1>\0AThe requested URL, file type or operation is not allowed on this simple static file webserver.\0A</body></html>\0A\00"
define void @handle_error(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
switch i32 %5, label %15 [
i32 500, label %6
i32 404, label %9
i32 403, label %12
]
6: ; preds = %2
%7 = load i32, i32* %4
%8 = call i32 @write(i32 %7, i8* getelementptr inbounds ([228 x i8], [228 x i8]* @.str, i64 0, i64 0), i32 227)
br label %15
9: ; preds = %2
%10 = load i32, i32* %4
%11 = call i32 @write(i32 %10, i8* getelementptr inbounds ([225 x i8], [225 x i8]* @.str.1, i64 0, i64 0), i32 224)
br label %15
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([272 x i8], [272 x i8]* @.str.2, i64 0, i64 0), i32 271)
br label %15
15: ; preds = %2, %12, %9, %6
%16 = call i32 @exit(i32 3)
unreachable
}

LLVM IR (-O2):
@.str = [228 x i8] c"HTTP/1.1 500 Internal Server Error\0AContent-Length: 129\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>403 Forbidden</title>\0A</head><body>\0A<h1>Internal Server Error</h1>\0AOperation gone bad. Sorry.\0A</body></html>\0A\00"
@.str.1 = [225 x i8] c"HTTP/1.1 404 Not Found\0AContent-Length: 137\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>404 Not Found</title>\0A</head><body>\0A<h1>Not Found</h1>\0AThe requested URL was not found on this server.\0A</body></html>\0A\00"
@.str.2 = [272 x i8] c"HTTP/1.1 403 Forbidden\0AContent-Length: 185\0AConnection: close\0AContent-Type: text/html\0A\0A<html><head>\0A<title>403 Forbidden</title>\0A</head><body>\0A<h1>Forbidden</h1>\0AThe requested URL, file type or operation is not allowed on this simple static file webserver.\0A</body></html>\0A\00"
define void @handle_error(i32 %0, i32 %1) {
switch i32 %0, label %9 [
i32 500, label %5
i32 404, label %3
i32 403, label %4
]
3: ; preds = %2
br label %5
4: ; preds = %2
br label %5
5: ; preds = %2, %3, %4
%6 = phi i32 [ 271, %4 ], [ 224, %3 ], [ 227, %2 ]
%7 = phi i8* [ getelementptr inbounds ([272 x i8], [272 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([225 x i8], [225 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([228 x i8], [228 x i8]* @.str, i64 0, i64 0), %2 ]
%8 = tail call i32 @write(i32 %1, i8* %7, i32 %6)
br label %9
9: ; preds = %5, %2
%10 = tail call i32 @exit(i32 3)
unreachable
}