#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 */
struct stat {
  int st_size;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ fstat(int, struct stat *);
char *get_request(int);
int /*<<< orphan*/ hangup(int);
int /*<<< orphan*/ headers_cleanup();
int /*<<< orphan*/ headers_get_state();
int /*<<< orphan*/ headers_has_request();
scalar_t__ headers_is_error(int /*<<< orphan*/);
int /*<<< orphan*/ headers_parse(int);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ response_add(char *, char *);
int /*<<< orphan*/ response_init(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ write(int, char *, int);
scalar_t__ write_headers(int);
void run(int worker_id, int sock_fd, struct sockaddr addr, socklen_t addr_len) {
  headers_parse(sock_fd);
  if (headers_is_error(headers_get_state()) || !headers_has_request()) {
    goto hangup;
  }
  char *name = get_request(1);
  char *strip = name;
  char response_buffer[255];
  while (*strip == '.' || *strip == '/')
    strip++;
  if (!*strip) {
    fprintf(stderr, "%s: No such file or directory\n", name);
    goto _404;
  }
  int len = strlen(strip);
  int file_fd;
  char *file = malloc(2 + len + 1);
  file[0] = '.';
  file[1] = '/';
  memcpy(file + 2, strip, len);
  file[len + 2] = 0;
  file_fd = open(file, O_RDONLY);
  free(file);
  struct stat info;
  if (file_fd == -1 || fstat(file_fd, &info)) {
    if (file_fd > 0) {
      close(file_fd);
    }
    file_fd = 0;
    perror(name);
    goto _404;
  }
  response_init(200);
  char content_length[25];
  sprintf(content_length, "%d", info.st_size);
  response_add("Content-Length", content_length);
  if (write_headers(sock_fd)) {
    close(file_fd);
    goto _404;
  }
  len = read(file_fd, response_buffer, 255);
  while (len > 0) {
    if (write(sock_fd, response_buffer, len) < 0) {
      perror("write");
      break;
    }
    len = read(file_fd, response_buffer, 255);
  }
  if (file_fd > 0) {
    close(file_fd);
  }
  goto hangup;
_404:
  response_init(404);
  write_headers(sock_fd);
  snprintf(response_buffer, 255, "File not found: '%s'\n", name);
  if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
    goto hangup;
  }
  goto hangup;
hangup:
  headers_cleanup();
  hangup(sock_fd);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %edx,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1110 <headers_parse@plt>
mov    $0x0,%al
call   10d0 <headers_get_state@plt>
mov    %eax,%edi
call   1180 <headers_is_error@plt>
cmp    $0x0,%rax
jne    12b7 <run+0x47>
mov    $0x0,%al
call   10b0 <headers_has_request@plt>
cmp    $0x0,%eax
jne    12bc <run+0x4c>
jmp    15a3 <run+0x333>
mov    $0x1,%edi
call   1040 <get_request@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x171(%rbp)
je     12fd <run+0x8d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x171(%rbp)
mov    -0x171(%rbp),%al
test   $0x1,%al
jne    1310 <run+0xa0>
jmp    1321 <run+0xb1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12d2 <run+0x62>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    134c <run+0xdc>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xcbe(%rip),%rsi
call   10e0 <fprintf@plt>
jmp    152a <run+0x2ba>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x134(%rbp)
mov    -0x134(%rbp),%edi
add    $0x2,%edi
add    $0x1,%edi
call   1130 <malloc@plt>
mov    %rax,-0x140(%rbp)
mov    -0x140(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x140(%rbp),%rax
movb   $0x2f,0x1(%rax)
mov    -0x140(%rbp),%rdi
add    $0x2,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x134(%rbp),%edx
call   10f0 <memcpy@plt>
mov    -0x140(%rbp),%rax
mov    -0x134(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x140(%rbp),%rdi
mov    0x2c21(%rip),%rax
mov    (%rax),%esi
call   1140 <open@plt>
mov    %eax,-0x138(%rbp)
mov    -0x140(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0xffffffff,-0x138(%rbp)
je     1409 <run+0x199>
mov    -0x138(%rbp),%edi
lea    -0x148(%rbp),%rsi
call   1190 <fstat@plt>
cmp    $0x0,%rax
je     1439 <run+0x1c9>
cmpl   $0x0,-0x138(%rbp)
jle    1421 <run+0x1b1>
mov    -0x138(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x138(%rbp)
mov    -0x20(%rbp),%rdi
call   1150 <perror@plt>
jmp    152a <run+0x2ba>
mov    $0xc8,%edi
call   1100 <response_init@plt>
lea    -0x170(%rbp),%rdi
mov    -0x148(%rbp),%edx
lea    0xbc8(%rip),%rsi
call   1170 <sprintf@plt>
lea    -0x170(%rbp),%rsi
lea    0xbb8(%rip),%rdi
call   1160 <response_add@plt>
mov    -0x10(%rbp),%edi
call   1080 <write_headers@plt>
cmp    $0x0,%rax
je     1491 <run+0x221>
mov    -0x138(%rbp),%edi
call   1090 <close@plt>
jmp    152a <run+0x2ba>
mov    -0x138(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
jle    150d <run+0x29d>
mov    -0x10(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    -0x134(%rbp),%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    14eb <run+0x27b>
lea    0xb50(%rip),%rdi
call   1150 <perror@plt>
jmp    150d <run+0x29d>
mov    -0x138(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
mov    %eax,-0x134(%rbp)
jmp    14ae <run+0x23e>
cmpl   $0x0,-0x138(%rbp)
jle    1525 <run+0x2b5>
mov    -0x138(%rbp),%edi
call   1090 <close@plt>
jmp    15a3 <run+0x333>
mov    $0x194,%edi
call   1100 <response_init@plt>
mov    -0x10(%rbp),%edi
call   1080 <write_headers@plt>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xff,%esi
lea    0xae4(%rip),%rdx
call   1070 <snprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x184(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x180(%rbp)
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x184(%rbp),%edi
mov    -0x180(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    159e <run+0x32e>
jmp    15a3 <run+0x333>
jmp    15a3 <run+0x333>
mov    $0x0,%al
call   10c0 <headers_cleanup@plt>
mov    -0x10(%rbp),%edi
call   1120 <hangup@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %esi,%r12d
mov    %esi,%edi
call   1110 <headers_parse@plt>
xor    %eax,%eax
call   10d0 <headers_get_state@plt>
mov    %eax,%edi
call   1180 <headers_is_error@plt>
test   %rax,%rax
jne    13e9 <run+0x179>
xor    %eax,%eax
call   10b0 <headers_has_request@plt>
test   %eax,%eax
je     13e9 <run+0x179>
mov    $0x1,%edi
call   1040 <get_request@plt>
mov    %rax,%r14
mov    %rax,%rbp
nop
movzbl 0x0(%rbp),%eax
lea    -0x2e(%rax),%ecx
cmp    $0x2,%cl
jae    12d2 <run+0x62>
add    $0x1,%rbp
jmp    12c0 <run+0x50>
test   %al,%al
jne    12f3 <run+0x83>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd1a(%rip),%rsi
mov    %r14,%rdx
call   10e0 <fprintf@plt>
jmp    13a6 <run+0x136>
mov    %rbp,%rdi
call   1060 <strlen@plt>
movslq %eax,%r15
lea    0x3(%r15),%edi
call   1130 <malloc@plt>
mov    %rax,%rbx
movw   $0x2f2e,(%rax)
lea    0x2(%rax),%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   10f0 <memcpy@plt>
movb   $0x0,0x2(%r15,%rbx,1)
mov    0x2cbd(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1140 <open@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    $0xffffffff,%r15d
je     1472 <run+0x202>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
call   1190 <fstat@plt>
test   %rax,%rax
jne    1465 <run+0x1f5>
mov    $0xc8,%edi
call   1100 <response_init@plt>
mov    0x8(%rsp),%edx
lea    0xcaa(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1170 <sprintf@plt>
lea    0xc99(%rip),%rdi
mov    %rbx,%rsi
call   1160 <response_add@plt>
mov    %r12d,%edi
call   1080 <write_headers@plt>
test   %rax,%rax
je     1408 <run+0x198>
mov    %r15d,%edi
call   1090 <close@plt>
mov    $0x194,%edi
call   1100 <response_init@plt>
mov    %r12d,%edi
call   1080 <write_headers@plt>
lea    0xc78(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rcx
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
xor    %eax,%eax
call   10c0 <headers_cleanup@plt>
mov    %r12d,%edi
call   1120 <hangup@plt>
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x30(%rsp),%rsi
mov    %r15d,%edi
mov    $0xff,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1456 <run+0x1e6>
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
js     147f <run+0x20f>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
test   %eax,%eax
jg     1430 <run+0x1c0>
test   %r15d,%r15d
jle    13e9 <run+0x179>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    13e9 <run+0x179>
test   %r15d,%r15d
jle    1472 <run+0x202>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r14,%rdi
call   1150 <perror@plt>
jmp    13a6 <run+0x136>
lea    0xbab(%rip),%rdi
call   1150 <perror@plt>
test   %r15d,%r15d
jg     145b <run+0x1eb>
jmp    13e9 <run+0x179>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"%s: No such file or directory\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Content-Length\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [22 x i8] c"File not found: '%s'\0A\00"
define void @run(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.sockaddr
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [255 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca %struct.stat
%16 = alloca [25 x i8]
%17 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %5, i32 0, i32 0
store i32 %2, i32* %17
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %3, i32* %8
%18 = load i32, i32* %7
%19 = call i32 @headers_parse(i32 %18)
%20 = call i32 (...) @headers_get_state()
%21 = call i64 @headers_is_error(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %4
%24 = call i32 (...) @headers_has_request()
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %23, %4
br label %149
27: ; preds = %23
%28 = call i8* @get_request(i32 1)
store i8* %28, i8** %9
%29 = load i8*, i8** %9
store i8* %29, i8** %10
br label %30
30: ; preds = %42, %27
%31 = load i8*, i8** %10
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 46
br i1 %34, label %40, label %35
35: ; preds = %30
%36 = load i8*, i8** %10
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 47
br label %40
40: ; preds = %35, %30
%41 = phi i1 [ true, %30 ], [ %39, %35 ]
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = load i8*, i8** %10
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %10
br label %30
45: ; preds = %40
%46 = load i8*, i8** %10
%47 = load i8, i8* %46
%48 = icmp ne i8 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %9
%52 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %51)
br label %134
53: ; preds = %45
%54 = load i8*, i8** %10
%55 = call i32 @strlen(i8* %54)
store i32 %55, i32* %12
%56 = load i32, i32* %12
%57 = add nsw i32 2, %56
%58 = add nsw i32 %57, 1
%59 = call i8* @malloc(i32 %58)
store i8* %59, i8** %14
%60 = load i8*, i8** %14
%61 = getelementptr inbounds i8, i8* %60, i64 0
store i8 46, i8* %61
%62 = load i8*, i8** %14
%63 = getelementptr inbounds i8, i8* %62, i64 1
store i8 47, i8* %63
%64 = load i8*, i8** %14
%65 = getelementptr inbounds i8, i8* %64, i64 2
%66 = load i8*, i8** %10
%67 = load i32, i32* %12
%68 = call i32 @memcpy(i8* %65, i8* %66, i32 %67)
%69 = load i8*, i8** %14
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 2
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %69, i64 %72
store i8 0, i8* %73
%74 = load i8*, i8** %14
%75 = load i32, i32* @O_RDONLY
%76 = call i32 @open(i8* %74, i32 %75)
store i32 %76, i32* %13
%77 = load i8*, i8** %14
%78 = call i32 @free(i8* %77)
%79 = load i32, i32* %13
%80 = icmp eq i32 %79, -1
br i1 %80, label %85, label %81
81: ; preds = %53
%82 = load i32, i32* %13
%83 = call i64 @fstat(i32 %82, %struct.stat* %15)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %94
85: ; preds = %81, %53
%86 = load i32, i32* %13
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i32, i32* %13
%90 = call i32 @close(i32 %89)
br label %91
91: ; preds = %88, %85
store i32 0, i32* %13
%92 = load i8*, i8** %9
%93 = call i32 @perror(i8* %92)
br label %134
94: ; preds = %81
%95 = call i32 @response_init(i32 200)
%96 = getelementptr inbounds [25 x i8], [25 x i8]* %16, i64 0, i64 0
%97 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%98 = load i32, i32* %97
%99 = call i32 @sprintf(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [25 x i8], [25 x i8]* %16, i64 0, i64 0
%101 = call i32 @response_add(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %100)
%102 = load i32, i32* %7
%103 = call i64 @write_headers(i32 %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %94
%106 = load i32, i32* %13
%107 = call i32 @close(i32 %106)
br label %134
108: ; preds = %94
%109 = load i32, i32* %13
%110 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%111 = call i32 @read(i32 %109, i8* %110, i32 255)
store i32 %111, i32* %12
br label %112
112: ; preds = %123, %108
%113 = load i32, i32* %12
%114 = icmp sgt i32 %113, 0
br i1 %114, label %115, label %127
115: ; preds = %112
%116 = load i32, i32* %7
%117 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%118 = load i32, i32* %12
%119 = call i64 @write(i32 %116, i8* %117, i32 %118)
%120 = icmp slt i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %115
%122 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %127
123: ; preds = %115
%124 = load i32, i32* %13
%125 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%126 = call i32 @read(i32 %124, i8* %125, i32 255)
store i32 %126, i32* %12
br label %112
127: ; preds = %121, %112
%128 = load i32, i32* %13
%129 = icmp sgt i32 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = load i32, i32* %13
%132 = call i32 @close(i32 %131)
br label %133
133: ; preds = %130, %127
br label %149
134: ; preds = %105, %91, %49
%135 = call i32 @response_init(i32 404)
%136 = load i32, i32* %7
%137 = call i64 @write_headers(i32 %136)
%138 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%139 = load i8*, i8** %9
%140 = call i32 @snprintf(i8* %138, i32 255, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %139)
%141 = load i32, i32* %7
%142 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%143 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%144 = call i32 @strlen(i8* %143)
%145 = call i64 @write(i32 %141, i8* %142, i32 %144)
%146 = icmp slt i64 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %134
br label %149
148: ; preds = %134
br label %149
149: ; preds = %148, %147, %133, %26
%150 = call i32 (...) @headers_cleanup()
%151 = load i32, i32* %7
%152 = call i32 @hangup(i32 %151)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"%s: No such file or directory\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Content-Length\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [22 x i8] c"File not found: '%s'\0A\00"
define void @run(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [255 x i8]
%6 = alloca %struct.stat
%7 = alloca [25 x i8]
%8 = tail call i32 @headers_parse(i32 %1)
%9 = tail call i32 (...) @headers_get_state()
%10 = tail call i64 @headers_is_error(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %83
12: ; preds = %4
%13 = tail call i32 (...) @headers_has_request()
%14 = icmp eq i32 %13, 0
br i1 %14, label %83, label %15
15: ; preds = %12
%16 = tail call i8* @get_request(i32 1)
br label %17
17: ; preds = %20, %15
%18 = phi i8* [ %16, %15 ], [ %21, %20 ]
%19 = load i8, i8* %18
switch i8 %19, label %25 [
i8 46, label %20
i8 47, label %20
i8 0, label %22
]
20: ; preds = %17, %17
%21 = getelementptr inbounds i8, i8* %18, i64 1
br label %17
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %76
25: ; preds = %17
%26 = tail call i32 @strlen(i8* %18)
%27 = add nsw i32 %26, 2
%28 = add nsw i32 %26, 3
%29 = tail call i8* @malloc(i32 %28)
store i8 46, i8* %29
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 47, i8* %30
%31 = getelementptr inbounds i8, i8* %29, i64 2
%32 = tail call i32 @memcpy(i8* %31, i8* %18, i32 %26)
%33 = sext i32 %27 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
store i8 0, i8* %34
%35 = load i32, i32* @O_RDONLY
%36 = tail call i32 @open(i8* %29, i32 %35)
%37 = tail call i32 @free(i8* %29)
%38 = icmp eq i32 %36, -1
br i1 %38, label %46, label %39
39: ; preds = %25
%40 = call i64 @fstat(i32 %36, %struct.stat* %6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %39
%43 = icmp sgt i32 %36, 0
br i1 %43, label %44, label %46
44: ; preds = %42
%45 = tail call i32 @close(i32 %36)
br label %46
46: ; preds = %25, %44, %42
%47 = tail call i32 @perror(i8* %16)
br label %76
48: ; preds = %39
%49 = tail call i32 @response_init(i32 200)
%50 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%51 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 @sprintf(i8* %50, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = call i32 @response_add(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %50)
%55 = call i64 @write_headers(i32 %1)
%56 = icmp eq i64 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %48
%58 = call i32 @close(i32 %36)
br label %76
59: ; preds = %48
%60 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%61 = call i32 @read(i32 %36, i8* %60, i32 255)
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %72
63: ; preds = %59, %69
%64 = phi i32 [ %70, %69 ], [ %61, %59 ]
%65 = call i64 @write(i32 %1, i8* %60, i32 %64)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %72
69: ; preds = %63
%70 = call i32 @read(i32 %36, i8* %60, i32 255)
%71 = icmp sgt i32 %70, 0
br i1 %71, label %63, label %72
72: ; preds = %69, %59, %67
%73 = icmp sgt i32 %36, 0
br i1 %73, label %74, label %83
74: ; preds = %72
%75 = call i32 @close(i32 %36)
br label %83
76: ; preds = %57, %46, %22
%77 = call i32 @response_init(i32 404)
%78 = call i64 @write_headers(i32 %1)
%79 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%80 = call i32 @snprintf(i8* %79, i32 255, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%81 = call i32 @strlen(i8* %79)
%82 = call i64 @write(i32 %1, i8* %79, i32 %81)
br label %83
83: ; preds = %76, %72, %74, %4, %12
%84 = call i32 (...) @headers_cleanup()
%85 = call i32 @hangup(i32 %1)
ret void
}