#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 evbuffer {
  int dummy;
};
struct bufferevent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bufferevent_free(struct bufferevent *);
struct evbuffer *bufferevent_get_input(struct bufferevent *);
struct evbuffer *bufferevent_get_output(struct bufferevent *);
int /*<<< orphan*/ evbuffer_add_buffer(struct evbuffer *, struct evbuffer *);
int /*<<< orphan*/ printf(char *);
void echo_read_cb(struct bufferevent *bev, void *ctx) {
  struct evbuffer *input = bufferevent_get_input(bev);
  struct evbuffer *output = bufferevent_get_output(bev);
  evbuffer_add_buffer(output, input);
  bufferevent_free(bev);
  printf("close bev in echo_read_cb\n");
}


x86 assembly (clang, -O0):
<echo_read_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <bufferevent_get_input@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <bufferevent_get_output@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <evbuffer_add_buffer@plt>
mov    -0x8(%rbp),%rdi
call   1070 <bufferevent_free@plt>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echo_read_cb>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <bufferevent_get_input@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <bufferevent_get_output@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <evbuffer_add_buffer@plt>
mov    %rbx,%rdi
call   1070 <bufferevent_free@plt>
lea    0xe7f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
%struct.evbuffer = type { i32 }
@.str = [27 x i8] c"close bev in echo_read_cb\0A\00"
define void @echo_read_cb(%struct.bufferevent* %0, i8* %1) {
%3 = alloca %struct.bufferevent*
%4 = alloca i8*
%5 = alloca %struct.evbuffer*
%6 = alloca %struct.evbuffer*
store %struct.bufferevent* %0, %struct.bufferevent** %3
store i8* %1, i8** %4
%7 = load %struct.bufferevent*, %struct.bufferevent** %3
%8 = call %struct.evbuffer* @bufferevent_get_input(%struct.bufferevent* %7)
store %struct.evbuffer* %8, %struct.evbuffer** %5
%9 = load %struct.bufferevent*, %struct.bufferevent** %3
%10 = call %struct.evbuffer* @bufferevent_get_output(%struct.bufferevent* %9)
store %struct.evbuffer* %10, %struct.evbuffer** %6
%11 = load %struct.evbuffer*, %struct.evbuffer** %6
%12 = load %struct.evbuffer*, %struct.evbuffer** %5
%13 = call i32 @evbuffer_add_buffer(%struct.evbuffer* %11, %struct.evbuffer* %12)
%14 = load %struct.bufferevent*, %struct.bufferevent** %3
%15 = call i32 @bufferevent_free(%struct.bufferevent* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
%struct.evbuffer = type { i32 }
@str = [26 x i8] c"close bev in echo_read_cb\00"
define void @echo_read_cb(%struct.bufferevent* %0, i8* nocapture readnone %1) {
%3 = tail call %struct.evbuffer* @bufferevent_get_input(%struct.bufferevent* %0)
%4 = tail call %struct.evbuffer* @bufferevent_get_output(%struct.bufferevent* %0)
%5 = tail call i32 @evbuffer_add_buffer(%struct.evbuffer* %4, %struct.evbuffer* %3)
%6 = tail call i32 @bufferevent_free(%struct.bufferevent* %0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
ret void
}