#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 evhttp_request {
  int dummy;
};
struct evhttp_connection {
  int dummy;
};
struct evbuffer {
  int dummy;
};
typedef int /*<<< orphan*/ ev_ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ evbuffer_drain(struct evbuffer *, int /*<<< orphan*/);
int /*<<< orphan*/ evbuffer_get_length(struct evbuffer *);
int /*<<< orphan*/ evbuffer_pullup(struct evbuffer *, int /*<<< orphan*/);
struct evhttp_connection *
evhttp_request_get_connection(struct evhttp_request *);
struct evbuffer *evhttp_request_get_input_buffer(struct evhttp_request *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/, int /*<<< orphan*/, int,
                          int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void get_cb(struct evhttp_request *req, void *arg) {
  ev_ssize_t len;
  struct evbuffer *evbuf;
  struct evhttp_connection *evcon;
  do {
    if (!(req)) {
      fprintf(stderr, "[error] %s\n", "req");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  evcon = evhttp_request_get_connection(req);
  do {
    if (!(evcon)) {
      fprintf(stderr, "[error] %s\n", "evcon");
      exit(EXIT_FAILURE);
    }
  } while (0);
  ;
  evbuf = evhttp_request_get_input_buffer(req);
  len = evbuffer_get_length(evbuf);
  fwrite(evbuffer_pullup(evbuf, len), len, 1, stdout);
  evbuffer_drain(evbuf, len);
}


x86 assembly (clang, -O0):
<get_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c5 <get_cb+0x45>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
lea    0xe5a(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11ca <get_cb+0x4a>
mov    -0x8(%rbp),%rdi
call   1050 <evhttp_request_get_connection@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120c <get_cb+0x8c>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe0e(%rip),%rsi
lea    0xe17(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1211 <get_cb+0x91>
mov    -0x8(%rbp),%rdi
call   1070 <evhttp_request_get_input_buffer@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <evbuffer_get_length@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <evbuffer_pullup@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
mov    0x2d8e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <evbuffer_drain@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cb>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     11db <get_cb+0x5b>
mov    %rdi,%rbx
call   1050 <evhttp_request_get_connection@plt>
test   %rax,%rax
je     11f4 <get_cb+0x74>
mov    %rbx,%rdi
call   1070 <evhttp_request_get_input_buffer@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <evbuffer_get_length@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <evbuffer_pullup@plt>
mov    0x2e15(%rip),%rcx
mov    (%rcx),%ecx
mov    %eax,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10a0 <evbuffer_drain@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
lea    0xe1a(%rip),%rdx
jmp    120b <get_cb+0x8b>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
lea    0xe05(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.evbuffer = type { i32 }
%struct.evhttp_connection = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"[error] %s\0A\00"
@.str.1 = [4 x i8] c"req\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"evcon\00"
@stdout = global i32 0
define void @get_cb(%struct.evhttp_request* %0, i8* %1) {
%3 = alloca %struct.evhttp_request*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.evbuffer*
%7 = alloca %struct.evhttp_connection*
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
br label %8
8: ; preds = %2
%9 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%10 = icmp ne %struct.evhttp_request* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%19 = call %struct.evhttp_connection* @evhttp_request_get_connection(%struct.evhttp_request* %18)
store %struct.evhttp_connection* %19, %struct.evhttp_connection** %7
br label %20
20: ; preds = %17
%21 = load %struct.evhttp_connection*, %struct.evhttp_connection** %7
%22 = icmp ne %struct.evhttp_connection* %21, null
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %20
br label %29
29: ; preds = %28
%30 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%31 = call %struct.evbuffer* @evhttp_request_get_input_buffer(%struct.evhttp_request* %30)
store %struct.evbuffer* %31, %struct.evbuffer** %6
%32 = load %struct.evbuffer*, %struct.evbuffer** %6
%33 = call i32 @evbuffer_get_length(%struct.evbuffer* %32)
store i32 %33, i32* %5
%34 = load %struct.evbuffer*, %struct.evbuffer** %6
%35 = load i32, i32* %5
%36 = call i32 @evbuffer_pullup(%struct.evbuffer* %34, i32 %35)
%37 = load i32, i32* %5
%38 = load i32, i32* @stdout
%39 = call i32 @fwrite(i32 %36, i32 %37, i32 1, i32 %38)
%40 = load %struct.evbuffer*, %struct.evbuffer** %6
%41 = load i32, i32* %5
%42 = call i32 @evbuffer_drain(%struct.evbuffer* %40, i32 %41)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.evhttp_connection = type { i32 }
%struct.evbuffer = type { i32 }
@stderr = global i32 0
@.str = [12 x i8] c"[error] %s\0A\00"
@.str.1 = [4 x i8] c"req\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"evcon\00"
@stdout = global i32 0
define void @get_cb(%struct.evhttp_request* %0, i8* nocapture readnone %1) {
%3 = icmp eq %struct.evhttp_request* %0, null
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = tail call %struct.evhttp_connection* @evhttp_request_get_connection(%struct.evhttp_request* %0)
%11 = icmp eq %struct.evhttp_connection* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
%18 = tail call %struct.evbuffer* @evhttp_request_get_input_buffer(%struct.evhttp_request* %0)
%19 = tail call i32 @evbuffer_get_length(%struct.evbuffer* %18)
%20 = tail call i32 @evbuffer_pullup(%struct.evbuffer* %18, i32 %19)
%21 = load i32, i32* @stdout
%22 = tail call i32 @fwrite(i32 %20, i32 %19, i32 1, i32 %21)
%23 = tail call i32 @evbuffer_drain(%struct.evbuffer* %18, i32 %19)
ret void
}