#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 int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ close(int);
scalar_t__ errno;
scalar_t__ http_request_handle(int, char *);
char *http_request_recv(int, char *, int, char **);
int /*<<< orphan*/ http_send_error(int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
char *uri_decode(char *);
int handle_http_socket(int fd) {
  static char buf[4096];
  char *ptr = NULL, *req, *endp;
  errno = 0;
  req = http_request_recv(fd, buf, sizeof(buf), &ptr);
  while (req != NULL) {
    if (strncmp((req), ("GET "), strlen("GET ")) == 0) {
      endp = strchr(req + 4, ' ');
      if (endp == NULL) {
        http_send_error(fd, 400, req);
      } else {
        *endp = '\0';
        req = uri_decode(req + 4);
        if (http_request_handle(fd, req) < 0)
          http_send_error(fd, 404, req);
      }
    } else if (strncmp((req), ("OPTIONS "), strlen("OPTIONS ")) == 0 ||
               strncmp((req), ("HEAD "), strlen("HEAD ")) == 0 ||
               strncmp((req), ("POST "), strlen("POST ")) == 0 ||
               strncmp((req), ("PUT "), strlen("PUT ")) == 0 ||
               strncmp((req), ("DELETE "), strlen("DELETE ")) == 0 ||
               strncmp((req), ("TRACE "), strlen("TRACE ")) == 0 ||
               strncmp((req), ("CONNECT "), strlen("CONNECT ")) == 0) {
      http_send_error(fd, 501, req);
    }
    req = http_request_recv(fd, buf, sizeof(buf), &ptr);
  }
  if (errno == 0) {
    printf("[AH]: Closing socket %d (HTTP Socket)\n", fd);
    if (close(fd) < 0)
      printf("[AH]: Error closing HTTP socket\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<handle_http_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e36(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
lea    0x2ec5(%rip),%rsi
mov    $0x1000,%edx
lea    -0x10(%rbp),%rcx
call   10a0 <http_request_recv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     140f <handle_http_socket+0x27f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe19(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe07(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1288 <handle_http_socket+0xf8>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123f <handle_http_socket+0xaf>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    $0x190,%esi
call   1030 <http_send_error@plt>
jmp    1283 <handle_http_socket+0xf3>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1080 <uri_decode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   10b0 <http_request_handle@plt>
cmp    $0x0,%rax
jge    127e <handle_http_socket+0xee>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    $0x194,%esi
call   1030 <http_send_error@plt>
jmp    1283 <handle_http_socket+0xf3>
jmp    13ee <handle_http_socket+0x25e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xd6e(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
lea    0xd5c(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xd47(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xd35(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xd1d(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
lea    0xd0b(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xcf3(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
lea    0xce1(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xcc8(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%edx
lea    0xcb6(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xca0(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
lea    0xc8e(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13d8 <handle_http_socket+0x248>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xc77(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xc65(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13e9 <handle_http_socket+0x259>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    $0x1f5,%esi
call   1030 <http_send_error@plt>
jmp    13ee <handle_http_socket+0x25e>
mov    -0x8(%rbp),%edi
lea    0x2c88(%rip),%rsi
mov    $0x1000,%edx
lea    -0x10(%rbp),%rcx
call   10a0 <http_request_recv@plt>
mov    %rax,-0x18(%rbp)
jmp    11cd <handle_http_socket+0x3d>
mov    0x2bca(%rip),%rax
cmpq   $0x0,(%rax)
jne    145d <handle_http_socket+0x2cd>
mov    -0x8(%rbp),%esi
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
cmp    $0x0,%rax
jge    1451 <handle_http_socket+0x2c1>
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1464 <handle_http_socket+0x2d4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_http_socket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
movq   $0x0,(%rsp)
mov    0x2e23(%rip),%rax
movq   $0x0,(%rax)
lea    0x2eb5(%rip),%rsi
mov    %rsp,%rcx
mov    $0x1000,%edx
call   10b0 <http_request_recv@plt>
test   %rax,%rax
je     13bc <handle_http_socket+0x21c>
mov    %rax,%rbp
lea    0xe15(%rip),%r14
lea    0x2e8e(%rip),%r15
mov    %rsp,%r13
jmp    122f <handle_http_socket+0x8f>
mov    %r12d,%edi
mov    $0x190,%esi
mov    %rbp,%rdx
call   1030 <http_send_error@plt>
mov    %rbx,%r15
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x1000,%edx
mov    %r13,%rcx
call   10b0 <http_request_recv@plt>
mov    %rax,%rbp
test   %rax,%rax
je     13bc <handle_http_socket+0x21c>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1370 <handle_http_socket+0x1d0>
lea    0xdb1(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd95(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd76(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd57(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd3b(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd22(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1350 <handle_http_socket+0x1b0>
lea    0xd08(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1210 <handle_http_socket+0x70>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
mov    $0x1f5,%esi
mov    %rbp,%rdx
call   1030 <http_send_error@plt>
jmp    1210 <handle_http_socket+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rbx
lea    0x4(%rbp),%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11f7 <handle_http_socket+0x57>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1090 <uri_decode@plt>
mov    %rax,%rbp
mov    %r12d,%edi
mov    %rax,%rsi
call   10c0 <http_request_handle@plt>
test   %rax,%rax
mov    %rbx,%r15
jns    1210 <handle_http_socket+0x70>
mov    %r12d,%edi
mov    $0x194,%esi
jmp    1358 <handle_http_socket+0x1b8>
xor    %ebp,%ebp
mov    0x2c1b(%rip),%rax
cmpq   $0x0,(%rax)
jne    13fa <handle_http_socket+0x25a>
lea    0xc65(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12d,%edi
call   10a0 <close@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jns    13fa <handle_http_socket+0x25a>
lea    0xc69(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@handle_http_socket.buf = internal global [4096 x i8] zeroinitializer
@errno = global i64 0
@.str = [5 x i8] c"GET \00"
@.str.1 = [9 x i8] c"OPTIONS \00"
@.str.2 = [6 x i8] c"HEAD \00"
@.str.3 = [6 x i8] c"POST \00"
@.str.4 = [5 x i8] c"PUT \00"
@.str.5 = [8 x i8] c"DELETE \00"
@.str.6 = [7 x i8] c"TRACE \00"
@.str.7 = [9 x i8] c"CONNECT \00"
@.str.8 = [39 x i8] c"[AH]: Closing socket %d (HTTP Socket)\0A\00"
@.str.9 = [33 x i8] c"[AH]: Error closing HTTP socket\0A\00"
define i32 @handle_http_socket(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8* null, i8** %4
store i64 0, i64* @errno
%7 = load i32, i32* %3
%8 = call i8* @http_request_recv(i32 %7, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @handle_http_socket.buf, i64 0, i64 0), i32 4096, i8** %4)
store i8* %8, i8** %5
br label %9
9: ; preds = %82, %1
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %85
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %42
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = call i8* @strchr(i8* %19, i8 signext 32)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i32, i32* %3
%25 = load i8*, i8** %5
%26 = call i32 @http_send_error(i32 %24, i32 400, i8* %25)
br label %41
27: ; preds = %17
%28 = load i8*, i8** %6
store i8 0, i8* %28
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 4
%31 = call i8* @uri_decode(i8* %30)
store i8* %31, i8** %5
%32 = load i32, i32* %3
%33 = load i8*, i8** %5
%34 = call i64 @http_request_handle(i32 %32, i8* %33)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %27
%37 = load i32, i32* %3
%38 = load i8*, i8** %5
%39 = call i32 @http_send_error(i32 %37, i32 404, i8* %38)
br label %40
40: ; preds = %36, %27
br label %41
41: ; preds = %40, %23
br label %82
42: ; preds = %12
%43 = load i8*, i8** %5
%44 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%45 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %77, label %47
47: ; preds = %42
%48 = load i8*, i8** %5
%49 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%50 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %77, label %52
52: ; preds = %47
%53 = load i8*, i8** %5
%54 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%55 = call i64 @strncmp(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %77, label %57
57: ; preds = %52
%58 = load i8*, i8** %5
%59 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%60 = call i64 @strncmp(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %77, label %62
62: ; preds = %57
%63 = load i8*, i8** %5
%64 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%65 = call i64 @strncmp(i8* %63, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %77, label %67
67: ; preds = %62
%68 = load i8*, i8** %5
%69 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%70 = call i64 @strncmp(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %77, label %72
72: ; preds = %67
%73 = load i8*, i8** %5
%74 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%75 = call i64 @strncmp(i8* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %74)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %72, %67, %62, %57, %52, %47, %42
%78 = load i32, i32* %3
%79 = load i8*, i8** %5
%80 = call i32 @http_send_error(i32 %78, i32 501, i8* %79)
br label %81
81: ; preds = %77, %72
br label %82
82: ; preds = %81, %41
%83 = load i32, i32* %3
%84 = call i8* @http_request_recv(i32 %83, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @handle_http_socket.buf, i64 0, i64 0), i32 4096, i8** %4)
store i8* %84, i8** %5
br label %9
85: ; preds = %9
%86 = load i64, i64* @errno
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %97
88: ; preds = %85
%89 = load i32, i32* %3
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %3
%92 = call i64 @close(i32 %91)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %88
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %96
96: ; preds = %94, %88
store i32 -1, i32* %2
br label %98
97: ; preds = %85
store i32 0, i32* %2
br label %98
98: ; preds = %97, %96
%99 = load i32, i32* %2
ret i32 %99
}

LLVM IR (-O2):
@handle_http_socket.buf = internal global [4096 x i8] zeroinitializer
@errno = global i64 0
@.str = [5 x i8] c"GET \00"
@.str.1 = [9 x i8] c"OPTIONS \00"
@.str.2 = [6 x i8] c"HEAD \00"
@.str.3 = [6 x i8] c"POST \00"
@.str.4 = [5 x i8] c"PUT \00"
@.str.5 = [8 x i8] c"DELETE \00"
@.str.6 = [7 x i8] c"TRACE \00"
@.str.7 = [9 x i8] c"CONNECT \00"
@.str.8 = [39 x i8] c"[AH]: Closing socket %d (HTTP Socket)\0A\00"
@str = [32 x i8] c"[AH]: Error closing HTTP socket\00"
define i32 @handle_http_socket(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
store i64 0, i64* @errno
%4 = call i8* @http_request_recv(i32 %0, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @handle_http_socket.buf, i64 0, i64 0), i32 4096, i8** %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %56, label %6
6: ; preds = %1, %53
%7 = phi i8* [ %54, %53 ], [ %4, %1 ]
%8 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %7, i64 4
%13 = call i8* @strchr(i8* %12, i8 signext 32)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @http_send_error(i32 %0, i32 400, i8* %7)
br label %53
17: ; preds = %11
store i8 0, i8* %13
%18 = call i8* @uri_decode(i8* %12)
%19 = call i64 @http_request_handle(i32 %0, i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %53
21: ; preds = %17
%22 = call i32 @http_send_error(i32 %0, i32 404, i8* %18)
br label %53
23: ; preds = %6
%24 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%25 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %51, label %27
27: ; preds = %23
%28 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%29 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %51, label %31
31: ; preds = %27
%32 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%33 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %31
%36 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%37 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %51, label %39
39: ; preds = %35
%40 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%41 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%45 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%49 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47, %43, %39, %35, %31, %27, %23
%52 = call i32 @http_send_error(i32 %0, i32 501, i8* %7)
br label %53
53: ; preds = %47, %51, %15, %21, %17
%54 = call i8* @http_request_recv(i32 %0, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @handle_http_socket.buf, i64 0, i64 0), i32 4096, i8** %2)
%55 = icmp eq i8* %54, null
br i1 %55, label %56, label %6
56: ; preds = %53, %1
%57 = load i64, i64* @errno
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %0)
%61 = call i64 @close(i32 %0)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %65
65: ; preds = %56, %59, %63
%66 = phi i32 [ -1, %63 ], [ -1, %59 ], [ 0, %56 ]
ret i32 %66
}