#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 /*<<< orphan*/ input_buffer;
};
struct event_base {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int evbuffer_remove(int /*<<< orphan*/, char **, int);
int /*<<< orphan*/ event_base_loopbreak(struct event_base *);
int /*<<< orphan*/ printf(char *, char *);
void http_request_done(struct evhttp_request *req, void *arg) {
  char buf[1024];
  int s = evbuffer_remove(req->input_buffer, &buf, sizeof(buf) - 1);
  buf[s] = '\0';
  printf("%s", buf);
  event_base_loopbreak((struct event_base *)arg);
}


x86 assembly (clang, -O0):
<http_request_done>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    $0x3ff,%edx
call   1030 <evbuffer_remove@plt>
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <event_base_loopbreak@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_request_done>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    (%rdi),%edi
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x3ff,%edx
call   1030 <evbuffer_remove@plt>
cltq
movb   $0x0,(%rsp,%rax,1)
lea    0xea4(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <event_base_loopbreak@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.evhttp_request = type { i32 }
%struct.event_base = type { i32 }
@.str = [3 x i8] c"%s\00"
define void @http_request_done(%struct.evhttp_request* %0, i8* %1) {
%3 = alloca %struct.evhttp_request*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i32
store %struct.evhttp_request* %0, %struct.evhttp_request** %3
store i8* %1, i8** %4
%7 = load %struct.evhttp_request*, %struct.evhttp_request** %3
%8 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = bitcast [1024 x i8]* %5 to i8**
%11 = call i32 @evbuffer_remove(i32 %9, i8** %10, i32 1023)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %4
%18 = bitcast i8* %17 to %struct.event_base*
%19 = call i32 @event_base_loopbreak(%struct.event_base* %18)
ret void
}

LLVM IR (-O2):
%struct.evhttp_request = type { i32 }
%struct.event_base = type { i32 }
@.str = [3 x i8] c"%s\00"
define void @http_request_done(%struct.evhttp_request* nocapture %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.evhttp_request, %struct.evhttp_request* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = bitcast [1024 x i8]* %3 to i8**
%8 = call i32 @evbuffer_remove(i32 %6, i8** %7, i32 1023)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%12 = bitcast i8* %1 to %struct.event_base*
%13 = call i32 @event_base_loopbreak(%struct.event_base* %12)
ret void
}