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

/* Variables and functions */
char *get_header(int, int);
char *get_request(int);
char *get_response(int *);
int /*<<< orphan*/ hangup(int);
int /*<<< orphan*/ headers_cleanup();
int /*<<< orphan*/ headers_get_state();
int /*<<< orphan*/ headers_has_request();
scalar_t__ headers_has_version();
scalar_t__ headers_is_error(int /*<<< orphan*/);
int /*<<< orphan*/ headers_parse(int);
int /*<<< orphan*/ response_init(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
scalar_t__ write(int, char *, 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;
  }
  int j;
  response_init(200);
  int headers_len = 0;
  char *headers = get_response(&headers_len);
  if (!headers || headers_len <= 0 ||
      write(sock_fd, headers, headers_len) < 0) {
    goto hangup;
  }
  char response_buffer[255];
  sprintf(response_buffer, "Handled by worker #%d\nRequest:\n", worker_id);
  if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
    goto hangup;
  }
  char *field;
  if ((field = get_request(0))) {
    sprintf(response_buffer, "Method: %s\n", field);
    if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
      goto hangup;
    }
  }
  if ((field = get_request(1))) {
    sprintf(response_buffer, "Path: %s\n", field);
    if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
      goto hangup;
    }
  }
  if (headers_has_version() && (field = get_request(2))) {
    sprintf(response_buffer, "Version: %s\n", field);
    if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
      goto hangup;
    }
  }
  sprintf(response_buffer, "Headers:\n");
  if (write(sock_fd, response_buffer, strlen(response_buffer)) < 0) {
    goto hangup;
  }
  for (j = 0;; j++) {
    char *key = get_header(j, 0);
    char *val = get_header(j, 1);
    if (!key || !val) {
      break;
    }
    if (write(sock_fd, key, strlen(key)) < 0 || write(sock_fd, " = ", 3) < 0 ||
        write(sock_fd, val, strlen(val)) < 0 || write(sock_fd, "\n", 1) < 0) {
      break;
    }
  }
hangup:
  headers_cleanup();
  hangup(sock_fd);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %edx,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   10c0 <headers_parse@plt>
mov    $0x0,%al
call   10a0 <headers_get_state@plt>
mov    %eax,%edi
call   1100 <headers_is_error@plt>
cmp    $0x0,%rax
jne    1227 <run+0x47>
mov    $0x0,%al
call   1080 <headers_has_request@plt>
cmp    $0x0,%eax
jne    122c <run+0x4c>
jmp    15f2 <run+0x412>
mov    $0xc8,%edi
call   10b0 <response_init@plt>
movl   $0x0,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1050 <get_response@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1278 <run+0x98>
cmpl   $0x0,-0x1c(%rbp)
jle    1278 <run+0x98>
mov    -0x10(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    127d <run+0x9d>
jmp    15f2 <run+0x412>
lea    -0x130(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x154(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x154(%rbp),%edi
mov    -0x150(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    12db <run+0xfb>
jmp    15f2 <run+0x412>
xor    %edi,%edi
call   1030 <get_request@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
je     135a <run+0x17a>
lea    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x164(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x164(%rbp),%edi
mov    -0x160(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    1355 <run+0x175>
jmp    15f2 <run+0x412>
jmp    135a <run+0x17a>
mov    $0x1,%edi
call   1030 <get_request@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
je     13dc <run+0x1fc>
lea    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xca2(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x174(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x170(%rbp)
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x174(%rbp),%edi
mov    -0x170(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    13d7 <run+0x1f7>
jmp    15f2 <run+0x412>
jmp    13dc <run+0x1fc>
mov    $0x0,%al
call   10e0 <headers_has_version@plt>
cmp    $0x0,%rax
je     146f <run+0x28f>
mov    $0x2,%edi
call   1030 <get_request@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
je     146f <run+0x28f>
lea    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xc19(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@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   1040 <write@plt>
cmp    $0x0,%rax
jge    146a <run+0x28a>
jmp    15f2 <run+0x412>
jmp    146f <run+0x28f>
lea    -0x130(%rbp),%rdi
lea    0xbc6(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x194(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x190(%rbp)
lea    -0x130(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x194(%rbp),%edi
mov    -0x190(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    14ca <run+0x2ea>
jmp    15f2 <run+0x412>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%edi
xor    %esi,%esi
call   1070 <get_header@plt>
mov    %rax,-0x140(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1070 <get_header@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x140(%rbp)
je     1512 <run+0x332>
cmpq   $0x0,-0x148(%rbp)
jne    1517 <run+0x337>
jmp    15ed <run+0x40d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x140(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1a4(%rbp),%edi
mov    -0x1a0(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jl     15d5 <run+0x3f5>
mov    -0x10(%rbp),%edi
lea    0xaeb(%rip),%rsi
mov    $0x3,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jl     15d5 <run+0x3f5>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x148(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x148(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1b4(%rbp),%edi
mov    -0x1b0(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jl     15d5 <run+0x3f5>
mov    -0x10(%rbp),%edi
lea    0xa8a(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    15da <run+0x3fa>
jmp    15ed <run+0x40d>
jmp    15df <run+0x3ff>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14d1 <run+0x2f1>
jmp    15f2 <run+0x412>
mov    $0x0,%al
call   1090 <headers_cleanup@plt>
mov    -0x10(%rbp),%edi
call   10d0 <hangup@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%edi
call   10c0 <headers_parse@plt>
xor    %eax,%eax
call   10a0 <headers_get_state@plt>
mov    %eax,%edi
call   1100 <headers_is_error@plt>
test   %rax,%rax
je     122f <run+0x4f>
xor    %eax,%eax
call   1090 <headers_cleanup@plt>
mov    %ebx,%edi
call   10d0 <hangup@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1080 <headers_has_request@plt>
test   %eax,%eax
je     120f <run+0x2f>
mov    $0xc8,%edi
call   10b0 <response_init@plt>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <get_response@plt>
test   %rax,%rax
je     120f <run+0x2f>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    120f <run+0x2f>
mov    %ebx,%edi
mov    %rax,%rsi
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
lea    0xd87(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
xor    %edi,%edi
call   1030 <get_request@plt>
test   %rax,%rax
je     12e9 <run+0x109>
lea    0xd66(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
mov    $0x1,%edi
call   1030 <get_request@plt>
test   %rax,%rax
je     132e <run+0x14e>
lea    0xd2d(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
xor    %eax,%eax
call   10e0 <headers_has_version@plt>
test   %rax,%rax
je     137f <run+0x19f>
mov    $0x2,%edi
call   1030 <get_request@plt>
test   %rax,%rax
je     137f <run+0x19f>
lea    0xce6(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
movabs $0x3a73726564616548,%rax
72 73 3a
mov    %rax,0x10(%rsp)
movw   $0xa,0x18(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <get_header@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <get_header@plt>
test   %rbp,%rbp
je     120f <run+0x2f>
mov    %rax,%r13
test   %rax,%rax
je     120f <run+0x2f>
mov    $0x1,%r12d
lea    0xc5c(%rip),%r14
lea    0xc53(%rip),%r15
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
test   %rax,%rax
js     120f <run+0x2f>
mov    %r12d,%edi
xor    %esi,%esi
call   1070 <get_header@plt>
mov    %rax,%rbp
mov    %r12d,%edi
mov    $0x1,%esi
call   1070 <get_header@plt>
test   %rbp,%rbp
je     120f <run+0x2f>
mov    %rax,%r13
add    $0x1,%r12d
test   %rax,%rax
jne    13f8 <run+0x218>
jmp    120f <run+0x2f>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [32 x i8] c"Handled by worker #%d\0ARequest:\0A\00"
@.str.1 = [12 x i8] c"Method: %s\0A\00"
@.str.2 = [10 x i8] c"Path: %s\0A\00"
@.str.3 = [13 x i8] c"Version: %s\0A\00"
@.str.4 = [10 x i8] c"Headers:\0A\00"
@.str.5 = [4 x i8] c" = \00"
@.str.6 = [2 x i8] c"\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 i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [255 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %5, i32 0, i32 0
store i32 %2, i32* %16
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %3, i32* %8
%17 = load i32, i32* %7
%18 = call i32 @headers_parse(i32 %17)
%19 = call i32 (...) @headers_get_state()
%20 = call i64 @headers_is_error(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %4
%23 = call i32 (...) @headers_has_request()
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %22, %4
br label %150
26: ; preds = %22
%27 = call i32 @response_init(i32 200)
store i32 0, i32* %10
%28 = call i8* @get_response(i32* %10)
store i8* %28, i8** %11
%29 = load i8*, i8** %11
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %40
31: ; preds = %26
%32 = load i32, i32* %10
%33 = icmp sle i32 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = load i32, i32* %7
%36 = load i8*, i8** %11
%37 = load i32, i32* %10
%38 = call i64 @write(i32 %35, i8* %36, i32 %37)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34, %31, %26
br label %150
41: ; preds = %34
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%43 = load i32, i32* %6
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %7
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%48 = call i32 @strlen(i8* %47)
%49 = call i64 @write(i32 %45, i8* %46, i32 %48)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %41
br label %150
52: ; preds = %41
%53 = call i8* @get_request(i32 0)
store i8* %53, i8** %13
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %67
55: ; preds = %52
%56 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%57 = load i8*, i8** %13
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %57)
%59 = load i32, i32* %7
%60 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%61 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%62 = call i32 @strlen(i8* %61)
%63 = call i64 @write(i32 %59, i8* %60, i32 %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %55
br label %150
66: ; preds = %55
br label %67
67: ; preds = %66, %52
%68 = call i8* @get_request(i32 1)
store i8* %68, i8** %13
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %82
70: ; preds = %67
%71 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%72 = load i8*, i8** %13
%73 = call i32 (i8*, i8*, ...) @sprintf(i8* %71, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %7
%75 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%76 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%77 = call i32 @strlen(i8* %76)
%78 = call i64 @write(i32 %74, i8* %75, i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %70
br label %150
81: ; preds = %70
br label %82
82: ; preds = %81, %67
%83 = call i64 (...) @headers_has_version()
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %100
85: ; preds = %82
%86 = call i8* @get_request(i32 2)
store i8* %86, i8** %13
%87 = icmp ne i8* %86, null
br i1 %87, label %88, label %100
88: ; preds = %85
%89 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%90 = load i8*, i8** %13
%91 = call i32 (i8*, i8*, ...) @sprintf(i8* %89, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %90)
%92 = load i32, i32* %7
%93 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%94 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%95 = call i32 @strlen(i8* %94)
%96 = call i64 @write(i32 %92, i8* %93, i32 %95)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %88
br label %150
99: ; preds = %88
br label %100
100: ; preds = %99, %85, %82
%101 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%102 = call i32 (i8*, i8*, ...) @sprintf(i8* %101, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%103 = load i32, i32* %7
%104 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%105 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%106 = call i32 @strlen(i8* %105)
%107 = call i64 @write(i32 %103, i8* %104, i32 %106)
%108 = icmp slt i64 %107, 0
br i1 %108, label %109, label %110
109: ; preds = %100
br label %150
110: ; preds = %100
store i32 0, i32* %9
br label %111
111: ; preds = %146, %110
%112 = load i32, i32* %9
%113 = call i8* @get_header(i32 %112, i32 0)
store i8* %113, i8** %14
%114 = load i32, i32* %9
%115 = call i8* @get_header(i32 %114, i32 1)
store i8* %115, i8** %15
%116 = load i8*, i8** %14
%117 = icmp ne i8* %116, null
br i1 %117, label %118, label %121
118: ; preds = %111
%119 = load i8*, i8** %15
%120 = icmp ne i8* %119, null
br i1 %120, label %122, label %121
121: ; preds = %118, %111
br label %149
122: ; preds = %118
%123 = load i32, i32* %7
%124 = load i8*, i8** %14
%125 = load i8*, i8** %14
%126 = call i32 @strlen(i8* %125)
%127 = call i64 @write(i32 %123, i8* %124, i32 %126)
%128 = icmp slt i64 %127, 0
br i1 %128, label %144, label %129
129: ; preds = %122
%130 = load i32, i32* %7
%131 = call i64 @write(i32 %130, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%132 = icmp slt i64 %131, 0
br i1 %132, label %144, label %133
133: ; preds = %129
%134 = load i32, i32* %7
%135 = load i8*, i8** %15
%136 = load i8*, i8** %15
%137 = call i32 @strlen(i8* %136)
%138 = call i64 @write(i32 %134, i8* %135, i32 %137)
%139 = icmp slt i64 %138, 0
br i1 %139, label %144, label %140
140: ; preds = %133
%141 = load i32, i32* %7
%142 = call i64 @write(i32 %141, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%143 = icmp slt i64 %142, 0
br i1 %143, label %144, label %145
144: ; preds = %140, %133, %129, %122
br label %149
145: ; preds = %140
br label %146
146: ; preds = %145
%147 = load i32, i32* %9
%148 = add nsw i32 %147, 1
store i32 %148, i32* %9
br label %111
149: ; preds = %144, %121
br label %150
150: ; preds = %149, %109, %98, %80, %65, %51, %40, %25
%151 = call i32 (...) @headers_cleanup()
%152 = load i32, i32* %7
%153 = call i32 @hangup(i32 %152)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Handled by worker #%d\0ARequest:\0A\00"
@.str.1 = [12 x i8] c"Method: %s\0A\00"
@.str.2 = [10 x i8] c"Path: %s\0A\00"
@.str.3 = [13 x i8] c"Version: %s\0A\00"
@.str.4 = [10 x i8] c"Headers:\0A\00"
@.str.5 = [4 x i8] c" = \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @run(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca [255 x i8]
%7 = tail call i32 @headers_parse(i32 %1)
%8 = tail call i32 (...) @headers_get_state()
%9 = tail call i64 @headers_is_error(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %91
11: ; preds = %4
%12 = tail call i32 (...) @headers_has_request()
%13 = icmp eq i32 %12, 0
br i1 %13, label %91, label %14
14: ; preds = %11
%15 = tail call i32 @response_init(i32 200)
store i32 0, i32* %5
%16 = call i8* @get_response(i32* %5)
%17 = icmp eq i8* %16, null
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 1
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %91, label %21
21: ; preds = %14
%22 = call i64 @write(i32 %1, i8* %16, i32 %18)
%23 = icmp slt i64 %22, 0
br i1 %23, label %91, label %24
24: ; preds = %21
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0)
%27 = call i32 @strlen(i8* %25)
%28 = call i64 @write(i32 %1, i8* %25, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %91, label %30
30: ; preds = %24
%31 = call i8* @get_request(i32 0)
%32 = icmp eq i8* %31, null
br i1 %32, label %38, label %33
33: ; preds = %30
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%35 = call i32 @strlen(i8* %25)
%36 = call i64 @write(i32 %1, i8* %25, i32 %35)
%37 = icmp slt i64 %36, 0
br i1 %37, label %91, label %38
38: ; preds = %33, %30
%39 = call i8* @get_request(i32 1)
%40 = icmp eq i8* %39, null
br i1 %40, label %46, label %41
41: ; preds = %38
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%43 = call i32 @strlen(i8* %25)
%44 = call i64 @write(i32 %1, i8* %25, i32 %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %91, label %46
46: ; preds = %41, %38
%47 = call i64 (...) @headers_has_version()
%48 = icmp eq i64 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %46
%50 = call i8* @get_request(i32 2)
%51 = icmp eq i8* %50, null
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %50)
%54 = call i32 @strlen(i8* %25)
%55 = call i64 @write(i32 %1, i8* %25, i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %91, label %57
57: ; preds = %52, %49, %46
%58 = call i32 @strlen(i8* %25)
%59 = call i64 @write(i32 %1, i8* %25, i32 %58)
%60 = icmp slt i64 %59, 0
br i1 %60, label %91, label %61
61: ; preds = %57
%62 = call i8* @get_header(i32 0, i32 0)
%63 = call i8* @get_header(i32 0, i32 1)
%64 = icmp ne i8* %62, null
%65 = icmp ne i8* %63, null
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %73, label %91
67: ; preds = %87
%68 = call i8* @get_header(i32 %90, i32 0)
%69 = call i8* @get_header(i32 %90, i32 1)
%70 = icmp ne i8* %68, null
%71 = icmp ne i8* %69, null
%72 = select i1 %70, i1 %71, i1 false
br i1 %72, label %73, label %91
73: ; preds = %61, %67
%74 = phi i8* [ %69, %67 ], [ %63, %61 ]
%75 = phi i8* [ %68, %67 ], [ %62, %61 ]
%76 = phi i32 [ %90, %67 ], [ 0, %61 ]
%77 = call i32 @strlen(i8* %75)
%78 = call i64 @write(i32 %1, i8* %75, i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %91, label %80
80: ; preds = %73
%81 = call i64 @write(i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%82 = icmp slt i64 %81, 0
br i1 %82, label %91, label %83
83: ; preds = %80
%84 = call i32 @strlen(i8* %74)
%85 = call i64 @write(i32 %1, i8* %74, i32 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %91, label %87
87: ; preds = %83
%88 = call i64 @write(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
%89 = icmp slt i64 %88, 0
%90 = add nuw nsw i32 %76, 1
br i1 %89, label %91, label %67
91: ; preds = %67, %83, %80, %73, %87, %61, %57, %52, %41, %33, %24, %14, %21, %4, %11
%92 = call i32 (...) @headers_cleanup()
%93 = call i32 @hangup(i32 %1)
ret void
}