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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *httpd_parse_headers(char *, struct http_req *);
char *httpd_parse_request_line(char *, struct http_req *);
int /*<<< orphan*/ stderr;
char *httpd_parse_request(char *str, struct http_req *hreq) {
  char *pb;
  pb = str;
  pb = httpd_parse_request_line(str, hreq);
  if (!pb) {
    fprintf(stderr, "error: "
                    "can't parse request line"
                    "\n");
    return NULL;
  }
  return httpd_parse_headers(pb, hreq);
}


x86 assembly (clang, -O0):
<httpd_parse_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <httpd_parse_request_line@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1186 <httpd_parse_request+0x56>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1197 <httpd_parse_request+0x67>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <httpd_parse_headers@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_parse_request>:
push   %rbx
mov    %rsi,%rbx
call   1050 <httpd_parse_request_line@plt>
test   %rax,%rax
je     114a <httpd_parse_request+0x1a>
mov    %rax,%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <httpd_parse_headers@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.http_req = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"error: can't parse request line\0A\00"
define i8* @httpd_parse_request(i8* %0, %struct.http_req* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.http_req*
%6 = alloca i8*
store i8* %0, i8** %4
store %struct.http_req* %1, %struct.http_req** %5
%7 = load i8*, i8** %4
store i8* %7, i8** %6
%8 = load i8*, i8** %4
%9 = load %struct.http_req*, %struct.http_req** %5
%10 = call i8* @httpd_parse_request_line(i8* %8, %struct.http_req* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %20
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = load %struct.http_req*, %struct.http_req** %5
%19 = call i8* @httpd_parse_headers(i8* %17, %struct.http_req* %18)
store i8* %19, i8** %3
br label %20
20: ; preds = %16, %13
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
%struct.http_req = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"error: can't parse request line\0A\00"
define i8* @httpd_parse_request(i8* %0, %struct.http_req* %1) {
%3 = tail call i8* @httpd_parse_request_line(i8* %0, %struct.http_req* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %2
%9 = tail call i8* @httpd_parse_headers(i8* %3, %struct.http_req* %1)
br label %10
10: ; preds = %8, %5
%11 = phi i8* [ %9, %8 ], [ null, %5 ]
ret i8* %11
}