#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 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 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;
  do {
    if (!(req)) {
      fprintf(stderr, "[error] %s\n", "req");
      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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11b5 <get_cb+0x45>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
lea    0xe6a(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11ba <get_cb+0x4a>
mov    -0x8(%rbp),%rdi
call   1060 <evhttp_request_get_input_buffer@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <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    0x2de5(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <evbuffer_drain@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cb>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     11bb <get_cb+0x4b>
call   1060 <evhttp_request_get_input_buffer@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <evbuffer_get_length@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <evbuffer_pullup@plt>
mov    0x2e35(%rip),%rcx
mov    (%rcx),%ecx
mov    %eax,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <evbuffer_drain@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
lea    0xe3a(%rip),%rdx
call   1040 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.evhttp_request = 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
@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*
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %2
%8 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%9 = icmp ne %struct.evhttp_request* %8, null
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, 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))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %7
br label %16
16: ; preds = %15
%17 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%18 = call %struct.evbuffer* @evhttp_request_get_input_buffer(%struct.evhttp_request* %17)
store %struct.evbuffer* %18, %struct.evbuffer** %6
%19 = load %struct.evbuffer*, %struct.evbuffer** %6
%20 = call i32 @evbuffer_get_length(%struct.evbuffer* %19)
store i32 %20, i32* %5
%21 = load %struct.evbuffer*, %struct.evbuffer** %6
%22 = load i32, i32* %5
%23 = call i32 @evbuffer_pullup(%struct.evbuffer* %21, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* @stdout
%26 = call i32 @fwrite(i32 %23, i32 %24, i32 1, i32 %25)
%27 = load %struct.evbuffer*, %struct.evbuffer** %6
%28 = load i32, i32* %5
%29 = call i32 @evbuffer_drain(%struct.evbuffer* %27, i32 %28)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = 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
@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.evbuffer* @evhttp_request_get_input_buffer(%struct.evhttp_request* %0)
%11 = tail call i32 @evbuffer_get_length(%struct.evbuffer* %10)
%12 = tail call i32 @evbuffer_pullup(%struct.evbuffer* %10, i32 %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fwrite(i32 %12, i32 %11, i32 1, i32 %13)
%15 = tail call i32 @evbuffer_drain(%struct.evbuffer* %10, i32 %11)
ret void
}