#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 */
typedef char wchar_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ close(int);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int strlen(char *);
char *strpbrk(char *, char *);
char *strrchr(char *, int);
char *strtok(char *, char *);
void *httpRequest(void *data) {
  int me = *((int *)data);
  char buf[1000], requestLine[100], tmp[20];
  int a = 0, k = 0, b = 0, received = -1;
  if ((received = recv(me, buf, 100, 0)) < 0) {
    perror("Failed to receive initial bytes from client");
  }
  buf[received - 1] = '\0';
  while (buf[a] != '\n')
    requestLine[a] = buf[a++];
  while (requestLine[b] != ' ')
    tmp[b] = requestLine[b++];
  if (strcmp(tmp, "GET") == 0) {
    char *fileName, *fl1, *fl2;
    fl1 = strpbrk(requestLine, "/");
    fl2 = strtok(fl1, " ");
    fileName = strpbrk(fl2, "/");
    char document_root[10] = "./html";
    if (strcmp(fileName, "/") == 0)
      strcpy(fileName, strcat(document_root, "/index.html"));
    else
      strcpy(fileName, strcat(document_root, fileName));
    FILE *fp;
    int file_exist = 1;
    fp = fopen(fileName, "r");
    if (fp == NULL)
      file_exist = 0;
    char *filetype;
    char *type;
    int s = '.';
    filetype = strrchr(fileName, s);
    if ((strcmp(filetype, ".htm")) == 0 || (strcmp(filetype, ".html")) == 0)
      type = "text/html";
    else if ((strcmp(filetype, ".jpg")) == 0)
      type = "image/jpeg";
    else if (strcmp(filetype, ".gif") == 0)
      type = "image/gif";
    else if (strcmp(filetype, ".txt") == 0)
      type = "text/plain";
    else if ((strcmp(filetype, ".ram") == 0) || (strcmp(filetype, ".ra") == 0))
      type = "audio/x-pn-realaudio";
    else
      type = "application/octet-stream";
    char statusLine[100] = "HTTP/1.0";
    char contentTypeLine[100] = "Content-type: ";
    char entityBody[100] = "<html>";
    if (file_exist == 1) {
      strcpy(statusLine, strcat(statusLine, "200 OK"));
      strcpy(statusLine, strcat(statusLine, "\r\n"));
      strcpy(contentTypeLine, strcat(contentTypeLine, type));
      strcpy(contentTypeLine, strcat(contentTypeLine, "\r\n"));
    } else {
      strcpy(statusLine, strcat(statusLine, "404 Not Found"));
      strcpy(statusLine, strcat(statusLine, "\r\n"));
      strcpy(contentTypeLine, strcat(contentTypeLine, "NONE"));
      strcpy(contentTypeLine, strcat(contentTypeLine, "\r\n"));
      strcpy(entityBody,
             strcat(entityBody, "<HEAD><TITLE>404 Not Found</TITLE></HEAD>"));
      strcpy(entityBody, strcat(entityBody, "<BODY>Not Found</BODY></html>"));
      strcpy(entityBody, strcat(entityBody, "\r\n"));
    }
    if ((send(me, statusLine, strlen(statusLine), 0) == -1) ||
        (send(me, contentTypeLine, strlen(contentTypeLine), 0) == -1) ||
        (send(me, "\r\n", strlen("\r\n"), 0) == -1))
      perror("Failed to send bytes to client");
    if (file_exist) {
      wchar_t read_char[1];
      while ((read_char[0] = fgetc(fp)) != EOF) {
        if (send(me, read_char, sizeof(char), 0) == -1)
          perror("Failed to send bytes to client");
      }
    } else {
      if (send(me, entityBody, 100, 0) == -1)
        perror("Failed to send bytes to client");
    }
    close(me);
    pthread_exit(NULL);
  } else
    printf("Warning message\n");
}


x86 assembly (clang, -O0):
<httpRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x494(%rbp)
movl   $0x0,-0x498(%rbp)
movl   $0x0,-0x49c(%rbp)
movl   $0xffffffff,-0x4a0(%rbp)
ff ff ff
mov    -0x14(%rbp),%edi
lea    -0x400(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x4a0(%rbp)
cmp    $0x0,%eax
jge    1281 <httpRequest+0x71>
lea    0xd84(%rip),%rdi
call   1110 <perror@plt>
mov    -0x4a0(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x400(%rbp,%rax,1)
movslq -0x494(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     12d9 <httpRequest+0xc9>
mov    -0x494(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x494(%rbp)
cltq
mov    -0x400(%rbp,%rax,1),%cl
movslq -0x494(%rbp),%rax
mov    %cl,-0x470(%rbp,%rax,1)
jmp    1294 <httpRequest+0x84>
jmp    12de <httpRequest+0xce>
movslq -0x49c(%rbp),%rax
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     1323 <httpRequest+0x113>
mov    -0x49c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x49c(%rbp)
cltq
mov    -0x470(%rbp,%rax,1),%cl
movslq -0x49c(%rbp),%rax
mov    %cl,-0x490(%rbp,%rax,1)
jmp    12de <httpRequest+0xce>
lea    -0x490(%rbp),%rdi
lea    0xcfb(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    19d1 <httpRequest+0x7c1>
lea    -0x470(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   10f0 <strpbrk@plt>
mov    %rax,-0x4b0(%rbp)
mov    -0x4b0(%rbp),%rdi
lea    0xcca(%rip),%rsi
call   1120 <strtok@plt>
mov    %rax,-0x4b8(%rbp)
mov    -0x4b8(%rbp),%rdi
lea    0xcae(%rip),%rsi
call   10f0 <strpbrk@plt>
mov    %rax,-0x4a8(%rbp)
mov    0xdbb(%rip),%rax
mov    %rax,-0x4c2(%rbp)
mov    0xdb5(%rip),%ax
mov    %ax,-0x4ba(%rbp)
mov    -0x4a8(%rbp),%rdi
lea    0xc78(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    13fb <httpRequest+0x1eb>
mov    -0x4a8(%rbp),%rax
mov    %rax,-0x640(%rbp)
lea    -0x4c2(%rbp),%rdi
lea    0xc51(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x640(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
jmp    142a <httpRequest+0x21a>
mov    -0x4a8(%rbp),%rax
mov    %rax,-0x648(%rbp)
lea    -0x4c2(%rbp),%rdi
mov    -0x4a8(%rbp),%rsi
call   1130 <strcat@plt>
mov    -0x648(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
movl   $0x1,-0x4d4(%rbp)
mov    -0x4a8(%rbp),%rdi
lea    0xbfe(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x4d0(%rbp)
cmpq   $0x0,-0x4d0(%rbp)
jne    1466 <httpRequest+0x256>
movl   $0x0,-0x4d4(%rbp)
movl   $0x2e,-0x4ec(%rbp)
mov    -0x4a8(%rbp),%rdi
mov    -0x4ec(%rbp),%esi
call   1080 <strrchr@plt>
mov    %rax,-0x4e0(%rbp)
mov    -0x4e0(%rbp),%rdi
lea    0xbab(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
je     14c3 <httpRequest+0x2b3>
mov    -0x4e0(%rbp),%rdi
lea    0xb86(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14d6 <httpRequest+0x2c6>
lea    0xb7d(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15d5 <httpRequest+0x3c5>
mov    -0x4e0(%rbp),%rdi
lea    0xb6d(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1506 <httpRequest+0x2f6>
lea    0xb5c(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15d0 <httpRequest+0x3c0>
mov    -0x4e0(%rbp),%rdi
lea    0xb4d(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1536 <httpRequest+0x326>
lea    0xb3c(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15cb <httpRequest+0x3bb>
mov    -0x4e0(%rbp),%rdi
lea    0xb2c(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1566 <httpRequest+0x356>
lea    0xb1b(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15c6 <httpRequest+0x3b6>
mov    -0x4e0(%rbp),%rdi
lea    0xb0c(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
je     15a0 <httpRequest+0x390>
mov    -0x4e0(%rbp),%rdi
lea    0xaf4(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    15b3 <httpRequest+0x3a3>
lea    0xae2(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15c1 <httpRequest+0x3b1>
lea    0xae4(%rip),%rax
mov    %rax,-0x4e8(%rbp)
jmp    15c6 <httpRequest+0x3b6>
jmp    15cb <httpRequest+0x3bb>
jmp    15d0 <httpRequest+0x3c0>
jmp    15d5 <httpRequest+0x3c5>
lea    -0x550(%rbp),%rdi
lea    0xb7d(%rip),%rsi
mov    $0x64,%edx
call   10d0 <memcpy@plt>
lea    -0x5c0(%rbp),%rdi
lea    0xbd5(%rip),%rsi
mov    $0x64,%edx
call   10d0 <memcpy@plt>
lea    -0x630(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1090 <memset@plt>
movb   $0x3c,-0x630(%rbp)
movb   $0x68,-0x62f(%rbp)
movb   $0x74,-0x62e(%rbp)
movb   $0x6d,-0x62d(%rbp)
movb   $0x6c,-0x62c(%rbp)
movb   $0x3e,-0x62b(%rbp)
cmpl   $0x1,-0x4d4(%rbp)
jne    1710 <httpRequest+0x500>
lea    -0x550(%rbp),%rax
mov    %rax,-0x668(%rbp)
lea    -0x550(%rbp),%rdi
lea    0xa4c(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x668(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x550(%rbp),%rax
mov    %rax,-0x660(%rbp)
lea    -0x550(%rbp),%rdi
lea    0xa24(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x660(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x5c0(%rbp),%rax
mov    %rax,-0x658(%rbp)
lea    -0x5c0(%rbp),%rdi
mov    -0x4e8(%rbp),%rsi
call   1130 <strcat@plt>
mov    -0x658(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x5c0(%rbp),%rax
mov    %rax,-0x650(%rbp)
lea    -0x5c0(%rbp),%rdi
lea    0x9c6(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x650(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
jmp    1859 <httpRequest+0x649>
lea    -0x550(%rbp),%rax
mov    %rax,-0x6a0(%rbp)
lea    -0x550(%rbp),%rdi
lea    0x995(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x6a0(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x550(%rbp),%rax
mov    %rax,-0x698(%rbp)
lea    -0x550(%rbp),%rdi
lea    0x963(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x698(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x5c0(%rbp),%rax
mov    %rax,-0x690(%rbp)
lea    -0x5c0(%rbp),%rdi
lea    0x945(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x690(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x5c0(%rbp),%rax
mov    %rax,-0x688(%rbp)
lea    -0x5c0(%rbp),%rdi
lea    0x905(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x688(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x630(%rbp),%rax
mov    %rax,-0x680(%rbp)
lea    -0x630(%rbp),%rdi
lea    0x8ec(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x680(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x630(%rbp),%rax
mov    %rax,-0x678(%rbp)
lea    -0x630(%rbp),%rdi
lea    0x8e7(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x678(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x630(%rbp),%rax
mov    %rax,-0x670(%rbp)
lea    -0x630(%rbp),%rdi
lea    0x878(%rip),%rsi
call   1130 <strcat@plt>
mov    -0x670(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x6ac(%rbp)
lea    -0x550(%rbp),%rax
mov    %rax,-0x6a8(%rbp)
lea    -0x550(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x6ac(%rbp),%edi
mov    -0x6a8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
je     1911 <httpRequest+0x701>
mov    -0x14(%rbp),%eax
mov    %eax,-0x6bc(%rbp)
lea    -0x5c0(%rbp),%rax
mov    %rax,-0x6b8(%rbp)
lea    -0x5c0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x6bc(%rbp),%edi
mov    -0x6b8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
je     1911 <httpRequest+0x701>
mov    -0x14(%rbp),%eax
mov    %eax,-0x6c0(%rbp)
lea    0x7d1(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x6c0(%rbp),%edi
mov    %eax,%edx
lea    0x7bd(%rip),%rsi
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    191d <httpRequest+0x70d>
lea    0x804(%rip),%rdi
call   1110 <perror@plt>
cmpl   $0x0,-0x4d4(%rbp)
je     198b <httpRequest+0x77b>
jmp    192f <httpRequest+0x71f>
mov    -0x4d0(%rbp),%rdi
call   10a0 <fgetc@plt>
mov    %al,-0x631(%rbp)
movsbl %al,%eax
mov    0x269d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1986 <httpRequest+0x776>
mov    -0x14(%rbp),%edi
lea    -0x631(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    1981 <httpRequest+0x771>
lea    0x7a0(%rip),%rdi
call   1110 <perror@plt>
jmp    192f <httpRequest+0x71f>
jmp    19bb <httpRequest+0x7ab>
mov    -0x14(%rbp),%edi
lea    -0x630(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    19b6 <httpRequest+0x7a6>
lea    0x76b(%rip),%rdi
call   1110 <perror@plt>
jmp    19bb <httpRequest+0x7ab>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <pthread_exit@plt>
jmp    19dd <httpRequest+0x7cd>
lea    0x763(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x6c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpRequest>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x5f0,%rsp
mov    (%rdi),%r12d
lea    0x200(%rsp),%rbx
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebp
test   %eax,%eax
js     13e9 <httpRequest+0x1f9>
movslq %ebp,%rax
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x200(%rsp),%al
cmp    $0xa,%al
je     1257 <httpRequest+0x67>
mov    $0x1,%ecx
xchg   %ax,%ax
mov    %al,0x190(%rsp,%rcx,1)
movzbl 0x200(%rsp,%rcx,1),%eax
add    $0x1,%rcx
cmp    $0xa,%al
jne    1240 <httpRequest+0x50>
mov    $0x1,%eax
nopl   0x0(%rax)
mov    %cl,0x170(%rsp,%rax,1)
movzbl 0x190(%rsp,%rax,1),%ecx
add    $0x1,%rax
cmp    $0x20,%cl
jne    1260 <httpRequest+0x70>
lea    0xdad(%rip),%rsi
lea    0x170(%rsp),%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     12a2 <httpRequest+0xb2>
lea    0xea3(%rip),%rdi
call   1050 <puts@plt>
jmp    174b <httpRequest+0x55b>
lea    0x190(%rsp),%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
lea    0xd77(%rip),%rsi
mov    %rax,%rdi
call   1100 <strtok@plt>
mov    %rax,%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,%rbx
movabs $0x6c6d74682f2e,%rax
mov    %rax,0x10(%rsp)
movw   $0x0,0x18(%rsp)
lea    0xd40(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
lea    0xd32(%rip),%rsi
cmovne %rbx,%rsi
lea    0x10(%rsp),%rdi
call   1110 <strcat@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xd1f(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1090 <strrchr@plt>
mov    %rax,%rbx
lea    0xcff(%rip),%rsi
mov    %rax,%rdi
call   10c0 <strcmp@plt>
lea    0xcf5(%rip),%r15
test   %rax,%rax
je     141c <httpRequest+0x22c>
lea    0xcd8(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     141c <httpRequest+0x22c>
lea    0xcd7(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     13fa <httpRequest+0x20a>
lea    0xcd3(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1403 <httpRequest+0x213>
lea    0xcce(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     140c <httpRequest+0x21c>
lea    0xcca(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1415 <httpRequest+0x225>
lea    0xcbb(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strcmp@plt>
test   %rax,%rax
lea    0xcad(%rip),%rax
lea    0xcbb(%rip),%r15
cmove  %rax,%r15
jmp    141c <httpRequest+0x22c>
lea    0xc10(%rip),%rdi
call   10f0 <perror@plt>
jmp    1226 <httpRequest+0x36>
lea    0xc55(%rip),%r15
jmp    141c <httpRequest+0x22c>
lea    0xc5c(%rip),%r15
jmp    141c <httpRequest+0x22c>
lea    0xc62(%rip),%r15
jmp    141c <httpRequest+0x22c>
lea    0xc6d(%rip),%r15
movaps 0xd8d(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movaps 0xd6e(%rip),%xmm0
movaps %xmm0,0x140(%rsp)
movaps 0xd4f(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movaps 0xd30(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xd11(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xcf2(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movl   $0x0,0x160(%rsp)
movaps 0xd98(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xd79(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xd5a(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xd3b(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xd1c(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xcfd(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movl   $0x0,0xf0(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x80(%rsp)
movl   $0x6d74683c,0x20(%rsp)
6d
movw   $0x3e6c,0x24(%rsp)
test   %r14,%r14
je     1573 <httpRequest+0x383>
lea    0x90(%rsp),%rbx
lea    0xb82(%rip),%rsi
lea    0x100(%rsp),%rbp
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xb68(%rip),%rsi
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
jmp    160e <httpRequest+0x41e>
lea    0x20(%rsp),%rbx
lea    0xb42(%rip),%rsi
lea    0x100(%rsp),%rbp
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xb1e(%rip),%r15
mov    %rbp,%rdi
mov    %r15,%rsi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xb13(%rip),%rsi
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xae2(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcat@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xaf3(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcat@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xa9a(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcat@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     1712 <httpRequest+0x522>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     1712 <httpRequest+0x522>
lea    0xa31(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     1712 <httpRequest+0x522>
test   %r14,%r14
je     1723 <httpRequest+0x533>
mov    %r14,%rdi
call   10a0 <fgetc@plt>
mov    %al,0xf(%rsp)
mov    0x2927(%rip),%rbp
cmp    0x0(%rbp),%al
je     173c <httpRequest+0x54c>
lea    0xf(%rsp),%rbx
lea    0xa4a(%rip),%r15
jmp    16f1 <httpRequest+0x501>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   10a0 <fgetc@plt>
mov    %al,0xf(%rsp)
cmp    0x0(%rbp),%al
je     173c <httpRequest+0x54c>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    16e0 <httpRequest+0x4f0>
mov    %r15,%rdi
call   10f0 <perror@plt>
jmp    16e0 <httpRequest+0x4f0>
lea    0xa03(%rip),%rdi
call   10f0 <perror@plt>
test   %r14,%r14
jne    16ae <httpRequest+0x4be>
lea    0x20(%rsp),%rsi
mov    %r12d,%edi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     175b <httpRequest+0x56b>
mov    %r12d,%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   10d0 <pthread_exit@plt>
add    $0x5f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9ba(%rip),%rdi
call   10f0 <perror@plt>
jmp    173c <httpRequest+0x54c>

LLVM IR (-O0):
@.str = [44 x i8] c"Failed to receive initial bytes from client\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c" \00"
@__const.httpRequest.document_root = [10 x i8] c"./html\00\00\00\00"
@.str.4 = [12 x i8] c"/index.html\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [5 x i8] c".htm\00"
@.str.7 = [6 x i8] c".html\00"
@.str.8 = [10 x i8] c"text/html\00"
@.str.9 = [5 x i8] c".jpg\00"
@.str.10 = [11 x i8] c"image/jpeg\00"
@.str.11 = [5 x i8] c".gif\00"
@.str.12 = [10 x i8] c"image/gif\00"
@.str.13 = [5 x i8] c".txt\00"
@.str.14 = [11 x i8] c"text/plain\00"
@.str.15 = [5 x i8] c".ram\00"
@.str.16 = [4 x i8] c".ra\00"
@.str.17 = [21 x i8] c"audio/x-pn-realaudio\00"
@.str.18 = [25 x i8] c"application/octet-stream\00"
@__const.httpRequest.statusLine = [100 x i8] c"HTTP/1.0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.httpRequest.contentTypeLine = [100 x i8] c"Content-type: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.19 = [7 x i8] c"200 OK\00"
@.str.20 = [3 x i8] c"\0D\0A\00"
@.str.21 = [14 x i8] c"404 Not Found\00"
@.str.22 = [5 x i8] c"NONE\00"
@.str.23 = [42 x i8] c"<HEAD><TITLE>404 Not Found</TITLE></HEAD>\00"
@.str.24 = [30 x i8] c"<BODY>Not Found</BODY></html>\00"
@.str.25 = [31 x i8] c"Failed to send bytes to client\00"
@EOF = global i8 0
@.str.26 = [17 x i8] c"Warning message\0A\00"
define i8* @httpRequest(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca [100 x i8]
%7 = alloca [20 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [10 x i8]
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
%21 = alloca [100 x i8]
%22 = alloca [100 x i8]
%23 = alloca [100 x i8]
%24 = alloca [1 x i8]
store i8* %0, i8** %3
%25 = load i8*, i8** %3
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
store i32 %27, i32* %4
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 -1, i32* %11
%28 = load i32, i32* %4
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%30 = call i32 @recv(i32 %28, i8* %29, i32 100, i32 0)
store i32 %30, i32* %11
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %1
%33 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32, %1
%35 = load i32, i32* %11
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %46, %34
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 10
br i1 %45, label %46, label %55
46: ; preds = %39
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %53
store i8 %51, i8* %54
br label %39
55: ; preds = %39
br label %56
56: ; preds = %63, %55
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 32
br i1 %62, label %63, label %72
63: ; preds = %56
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
%66 = sext i32 %64 to i64
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %70
store i8 %68, i8* %71
br label %56
72: ; preds = %56
%73 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %259
76: ; preds = %72
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%78 = call i8* @strpbrk(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %78, i8** %13
%79 = load i8*, i8** %13
%80 = call i8* @strtok(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %80, i8** %14
%81 = load i8*, i8** %14
%82 = call i8* @strpbrk(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %82, i8** %12
%83 = bitcast [10 x i8]* %15 to i8*
%84 = load i8*, i8** %12
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %76
%88 = load i8*, i8** %12
%89 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%90 = call i32 @strcat(i8* %89, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%91 = call i32 @strcpy(i8* %88, i32 %90)
br label %98
92: ; preds = %76
%93 = load i8*, i8** %12
%94 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%95 = load i8*, i8** %12
%96 = call i32 @strcat(i8* %94, i8* %95)
%97 = call i32 @strcpy(i8* %93, i32 %96)
br label %98
98: ; preds = %92, %87
store i32 1, i32* %17
%99 = load i8*, i8** %12
%100 = call i32* @fopen(i8* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %100, i32** %16
%101 = load i32*, i32** %16
%102 = icmp eq i32* %101, null
br i1 %102, label %103, label %104
103: ; preds = %98
store i32 0, i32* %17
br label %104
104: ; preds = %103, %98
store i32 46, i32* %20
%105 = load i8*, i8** %12
%106 = load i32, i32* %20
%107 = call i8* @strrchr(i8* %105, i32 %106)
store i8* %107, i8** %18
%108 = load i8*, i8** %18
%109 = call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %115, label %111
111: ; preds = %104
%112 = load i8*, i8** %18
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %111, %104
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8** %19
br label %145
116: ; preds = %111
%117 = load i8*, i8** %18
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %116
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8** %19
br label %144
121: ; preds = %116
%122 = load i8*, i8** %18
%123 = call i64 @strcmp(i8* %122, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%124 = icmp eq i64 %123, 0
br i1 %124, label %125, label %126
125: ; preds = %121
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8** %19
br label %143
126: ; preds = %121
%127 = load i8*, i8** %18
%128 = call i64 @strcmp(i8* %127, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%129 = icmp eq i64 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %126
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i8** %19
br label %142
131: ; preds = %126
%132 = load i8*, i8** %18
%133 = call i64 @strcmp(i8* %132, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%134 = icmp eq i64 %133, 0
br i1 %134, label %139, label %135
135: ; preds = %131
%136 = load i8*, i8** %18
%137 = call i64 @strcmp(i8* %136, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %140
139: ; preds = %135, %131
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8** %19
br label %141
140: ; preds = %135
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.18, i64 0, i64 0), i8** %19
br label %141
141: ; preds = %140, %139
br label %142
142: ; preds = %141, %130
br label %143
143: ; preds = %142, %125
br label %144
144: ; preds = %143, %120
br label %145
145: ; preds = %144, %115
%146 = bitcast [100 x i8]* %21 to i8*
%147 = bitcast [100 x i8]* %22 to i8*
%148 = bitcast [100 x i8]* %23 to i8*
%149 = bitcast i8* %148 to [100 x i8]*
%150 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 0
store i8 60, i8* %150
%151 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 1
store i8 104, i8* %151
%152 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 2
store i8 116, i8* %152
%153 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 3
store i8 109, i8* %153
%154 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 4
store i8 108, i8* %154
%155 = getelementptr inbounds [100 x i8], [100 x i8]* %149, i32 0, i32 5
store i8 62, i8* %155
%156 = load i32, i32* %17
%157 = icmp eq i32 %156, 1
br i1 %157, label %158, label %176
158: ; preds = %145
%159 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%160 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%161 = call i32 @strcat(i8* %160, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%162 = call i32 @strcpy(i8* %159, i32 %161)
%163 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%164 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%165 = call i32 @strcat(i8* %164, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%166 = call i32 @strcpy(i8* %163, i32 %165)
%167 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%168 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%169 = load i8*, i8** %19
%170 = call i32 @strcat(i8* %168, i8* %169)
%171 = call i32 @strcpy(i8* %167, i32 %170)
%172 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%173 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%174 = call i32 @strcat(i8* %173, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%175 = call i32 @strcpy(i8* %172, i32 %174)
br label %205
176: ; preds = %145
%177 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%178 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%179 = call i32 @strcat(i8* %178, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
%180 = call i32 @strcpy(i8* %177, i32 %179)
%181 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%182 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%183 = call i32 @strcat(i8* %182, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%184 = call i32 @strcpy(i8* %181, i32 %183)
%185 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%186 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%187 = call i32 @strcat(i8* %186, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0))
%188 = call i32 @strcpy(i8* %185, i32 %187)
%189 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%190 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%191 = call i32 @strcat(i8* %190, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%192 = call i32 @strcpy(i8* %189, i32 %191)
%193 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%194 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%195 = call i32 @strcat(i8* %194, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.23, i64 0, i64 0))
%196 = call i32 @strcpy(i8* %193, i32 %195)
%197 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%198 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%199 = call i32 @strcat(i8* %198, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%200 = call i32 @strcpy(i8* %197, i32 %199)
%201 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%202 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%203 = call i32 @strcat(i8* %202, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%204 = call i32 @strcpy(i8* %201, i32 %203)
br label %205
205: ; preds = %176, %158
%206 = load i32, i32* %4
%207 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%208 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%209 = call i32 @strlen(i8* %208)
%210 = call i32 @send(i32 %206, i8* %207, i32 %209, i32 0)
%211 = icmp eq i32 %210, -1
br i1 %211, label %224, label %212
212: ; preds = %205
%213 = load i32, i32* %4
%214 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%215 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%216 = call i32 @strlen(i8* %215)
%217 = call i32 @send(i32 %213, i8* %214, i32 %216, i32 0)
%218 = icmp eq i32 %217, -1
br i1 %218, label %224, label %219
219: ; preds = %212
%220 = load i32, i32* %4
%221 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%222 = call i32 @send(i32 %220, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32 %221, i32 0)
%223 = icmp eq i32 %222, -1
br i1 %223, label %224, label %226
224: ; preds = %219, %212, %205
%225 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %226
226: ; preds = %224, %219
%227 = load i32, i32* %17
%228 = icmp ne i32 %227, 0
br i1 %228, label %229, label %247
229: ; preds = %226
br label %230
230: ; preds = %245, %229
%231 = load i32*, i32** %16
%232 = call signext i8 @fgetc(i32* %231)
%233 = getelementptr inbounds [1 x i8], [1 x i8]* %24, i64 0, i64 0
store i8 %232, i8* %233
%234 = sext i8 %232 to i32
%235 = load i8, i8* @EOF
%236 = sext i8 %235 to i32
%237 = icmp ne i32 %234, %236
br i1 %237, label %238, label %246
238: ; preds = %230
%239 = load i32, i32* %4
%240 = getelementptr inbounds [1 x i8], [1 x i8]* %24, i64 0, i64 0
%241 = call i32 @send(i32 %239, i8* %240, i32 1, i32 0)
%242 = icmp eq i32 %241, -1
br i1 %242, label %243, label %245
243: ; preds = %238
%244 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %245
245: ; preds = %243, %238
br label %230
246: ; preds = %230
br label %255
247: ; preds = %226
%248 = load i32, i32* %4
%249 = getelementptr inbounds [100 x i8], [100 x i8]* %23, i64 0, i64 0
%250 = call i32 @send(i32 %248, i8* %249, i32 100, i32 0)
%251 = icmp eq i32 %250, -1
br i1 %251, label %252, label %254
252: ; preds = %247
%253 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %254
254: ; preds = %252, %247
br label %255
255: ; preds = %254, %246
%256 = load i32, i32* %4
%257 = call i32 @close(i32 %256)
%258 = call i32 @pthread_exit(i32* null)
br label %261
259: ; preds = %72
%260 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.26, i64 0, i64 0))
br label %261
261: ; preds = %259, %255
%262 = load i8*, i8** %2
ret i8* %262
}

LLVM IR (-O2):
@.str = [44 x i8] c"Failed to receive initial bytes from client\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c" \00"
@__const.httpRequest.document_root = [10 x i8] c"./html\00\00\00\00"
@.str.4 = [12 x i8] c"/index.html\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [5 x i8] c".htm\00"
@.str.7 = [6 x i8] c".html\00"
@.str.8 = [10 x i8] c"text/html\00"
@.str.9 = [5 x i8] c".jpg\00"
@.str.10 = [11 x i8] c"image/jpeg\00"
@.str.11 = [5 x i8] c".gif\00"
@.str.12 = [10 x i8] c"image/gif\00"
@.str.13 = [5 x i8] c".txt\00"
@.str.14 = [11 x i8] c"text/plain\00"
@.str.15 = [5 x i8] c".ram\00"
@.str.16 = [4 x i8] c".ra\00"
@.str.17 = [21 x i8] c"audio/x-pn-realaudio\00"
@.str.18 = [25 x i8] c"application/octet-stream\00"
@__const.httpRequest.statusLine = [100 x i8] c"HTTP/1.0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.httpRequest.contentTypeLine = [100 x i8] c"Content-type: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.19 = [7 x i8] c"200 OK\00"
@.str.20 = [3 x i8] c"\0D\0A\00"
@.str.21 = [14 x i8] c"404 Not Found\00"
@.str.22 = [5 x i8] c"NONE\00"
@.str.23 = [42 x i8] c"<HEAD><TITLE>404 Not Found</TITLE></HEAD>\00"
@.str.24 = [30 x i8] c"<BODY>Not Found</BODY></html>\00"
@.str.25 = [31 x i8] c"Failed to send bytes to client\00"
@EOF = global i8 0
@str = [16 x i8] c"Warning message\00"
define noalias i8* @httpRequest(i8* nocapture %0) {
%2 = alloca [1000 x i8]
%3 = alloca [100 x i8]
%4 = alloca [20 x i8]
%5 = alloca [10 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [1 x i8]
%10 = bitcast i8* %0 to i32*
%11 = load i32, i32* %10
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = call i32 @recv(i32 %11, i8* %12, i32 100, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %1
%20 = add nsw i32 %15, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %21
store i8 0, i8* %22
%23 = load i8, i8* %12
%24 = icmp eq i8 %23, 10
br i1 %24, label %33, label %25
25: ; preds = %19, %25
%26 = phi i64 [ %28, %25 ], [ 0, %19 ]
%27 = phi i8 [ %31, %25 ], [ %23, %19 ]
%28 = add nuw nsw i64 %26, 1
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %28
store i8 %27, i8* %29
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %28
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %25
33: ; preds = %25, %19
br label %34
34: ; preds = %33, %34
%35 = phi i64 [ %37, %34 ], [ 0, %33 ]
%36 = phi i8 [ %40, %34 ], [ undef, %33 ]
%37 = add nuw nsw i64 %35, 1
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %37
store i8 %36, i8* %38
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %37
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 32
br i1 %41, label %42, label %34
42: ; preds = %34
%43 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %150
45: ; preds = %42
%46 = call i8* @strchr(i8* %13, i32 47)
%47 = call i8* @strtok(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = call i8* @strchr(i8* dereferenceable(1) %47, i32 47)
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%50 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
%52 = select i1 %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %48
%53 = call i32 @strcat(i8* %49, i8* %52)
%54 = call i32 @strcpy(i8* %48, i32 %53)
%55 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i32* %55, null
%57 = call i8* @strrchr(i8* dereferenceable(1) %48, i32 46)
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %79, label %60
60: ; preds = %45
%61 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %79, label %63
63: ; preds = %60
%64 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %79, label %66
66: ; preds = %63
%67 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %79, label %69
69: ; preds = %66
%70 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %79, label %72
72: ; preds = %69
%73 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %72
%76 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
%78 = select i1 %77, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.18, i64 0, i64 0)
br label %79
79: ; preds = %75, %72, %69, %66, %63, %45, %60
%80 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %60 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), %45 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), %63 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), %66 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), %69 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), %72 ], [ %78, %75 ]
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
store i8 60, i8* %83
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
store i8 104, i8* %84
%85 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 2
store i8 116, i8* %85
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 3
store i8 109, i8* %86
%87 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 4
store i8 108, i8* %87
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 5
store i8 62, i8* %88
br i1 %56, label %96, label %89
89: ; preds = %79
%90 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0))
%91 = call i32 @strcpy(i8* %81, i32 %90)
%92 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%93 = call i32 @strcpy(i8* %81, i32 %92)
%94 = call i32 @strcat(i8* %82, i8* %80)
%95 = call i32 @strcpy(i8* %82, i32 %94)
br label %109
96: ; preds = %79
%97 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
%98 = call i32 @strcpy(i8* %81, i32 %97)
%99 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%100 = call i32 @strcpy(i8* %81, i32 %99)
%101 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.22, i64 0, i64 0))
%102 = call i32 @strcpy(i8* %82, i32 %101)
%103 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%104 = call i32 @strcpy(i8* %82, i32 %103)
%105 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.23, i64 0, i64 0))
%106 = call i32 @strcpy(i8* %83, i32 %105)
%107 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.24, i64 0, i64 0))
%108 = call i32 @strcpy(i8* %83, i32 %107)
br label %109
109: ; preds = %96, %89
%110 = phi i8* [ %83, %96 ], [ %82, %89 ]
%111 = call i32 @strcat(i8* %110, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%112 = call i32 @strcpy(i8* %110, i32 %111)
%113 = call i32 @strlen(i8* %81)
%114 = call i32 @send(i32 %11, i8* %81, i32 %113, i32 0)
%115 = icmp eq i32 %114, -1
br i1 %115, label %124, label %116
116: ; preds = %109
%117 = call i32 @strlen(i8* %82)
%118 = call i32 @send(i32 %11, i8* %82, i32 %117, i32 0)
%119 = icmp eq i32 %118, -1
br i1 %119, label %124, label %120
120: ; preds = %116
%121 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%122 = call i32 @send(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32 %121, i32 0)
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %126
124: ; preds = %120, %116, %109
%125 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %126
126: ; preds = %124, %120
br i1 %56, label %142, label %127
127: ; preds = %126
%128 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%129 = call signext i8 @fgetc(i32* %55)
store i8 %129, i8* %128
%130 = load i8, i8* @EOF
%131 = icmp eq i8 %129, %130
br i1 %131, label %141, label %132
132: ; preds = %127, %137
%133 = call i32 @send(i32 %11, i8* %128, i32 1, i32 0)
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %137
135: ; preds = %132
%136 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %137
137: ; preds = %135, %132
%138 = call signext i8 @fgetc(i32* %55)
store i8 %138, i8* %128
%139 = load i8, i8* @EOF
%140 = icmp eq i8 %138, %139
br i1 %140, label %141, label %132
141: ; preds = %137, %127
br label %147
142: ; preds = %126
%143 = call i32 @send(i32 %11, i8* %83, i32 100, i32 0)
%144 = icmp eq i32 %143, -1
br i1 %144, label %145, label %147
145: ; preds = %142
%146 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.25, i64 0, i64 0))
br label %147
147: ; preds = %142, %145, %141
%148 = call i32 @close(i32 %11)
%149 = call i32 @pthread_exit(i32* null)
br label %152
150: ; preds = %42
%151 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %152
152: ; preds = %150, %147
ret i8* undef
}