#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__ http_read_line(int, char *, int);
int snprintf(char *, int, char *, ...);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ touch(char *);
int /*<<< orphan*/ url_decode(char *, char *, int);
const char *http_request_line(int fd, char *reqpath, char *env, size_t *env_len,
                              int len, int len2) {
  static char buf[8192];
  char *sp1, *sp2, *qp, *envp = env;
  touch("http_request_line");
  if (http_read_line(fd, buf, sizeof(buf)) < 0)
    return "Socket IO error";
  sp1 = strchr(buf, ' ');
  if (!sp1)
    return "Cannot parse HTTP request (1)";
  *sp1 = '\0';
  sp1++;
  if (*sp1 != '/')
    return "Bad request path";
  sp2 = strchr(sp1, ' ');
  if (!sp2)
    return "Cannot parse HTTP request (2)";
  *sp2 = '\0';
  sp2++;
  if (strcmp(buf, "GET") && strcmp(buf, "POST"))
    return "Unsupported request (not GET or POST)";
  int length = len2;
  int gap = snprintf(envp, length, "REQUEST_METHOD=%s", buf) + 1;
  envp += gap;
  length -= gap;
  gap = snprintf(envp, length, "SERVER_PROTOCOL=%s", sp2) + 1;
  envp += gap;
  length -= gap;
  if ((qp = strchr(sp1, '?'))) {
    *qp = '\0';
    gap += snprintf(envp, length, "QUERY_STRING=%s", qp + 1) + 1;
    length -= gap;
    envp += gap;
  }
  url_decode(reqpath, sp1, len);
  gap = snprintf(envp, length, "REQUEST_URI=%s", reqpath) + 1;
  envp += gap;
  length -= gap;
  gap = snprintf(envp, length, "SERVER_NAME=zoobar.org") + 1;
  envp += gap;
  length -= gap;
  *envp = 0;
  *env_len = envp - env + 1;
  return NULL;
}


x86 assembly (clang, -O0):
<http_request_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xe72(%rip),%rdi
call   1030 <touch@plt>
mov    -0xc(%rbp),%edi
lea    0x2ec3(%rip),%rsi
mov    $0x2000,%edx
call   1080 <http_read_line@plt>
cmp    $0x0,%rax
jge    11c1 <http_request_line+0x61>
lea    0xe5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1439 <http_request_line+0x2d9>
lea    0x2e98(%rip),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11f1 <http_request_line+0x91>
lea    0xe3a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1439 <http_request_line+0x2d9>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1224 <http_request_line+0xc4>
lea    0xe25(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1439 <http_request_line+0x2d9>
mov    -0x38(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1251 <http_request_line+0xf1>
lea    0xe09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1439 <http_request_line+0x2d9>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
lea    0x2df5(%rip),%rdi
lea    0xdfd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12ae <http_request_line+0x14e>
lea    0x2dd8(%rip),%rdi
lea    0xde4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12ae <http_request_line+0x14e>
lea    0xdd3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1439 <http_request_line+0x2d9>
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
lea    0xddc(%rip),%rdx
lea    0x2d97(%rip),%rcx
mov    $0x0,%al
call   1050 <snprintf@plt>
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x40(%rbp),%rcx
lea    0xdac(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x3f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     1392 <http_request_line+0x232>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x48(%rbp),%rcx
add    $0x1,%rcx
lea    0xd5d(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
add    $0x1,%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1060 <url_decode@plt>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x18(%rbp),%rcx
lea    0xd1f(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
lea    0xcf7(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rax,%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_request_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe7a(%rip),%rdi
call   1030 <touch@plt>
lea    0x2ece(%rip),%rsi
mov    %ebp,%edi
mov    $0x2000,%edx
call   1080 <http_read_line@plt>
test   %rax,%rax
js     122b <http_request_line+0xcb>
lea    0x2eb2(%rip),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1237 <http_request_line+0xd7>
mov    %rax,%rbp
movb   $0x0,(%rax)
cmpb   $0x2f,0x1(%rax)
jne    1243 <http_request_line+0xe3>
mov    %rbx,0x20(%rsp)
mov    %r14d,0xc(%rsp)
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     124f <http_request_line+0xef>
mov    %rax,%r14
movb   $0x0,(%rax)
lea    0x2e6a(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     125b <http_request_line+0xfb>
lea    0x2e52(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     125b <http_request_line+0xfb>
lea    0xe52(%rip),%rbp
jmp    136e <http_request_line+0x20e>
lea    0xde0(%rip),%rbp
jmp    136e <http_request_line+0x20e>
lea    0xde4(%rip),%rbp
jmp    136e <http_request_line+0x20e>
lea    0xdf6(%rip),%rbp
jmp    136e <http_request_line+0x20e>
lea    0xdfb(%rip),%rbp
jmp    136e <http_request_line+0x20e>
mov    %r13,0x10(%rsp)
add    $0x1,%r14
lea    0xe33(%rip),%rdx
lea    0x2dee(%rip),%rcx
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %r12,%rcx
movslq %eax,%r12
lea    (%r12,%rcx,1),%r13
mov    %rcx,0x18(%rsp)
lea    (%r12,%rcx,1),%rdi
add    $0x1,%rdi
not    %r12d
add    %r15d,%r12d
lea    0xe0d(%rip),%rdx
mov    %r12d,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %eax,%r14d
movslq %eax,%rbx
add    %rbx,%r13
add    $0x2,%r13
not    %ebx
add    %r12d,%ebx
mov    %rbp,%rdi
mov    $0x3f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12fe <http_request_line+0x19e>
movb   $0x0,(%rax)
add    $0x1,%rax
lea    0xde1(%rip),%rdx
mov    %r13,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
add    %r14d,%eax
add    $0x2,%eax
sub    %eax,%ebx
cltq
add    %rax,%r13
mov    0x10(%rsp),%r15
mov    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
mov    0xc(%rsp),%edx
call   1060 <url_decode@plt>
lea    0xdb5(%rip),%rdx
xor    %ebp,%ebp
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <snprintf@plt>
cltq
lea    (%rax,%r13,1),%r14
add    $0x1,%r14
add    $0x1,%rax
sub    %eax,%ebx
lea    0xd9c(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
cltq
lea    (%rax,%r14,1),%rcx
add    $0x1,%rcx
movb   $0x0,0x1(%rax,%r14,1)
sub    0x18(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,(%r15)
mov    %rbp,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@http_request_line.buf = internal global [8192 x i8] zeroinitializer
@.str = [18 x i8] c"http_request_line\00"
@.str.1 = [16 x i8] c"Socket IO error\00"
@.str.2 = [30 x i8] c"Cannot parse HTTP request (1)\00"
@.str.3 = [17 x i8] c"Bad request path\00"
@.str.4 = [30 x i8] c"Cannot parse HTTP request (2)\00"
@.str.5 = [4 x i8] c"GET\00"
@.str.6 = [5 x i8] c"POST\00"
@.str.7 = [38 x i8] c"Unsupported request (not GET or POST)\00"
@.str.8 = [18 x i8] c"REQUEST_METHOD=%s\00"
@.str.9 = [19 x i8] c"SERVER_PROTOCOL=%s\00"
@.str.10 = [16 x i8] c"QUERY_STRING=%s\00"
@.str.11 = [15 x i8] c"REQUEST_URI=%s\00"
@.str.12 = [23 x i8] c"SERVER_NAME=zoobar.org\00"
define i8* @http_request_line(i32 %0, i8* %1, i8* %2, i64* %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i64* %3, i64** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%20 = load i8*, i8** %10
store i8* %20, i8** %17
%21 = call i32 @touch(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %8
%23 = call i64 @http_read_line(i32 %22, i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i32 8192)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %6
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %137
26: ; preds = %6
%27 = call i8* @strchr(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8 signext 32)
store i8* %27, i8** %14
%28 = load i8*, i8** %14
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %26
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %137
31: ; preds = %26
%32 = load i8*, i8** %14
store i8 0, i8* %32
%33 = load i8*, i8** %14
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %14
%35 = load i8*, i8** %14
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 47
br i1 %38, label %39, label %40
39: ; preds = %31
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %137
40: ; preds = %31
%41 = load i8*, i8** %14
%42 = call i8* @strchr(i8* %41, i8 signext 32)
store i8* %42, i8** %15
%43 = load i8*, i8** %15
%44 = icmp ne i8* %43, null
br i1 %44, label %46, label %45
45: ; preds = %40
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %137
46: ; preds = %40
%47 = load i8*, i8** %15
store i8 0, i8* %47
%48 = load i8*, i8** %15
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %15
%50 = call i64 @strcmp(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = call i64 @strcmp(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %52
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %137
56: ; preds = %52, %46
%57 = load i32, i32* %13
store i32 %57, i32* %18
%58 = load i8*, i8** %17
%59 = load i32, i32* %18
%60 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %58, i32 %59, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0))
%61 = add nsw i32 %60, 1
store i32 %61, i32* %19
%62 = load i32, i32* %19
%63 = load i8*, i8** %17
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8* %65, i8** %17
%66 = load i32, i32* %19
%67 = load i32, i32* %18
%68 = sub nsw i32 %67, %66
store i32 %68, i32* %18
%69 = load i8*, i8** %17
%70 = load i32, i32* %18
%71 = load i8*, i8** %15
%72 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %69, i32 %70, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %71)
%73 = add nsw i32 %72, 1
store i32 %73, i32* %19
%74 = load i32, i32* %19
%75 = load i8*, i8** %17
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8* %77, i8** %17
%78 = load i32, i32* %19
%79 = load i32, i32* %18
%80 = sub nsw i32 %79, %78
store i32 %80, i32* %18
%81 = load i8*, i8** %14
%82 = call i8* @strchr(i8* %81, i8 signext 63)
store i8* %82, i8** %16
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %101
84: ; preds = %56
%85 = load i8*, i8** %16
store i8 0, i8* %85
%86 = load i8*, i8** %17
%87 = load i32, i32* %18
%88 = load i8*, i8** %16
%89 = getelementptr inbounds i8, i8* %88, i64 1
%90 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %86, i32 %87, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %89)
%91 = add nsw i32 %90, 1
%92 = load i32, i32* %19
%93 = add nsw i32 %92, %91
store i32 %93, i32* %19
%94 = load i32, i32* %19
%95 = load i32, i32* %18
%96 = sub nsw i32 %95, %94
store i32 %96, i32* %18
%97 = load i32, i32* %19
%98 = load i8*, i8** %17
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %98, i64 %99
store i8* %100, i8** %17
br label %101
101: ; preds = %84, %56
%102 = load i8*, i8** %9
%103 = load i8*, i8** %14
%104 = load i32, i32* %12
%105 = call i32 @url_decode(i8* %102, i8* %103, i32 %104)
%106 = load i8*, i8** %17
%107 = load i32, i32* %18
%108 = load i8*, i8** %9
%109 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %106, i32 %107, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8* %108)
%110 = add nsw i32 %109, 1
store i32 %110, i32* %19
%111 = load i32, i32* %19
%112 = load i8*, i8** %17
%113 = sext i32 %111 to i64
%114 = getelementptr inbounds i8, i8* %112, i64 %113
store i8* %114, i8** %17
%115 = load i32, i32* %19
%116 = load i32, i32* %18
%117 = sub nsw i32 %116, %115
store i32 %117, i32* %18
%118 = load i8*, i8** %17
%119 = load i32, i32* %18
%120 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %118, i32 %119, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%121 = add nsw i32 %120, 1
store i32 %121, i32* %19
%122 = load i32, i32* %19
%123 = load i8*, i8** %17
%124 = sext i32 %122 to i64
%125 = getelementptr inbounds i8, i8* %123, i64 %124
store i8* %125, i8** %17
%126 = load i32, i32* %19
%127 = load i32, i32* %18
%128 = sub nsw i32 %127, %126
store i32 %128, i32* %18
%129 = load i8*, i8** %17
store i8 0, i8* %129
%130 = load i8*, i8** %17
%131 = load i8*, i8** %10
%132 = ptrtoint i8* %130 to i64
%133 = ptrtoint i8* %131 to i64
%134 = sub i64 %132, %133
%135 = add nsw i64 %134, 1
%136 = load i64*, i64** %11
store i64 %135, i64* %136
store i8* null, i8** %7
br label %137
137: ; preds = %101, %55, %45, %39, %30, %25
%138 = load i8*, i8** %7
ret i8* %138
}

LLVM IR (-O2):
@http_request_line.buf = internal global [8192 x i8] zeroinitializer
@.str = [18 x i8] c"http_request_line\00"
@.str.1 = [16 x i8] c"Socket IO error\00"
@.str.2 = [30 x i8] c"Cannot parse HTTP request (1)\00"
@.str.3 = [17 x i8] c"Bad request path\00"
@.str.4 = [30 x i8] c"Cannot parse HTTP request (2)\00"
@.str.5 = [4 x i8] c"GET\00"
@.str.6 = [5 x i8] c"POST\00"
@.str.7 = [38 x i8] c"Unsupported request (not GET or POST)\00"
@.str.8 = [18 x i8] c"REQUEST_METHOD=%s\00"
@.str.9 = [19 x i8] c"SERVER_PROTOCOL=%s\00"
@.str.10 = [16 x i8] c"QUERY_STRING=%s\00"
@.str.11 = [15 x i8] c"REQUEST_URI=%s\00"
@.str.12 = [23 x i8] c"SERVER_NAME=zoobar.org\00"
define i8* @http_request_line(i32 %0, i8* %1, i8* %2, i64* nocapture writeonly %3, i32 %4, i32 %5) {
%7 = tail call i32 @touch(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = tail call i64 @http_read_line(i32 %0, i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i32 8192)
%9 = icmp slt i64 %8, 0
br i1 %9, label %65, label %10
10: ; preds = %6
%11 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8 signext 32)
%12 = icmp eq i8* %11, null
br i1 %12, label %65, label %13
13: ; preds = %10
store i8 0, i8* %11
%14 = getelementptr inbounds i8, i8* %11, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %65
17: ; preds = %13
%18 = tail call i8* @strchr(i8* %14, i8 signext 32)
%19 = icmp eq i8* %18, null
br i1 %19, label %65, label %20
20: ; preds = %17
store i8 0, i8* %18
%21 = getelementptr inbounds i8, i8* %18, i64 1
%22 = tail call i64 @strcmp(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = tail call i64 @strcmp(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %65
27: ; preds = %24, %20
%28 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %2, i32 %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @http_request_line.buf, i64 0, i64 0))
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %2, i64 %30
%32 = sub nsw i32 %5, %29
%33 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %31, i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %21)
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
%37 = sub nsw i32 %32, %34
%38 = tail call i8* @strchr(i8* %14, i8 signext 63)
%39 = icmp eq i8* %38, null
br i1 %39, label %48, label %40
40: ; preds = %27
store i8 0, i8* %38
%41 = getelementptr inbounds i8, i8* %38, i64 1
%42 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %36, i32 %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %41)
%43 = add i32 %33, 2
%44 = add i32 %43, %42
%45 = sub nsw i32 %37, %44
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8, i8* %36, i64 %46
br label %48
48: ; preds = %40, %27
%49 = phi i8* [ %47, %40 ], [ %36, %27 ]
%50 = phi i32 [ %45, %40 ], [ %37, %27 ]
%51 = tail call i32 @url_decode(i8* %1, i8* %14, i32 %4)
%52 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %49, i32 %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8* %1)
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %49, i64 %54
%56 = sub nsw i32 %50, %53
%57 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %55, i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%58 = add nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %55, i64 %59
store i8 0, i8* %60
%61 = ptrtoint i8* %60 to i64
%62 = ptrtoint i8* %2 to i64
%63 = sub i64 1, %62
%64 = add i64 %63, %61
store i64 %64, i64* %3
br label %65
65: ; preds = %24, %17, %13, %10, %6, %48
%66 = phi i8* [ null, %48 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), %17 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), %24 ]
ret i8* %66
}