#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 addrinfo {
  scalar_t__ ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  int /*<<< orphan*/ *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ AI_CANONNAME;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOMAXCONN;
int STDERR_FILENO;
int STDOUT_FILENO;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ bind(int, int /*<<< orphan*/ *, scalar_t__);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ *getcwd(char *, size_t const);
scalar_t__ listen(int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
size_t read(int, char *, size_t const);
char *realpath(char *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, size_t);
int main(int argc, char **argv) {
  struct addrinfo *address, hint;
  const size_t max = 1024;
  char request[max], response[max], web_root[max], *uri, *path;
  size_t request_length, response_length, uri_length;
  int server, client, file;
  if (argc != 3) {
    write(STDERR_FILENO, "Usage: httpd hostname port\n", 27);
    return 1;
  }
  hint.ai_flags = AI_CANONNAME;
  hint.ai_family = AF_INET6;
  hint.ai_socktype = SOCK_STREAM;
  hint.ai_protocol = 0;
  hint.ai_addrlen = 0;
  hint.ai_addr = NULL;
  hint.ai_canonname = NULL;
  hint.ai_next = NULL;
  if (getaddrinfo(argv[1], argv[2], &hint, &address) != 0)
    return 2;
  if ((server = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
    return 3;
  if (bind(server, address->ai_addr, address->ai_addrlen) != 0)
    return 5;
  if (listen(server, SOMAXCONN) != 0)
    return 7;
  if (getcwd(web_root, max) == NULL)
    return 11;
http:
  if ((client = accept(server, NULL, NULL)) == -1)
    return 13;
  request_length = read(client, request, max);
  if ((request_length > 5) && (strncmp("GET /", request, 5) == 0)) {
    uri = request + 5;
    uri_length = strchr(uri, ' ') - uri;
    uri[uri_length] = '\0';
    path = realpath(uri, NULL);
    if (path && strncmp(web_root, path, strlen(web_root)) == 0 &&
        (file = open(uri, O_RDONLY)) != -1) {
      write(STDOUT_FILENO, uri - 1, uri_length + 1);
      write(STDOUT_FILENO, "\n", 1);
      while ((response_length = read(file, response, max)) > 0)
        write(client, response, response_length);
      close(file);
    }
    free(path);
  }
  close(client);
  goto http;
  close(server);
  freeaddrinfo(address);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x400,-0x58(%rbp)
mov    %rsp,%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1252 <main+0x62>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x1b,%edx
call   1050 <write@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1100 <getaddrinfo@plt>
cmp    $0x0,%rax
je     12db <main+0xeb>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x8c(%rbp)
cmp    $0xffffffff,%eax
jne    1319 <main+0x129>
movl   $0x3,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
mov    -0x8c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
call   10d0 <bind@plt>
cmp    $0x0,%rax
je     1353 <main+0x163>
movl   $0x5,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
mov    -0x8c(%rbp),%edi
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
je     1387 <main+0x197>
movl   $0x7,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
lea    -0xca0(%rbp),%rdi
mov    $0x400,%esi
call   1080 <getcwd@plt>
cmp    $0x0,%rax
jne    13b8 <main+0x1c8>
movl   $0xb,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
jmp    13bd <main+0x1cd>
mov    -0x8c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10f0 <accept@plt>
mov    %eax,-0x90(%rbp)
cmp    $0xffffffff,%eax
jne    13f4 <main+0x204>
movl   $0xd,-0x4(%rbp)
movl   $0x1,-0x98(%rbp)
jmp    1588 <main+0x398>
mov    -0x90(%rbp),%edi
lea    -0x4a0(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x5,-0x78(%rbp)
jbe    1578 <main+0x388>
lea    0xbfb(%rip),%rdi
lea    -0x4a0(%rbp),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1578 <main+0x388>
lea    -0x4a0(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    -0x68(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x88(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <realpath@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     156f <main+0x37f>
mov    -0x70(%rbp),%rax
mov    %rax,-0xca8(%rbp)
lea    -0xca0(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xca8(%rbp),%rsi
mov    %eax,%edx
lea    -0xca0(%rbp),%rdi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    156f <main+0x37f>
mov    -0x68(%rbp),%rdi
mov    0x2b0d(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x94(%rbp)
cmp    $0xffffffff,%eax
je     156f <main+0x37f>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
mov    -0x88(%rbp),%rdx
add    $0x1,%rdx
call   1050 <write@plt>
mov    0x2adf(%rip),%rax
mov    (%rax),%edi
lea    0xb00(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x94(%rbp),%edi
lea    -0x8a0(%rbp),%rsi
mov    $0x400,%edx
call   10a0 <read@plt>
mov    %rax,-0x80(%rbp)
cmp    $0x0,%rax
jbe    1564 <main+0x374>
mov    -0x90(%rbp),%edi
mov    -0x80(%rbp),%rdx
lea    -0x8a0(%rbp),%rsi
call   1050 <write@plt>
jmp    1524 <main+0x334>
mov    -0x94(%rbp),%edi
call   1090 <close@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%edi
call   1090 <close@plt>
jmp    13bd <main+0x1cd>
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0xcb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc68,%rsp
mov    %rsp,%r14
cmp    $0x3,%edi
jne    1302 <main+0x112>
mov    0x2dc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
mov    0x2daf(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x4c(%rsp)
mov    0x2d8a(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x48(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1100 <getaddrinfo@plt>
mov    $0x2,%r13d
test   %rax,%rax
jne    1322 <main+0x132>
mov    (%rbx),%edi
mov    0x0(%rbp),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     133a <main+0x14a>
mov    %eax,%ebx
mov    0x18(%rsp),%rax
mov    (%rax),%rdx
mov    0x8(%rax),%rsi
mov    %ebx,%edi
call   10d0 <bind@plt>
mov    $0x5,%r13d
test   %rax,%rax
jne    1322 <main+0x132>
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10c0 <listen@plt>
mov    $0x7,%r13d
test   %rax,%rax
jne    1322 <main+0x132>
lea    0x460(%rsp),%rdi
mov    $0x400,%esi
call   1080 <getcwd@plt>
test   %rax,%rax
je     1342 <main+0x152>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10f0 <accept@plt>
mov    $0xd,%r13d
cmp    $0xffffffff,%eax
je     1322 <main+0x132>
mov    %eax,%r15d
lea    0x60(%rsp),%rbp
lea    0xd1f(%rip),%r12
jmp    138b <main+0x19b>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
mov    $0x1b,%edx
call   1050 <write@plt>
mov    $0x1,%r13d
mov    %r14,%rsp
mov    %r13d,%eax
add    $0xc68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3,%r13d
jmp    1322 <main+0x132>
mov    $0xb,%r13d
jmp    1322 <main+0x132>
mov    %ebp,%edi
call   1090 <close@plt>
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0x60(%rsp),%rbp
lea    0xcb2(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1090 <close@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10f0 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
je     1322 <main+0x132>
mov    $0x400,%edx
mov    %r15d,%edi
mov    %rbp,%rsi
call   10a0 <read@plt>
cmp    $0x6,%rax
jb     1370 <main+0x180>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1370 <main+0x180>
lea    0x65(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%r12
sub    %rbp,%r12
movb   $0x0,0x65(%rsp,%r12,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <realpath@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1356 <main+0x166>
mov    %rbp,0x10(%rsp)
lea    0x460(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1356 <main+0x166>
mov    0x2bbf(%rip),%rax
mov    (%rax),%esi
lea    0x65(%rsp),%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     1356 <main+0x166>
mov    %eax,%ebp
mov    %eax,0xc(%rsp)
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
add    $0x1,%r12
lea    0x64(%rsp),%rsi
mov    %r12,%rdx
call   1050 <write@plt>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%edx
lea    0xbaf(%rip),%rsi
call   1050 <write@plt>
mov    $0x400,%edx
mov    %ebp,%edi
lea    0x860(%rsp),%r12
mov    %r12,%rsi
call   10a0 <read@plt>
test   %rax,%rax
mov    0xc(%rsp),%ebp
je     134a <main+0x15a>
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
mov    $0x400,%edx
mov    %ebp,%edi
mov    %r12,%rsi
call   10a0 <read@plt>
test   %rax,%rax
jne    1494 <main+0x2a4>
jmp    134a <main+0x15a>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32*, i32*, i32*, i64, i32, i32, i32 }
@STDERR_FILENO = global i32 0
@.str = [28 x i8] c"Usage: httpd hostname port\0A\00"
@AI_CANONNAME = global i32 0
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@SOMAXCONN = global i32 0
@.str.1 = [6 x i8] c"GET /\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo*
%7 = alloca %struct.addrinfo
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1024, i64* %8
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %9
%20 = alloca i8, i64 1024
%21 = alloca i8, i64 1024
%22 = alloca i8, i64 1024
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 3
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = load i32, i32* @STDERR_FILENO
%27 = call i32 @write(i32 %26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 27)
store i32 1, i32* %3
store i32 1, i32* %18
br label %141
28: ; preds = %2
%29 = load i32, i32* @AI_CANONNAME
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 7
store i32 %29, i32* %30
%31 = load i32, i32* @AF_INET6
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 6
store i32 %31, i32* %32
%33 = load i32, i32* @SOCK_STREAM
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 5
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i64 0, i64* %35
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 0
store i64 0, i64* %36
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 1
store i32* null, i32** %37
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32* null, i32** %38
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 2
store i32* null, i32** %39
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i64 @getaddrinfo(i8* %42, i8* %45, %struct.addrinfo* %7, %struct.addrinfo** %6)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %28
store i32 2, i32* %3
store i32 1, i32* %18
br label %141
49: ; preds = %28
%50 = load i32, i32* @AF_INET6
%51 = load i32, i32* @SOCK_STREAM
%52 = call i32 @socket(i32 %50, i32 %51, i32 0)
store i32 %52, i32* %15
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %55
54: ; preds = %49
store i32 3, i32* %3
store i32 1, i32* %18
br label %141
55: ; preds = %49
%56 = load i32, i32* %15
%57 = load %struct.addrinfo*, %struct.addrinfo** %6
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 1
%59 = load i32*, i32** %58
%60 = load %struct.addrinfo*, %struct.addrinfo** %6
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = call i64 @bind(i32 %56, i32* %59, i64 %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %55
store i32 5, i32* %3
store i32 1, i32* %18
br label %141
66: ; preds = %55
%67 = load i32, i32* %15
%68 = load i32, i32* @SOMAXCONN
%69 = call i64 @listen(i32 %67, i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %66
store i32 7, i32* %3
store i32 1, i32* %18
br label %141
72: ; preds = %66
%73 = call i32* @getcwd(i8* %22, i64 1024)
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %76
75: ; preds = %72
store i32 11, i32* %3
store i32 1, i32* %18
br label %141
76: ; preds = %72
br label %77
77: ; preds = %138, %76
%78 = load i32, i32* %15
%79 = call i32 @accept(i32 %78, i32* null, i32* null)
store i32 %79, i32* %16
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %82
81: ; preds = %77
store i32 13, i32* %3
store i32 1, i32* %18
br label %141
82: ; preds = %77
%83 = load i32, i32* %16
%84 = call i64 @read(i32 %83, i8* %20, i64 1024)
store i64 %84, i64* %12
%85 = load i64, i64* %12
%86 = icmp ugt i64 %85, 5
br i1 %86, label %87, label %138
87: ; preds = %82
%88 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 5)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %138
90: ; preds = %87
%91 = getelementptr inbounds i8, i8* %20, i64 5
store i8* %91, i8** %10
%92 = load i8*, i8** %10
%93 = call i8* @strchr(i8* %92, i8 signext 32)
%94 = load i8*, i8** %10
%95 = ptrtoint i8* %93 to i64
%96 = ptrtoint i8* %94 to i64
%97 = sub i64 %95, %96
store i64 %97, i64* %14
%98 = load i8*, i8** %10
%99 = load i64, i64* %14
%100 = getelementptr inbounds i8, i8* %98, i64 %99
store i8 0, i8* %100
%101 = load i8*, i8** %10
%102 = call i8* @realpath(i8* %101, i32* null)
store i8* %102, i8** %11
%103 = load i8*, i8** %11
%104 = icmp ne i8* %103, null
br i1 %104, label %105, label %135
105: ; preds = %90
%106 = load i8*, i8** %11
%107 = call i32 @strlen(i8* %22)
%108 = call i64 @strncmp(i8* %22, i8* %106, i32 %107)
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %135
110: ; preds = %105
%111 = load i8*, i8** %10
%112 = load i32, i32* @O_RDONLY
%113 = call i32 @open(i8* %111, i32 %112)
store i32 %113, i32* %17
%114 = icmp ne i32 %113, -1
br i1 %114, label %115, label %135
115: ; preds = %110
%116 = load i32, i32* @STDOUT_FILENO
%117 = load i8*, i8** %10
%118 = getelementptr inbounds i8, i8* %117, i64 -1
%119 = load i64, i64* %14
%120 = add i64 %119, 1
%121 = call i32 @write(i32 %116, i8* %118, i64 %120)
%122 = load i32, i32* @STDOUT_FILENO
%123 = call i32 @write(i32 %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64 1)
br label %124
124: ; preds = %128, %115
%125 = load i32, i32* %17
%126 = call i64 @read(i32 %125, i8* %21, i64 1024)
store i64 %126, i64* %13
%127 = icmp ugt i64 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %124
%129 = load i32, i32* %16
%130 = load i64, i64* %13
%131 = call i32 @write(i32 %129, i8* %21, i64 %130)
br label %124
132: ; preds = %124
%133 = load i32, i32* %17
%134 = call i32 @close(i32 %133)
br label %135
135: ; preds = %132, %110, %105, %90
%136 = load i8*, i8** %11
%137 = call i32 @free(i8* %136)
br label %138
138: ; preds = %135, %87, %82
%139 = load i32, i32* %16
%140 = call i32 @close(i32 %139)
br label %77
141: ; preds = %81, %75, %71, %65, %54, %48, %25
%142 = load i8*, i8** %9
%143 = load i32, i32* %3
ret i32 %143
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32*, i32*, i32*, i64, i32, i32, i32 }
@STDERR_FILENO = global i32 0
@.str = [28 x i8] c"Usage: httpd hostname port\0A\00"
@AI_CANONNAME = global i32 0
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@SOMAXCONN = global i32 0
@.str.1 = [6 x i8] c"GET /\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo*
%4 = alloca %struct.addrinfo
%5 = bitcast %struct.addrinfo** %3 to i8*
%6 = bitcast %struct.addrinfo* %4 to i8*
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = icmp eq i32 %0, 3
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* @STDERR_FILENO
%17 = tail call i32 @write(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 27)
br label %102
18: ; preds = %2
%19 = load i32, i32* @AI_CANONNAME
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 7
store i32 %19, i32* %20
%21 = load i32, i32* @AF_INET6
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 6
store i32 %21, i32* %22
%23 = load i32, i32* @SOCK_STREAM
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 5
store i32 %23, i32* %24
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = bitcast %struct.addrinfo* %4 to i8*
%27 = load i8*, i8** %25
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = call i64 @getaddrinfo(i8* %27, i8* %29, %struct.addrinfo* %4, %struct.addrinfo** %3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %102
32: ; preds = %18
%33 = load i32, i32* @AF_INET6
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
%36 = icmp eq i32 %35, -1
br i1 %36, label %102, label %37
37: ; preds = %32
%38 = load %struct.addrinfo*, %struct.addrinfo** %3
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 1
%40 = load i32*, i32** %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 0
%42 = load i64, i64* %41
%43 = call i64 @bind(i32 %35, i32* %40, i64 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %102
45: ; preds = %37
%46 = load i32, i32* @SOMAXCONN
%47 = call i64 @listen(i32 %35, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %102
49: ; preds = %45
%50 = call i32* @getcwd(i8* %11, i64 1024)
%51 = icmp eq i32* %50, null
br i1 %51, label %102, label %52
52: ; preds = %49
%53 = call i32 @accept(i32 %35, i32* null, i32* null)
%54 = icmp eq i32 %53, -1
br i1 %54, label %102, label %55
55: ; preds = %52
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 5
%57 = ptrtoint i8* %56 to i64
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 4
br label %59
59: ; preds = %55, %98
%60 = phi i32 [ %53, %55 ], [ %100, %98 ]
%61 = call i64 @read(i32 %60, i8* %13, i64 1024)
%62 = icmp ugt i64 %61, 5
br i1 %62, label %63, label %98
63: ; preds = %59
%64 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 5)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %98
66: ; preds = %63
%67 = call i8* @strchr(i8* %56, i8 signext 32)
%68 = ptrtoint i8* %67 to i64
%69 = sub i64 %68, %57
%70 = getelementptr inbounds i8, i8* %56, i64 %69
store i8 0, i8* %70
%71 = call i8* @realpath(i8* %56, i32* null)
%72 = icmp eq i8* %71, null
br i1 %72, label %96, label %73
73: ; preds = %66
%74 = call i32 @strlen(i8* %11)
%75 = call i64 @strncmp(i8* %11, i8* %71, i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %96
77: ; preds = %73
%78 = load i32, i32* @O_RDONLY
%79 = call i32 @open(i8* %56, i32 %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %96, label %81
81: ; preds = %77
%82 = load i32, i32* @STDOUT_FILENO
%83 = add i64 %69, 1
%84 = call i32 @write(i32 %82, i8* %58, i64 %83)
%85 = load i32, i32* @STDOUT_FILENO
%86 = call i32 @write(i32 %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64 1)
%87 = call i64 @read(i32 %79, i8* %12, i64 1024)
%88 = icmp eq i64 %87, 0
br i1 %88, label %94, label %89
89: ; preds = %81, %89
%90 = phi i64 [ %92, %89 ], [ %87, %81 ]
%91 = call i32 @write(i32 %60, i8* %12, i64 %90)
%92 = call i64 @read(i32 %79, i8* %12, i64 1024)
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %89
94: ; preds = %89, %81
%95 = call i32 @close(i32 %79)
br label %96
96: ; preds = %94, %77, %73, %66
%97 = call i32 @free(i8* %71)
br label %98
98: ; preds = %96, %63, %59
%99 = call i32 @close(i32 %60)
%100 = call i32 @accept(i32 %35, i32* null, i32* null)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %59
102: ; preds = %98, %52, %49, %45, %37, %32, %18, %15
%103 = phi i32 [ 1, %15 ], [ 2, %18 ], [ 3, %32 ], [ 5, %37 ], [ 7, %45 ], [ 11, %49 ], [ 13, %52 ], [ 13, %98 ]
ret i32 %103
}