#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 phr_header {
  int dummy;
};

/* Variables and functions */
char *get_token_to_eol(char const *, char const *, char const **, size_t *,
                       int *);
char const *parse_headers(char const *, char const *, struct phr_header *,
                          size_t *, size_t, int *);
char *parse_http_version(char const *, char const *, int *, int *);
char *parse_int(char const *, char const *, int *, int *);
const char *parse_response(const char *buf, const char *buf_end,
                           int *minor_version, int *status, const char **msg,
                           size_t *msg_len, struct phr_header *headers,
                           size_t *num_headers, size_t max_headers, int *ret) {
  if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
    return NULL;
  }
  if (*buf++ != ' ') {
    *ret = -1;
    return NULL;
  }
  if ((buf = parse_int(buf, buf_end, status, ret)) == NULL) {
    return NULL;
  }
  if (*buf++ != ' ') {
    *ret = -1;
    return NULL;
  }
  if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
    return NULL;
  }
  return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
}


x86 assembly (clang, -O0):
<parse_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    0x28(%rbp),%rcx
call   1050 <parse_http_version@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a0 <parse_response+0x60>
movq   $0x0,-0x8(%rbp)
jmp    1289 <parse_response+0x149>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11d2 <parse_response+0x92>
mov    0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1289 <parse_response+0x149>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    0x28(%rbp),%rcx
call   1060 <parse_int@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1202 <parse_response+0xc2>
movq   $0x0,-0x8(%rbp)
jmp    1289 <parse_response+0x149>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1234 <parse_response+0xf4>
mov    0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1289 <parse_response+0x149>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    0x28(%rbp),%r8
call   1030 <get_token_to_eol@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1268 <parse_response+0x128>
movq   $0x0,-0x8(%rbp)
jmp    1289 <parse_response+0x149>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    0x20(%rbp),%r8
mov    0x28(%rbp),%r9
call   1040 <parse_headers@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_response>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbp
mov    %r8,%r15
mov    %rcx,%r12
mov    %rsi,%r14
mov    0x68(%rsp),%rbx
mov    0x60(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x58(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x50(%rsp),%r13
mov    %rbx,%rcx
call   1050 <parse_http_version@plt>
test   %rax,%rax
je     11f5 <parse_response+0xb5>
cmpb   $0x20,(%rax)
jne    11ef <parse_response+0xaf>
add    $0x1,%rax
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1060 <parse_int@plt>
test   %rax,%rax
je     11f5 <parse_response+0xb5>
cmpb   $0x20,(%rax)
jne    11ef <parse_response+0xaf>
add    $0x1,%rax
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
call   1030 <get_token_to_eol@plt>
test   %rax,%rax
je     11f5 <parse_response+0xb5>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %rbx,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <parse_headers@plt>
movl   $0xffffffff,(%rbx)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.phr_header = type { i32 }
define i8* @parse_response(i8* %0, i8* %1, i32* %2, i32* %3, i8** %4, i64* %5, %struct.phr_header* %6, i64* %7, i64 %8, i32* %9) {
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i8**
%17 = alloca i64*
%18 = alloca %struct.phr_header*
%19 = alloca i64*
%20 = alloca i64
%21 = alloca i32*
store i8* %0, i8** %12
store i8* %1, i8** %13
store i32* %2, i32** %14
store i32* %3, i32** %15
store i8** %4, i8*** %16
store i64* %5, i64** %17
store %struct.phr_header* %6, %struct.phr_header** %18
store i64* %7, i64** %19
store i64 %8, i64* %20
store i32* %9, i32** %21
%22 = load i8*, i8** %12
%23 = load i8*, i8** %13
%24 = load i32*, i32** %14
%25 = load i32*, i32** %21
%26 = call i8* @parse_http_version(i8* %22, i8* %23, i32* %24, i32* %25)
store i8* %26, i8** %12
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %10
store i8* null, i8** %11
br label %70
29: ; preds = %10
%30 = load i8*, i8** %12
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %12
%32 = load i8, i8* %30
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 32
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = load i32*, i32** %21
store i32 -1, i32* %36
store i8* null, i8** %11
br label %70
37: ; preds = %29
%38 = load i8*, i8** %12
%39 = load i8*, i8** %13
%40 = load i32*, i32** %15
%41 = load i32*, i32** %21
%42 = call i8* @parse_int(i8* %38, i8* %39, i32* %40, i32* %41)
store i8* %42, i8** %12
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %45
44: ; preds = %37
store i8* null, i8** %11
br label %70
45: ; preds = %37
%46 = load i8*, i8** %12
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %12
%48 = load i8, i8* %46
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 32
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = load i32*, i32** %21
store i32 -1, i32* %52
store i8* null, i8** %11
br label %70
53: ; preds = %45
%54 = load i8*, i8** %12
%55 = load i8*, i8** %13
%56 = load i8**, i8*** %16
%57 = load i64*, i64** %17
%58 = load i32*, i32** %21
%59 = call i8* @get_token_to_eol(i8* %54, i8* %55, i8** %56, i64* %57, i32* %58)
store i8* %59, i8** %12
%60 = icmp eq i8* %59, null
br i1 %60, label %61, label %62
61: ; preds = %53
store i8* null, i8** %11
br label %70
62: ; preds = %53
%63 = load i8*, i8** %12
%64 = load i8*, i8** %13
%65 = load %struct.phr_header*, %struct.phr_header** %18
%66 = load i64*, i64** %19
%67 = load i64, i64* %20
%68 = load i32*, i32** %21
%69 = call i8* @parse_headers(i8* %63, i8* %64, %struct.phr_header* %65, i64* %66, i64 %67, i32* %68)
store i8* %69, i8** %11
br label %70
70: ; preds = %62, %61, %51, %44, %35, %28
%71 = load i8*, i8** %11
ret i8* %71
}

LLVM IR (-O2):
%struct.phr_header = type { i32 }
define i8* @parse_response(i8* %0, i8* %1, i32* %2, i32* %3, i8** %4, i64* %5, %struct.phr_header* %6, i64* %7, i64 %8, i32* %9) {
%11 = tail call i8* @parse_http_version(i8* %0, i8* %1, i32* %2, i32* %9)
%12 = icmp eq i8* %11, null
br i1 %12, label %31, label %13
13: ; preds = %10
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 32
br i1 %15, label %17, label %16
16: ; preds = %13
store i32 -1, i32* %9
br label %31
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = tail call i8* @parse_int(i8* %18, i8* %1, i32* %3, i32* %9)
%20 = icmp eq i8* %19, null
br i1 %20, label %31, label %21
21: ; preds = %17
%22 = load i8, i8* %19
%23 = icmp eq i8 %22, 32
br i1 %23, label %25, label %24
24: ; preds = %21
store i32 -1, i32* %9
br label %31
25: ; preds = %21
%26 = getelementptr inbounds i8, i8* %19, i64 1
%27 = tail call i8* @get_token_to_eol(i8* %26, i8* %1, i8** %4, i64* %5, i32* %9)
%28 = icmp eq i8* %27, null
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = tail call i8* @parse_headers(i8* %27, i8* %1, %struct.phr_header* %6, i64* %7, i64 %8, i32* %9)
br label %31
31: ; preds = %25, %17, %10, %29, %24, %16
%32 = phi i8* [ null, %16 ], [ null, %24 ], [ %30, %29 ], [ null, %10 ], [ null, %17 ], [ null, %25 ]
ret i8* %32
}