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

/* Variables and functions */
int /*<<< orphan*/ BEV_FLUSH;
int EV_READ;
int EV_WRITE;
int /*<<< orphan*/ bufferevent_flush(struct bufferevent *, int,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ bufferevent_write(struct bufferevent *, char *,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void socket_read_cb(struct bufferevent *bev, void *arg) {
  bufferevent_flush(bev, EV_READ | EV_WRITE, BEV_FLUSH);
  static char buf[] =
      "HTTP/1.1 200 0K\r\nConnection:keep-alive\r\nContent-length:4\r\n\r\n"
      "test";
  bufferevent_write(bev, buf, strlen(buf));
}


x86 assembly (clang, -O0):
<socket_read_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    0x2e74(%rip),%rax
or     (%rax),%esi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
call   1030 <bufferevent_flush@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0x2ecd(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0x2ebb(%rip),%rsi
call   1050 <bufferevent_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_read_cb>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eaa(%rip),%rax
mov    0x2e83(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
call   1030 <bufferevent_flush@plt>
lea    0x2ee2(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <bufferevent_write@plt>

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
@EV_READ = global i32 0
@EV_WRITE = global i32 0
@BEV_FLUSH = global i32 0
@socket_read_cb.buf = internal global [65 x i8] c"HTTP/1.1 200 0K\0D\0AConnection:keep-alive\0D\0AContent-length:4\0D\0A\0D\0Atest\00"
define void @socket_read_cb(%struct.bufferevent* %0, i8* %1) {
%3 = alloca %struct.bufferevent*
%4 = alloca i8*
store %struct.bufferevent* %0, %struct.bufferevent** %3
store i8* %1, i8** %4
%5 = load %struct.bufferevent*, %struct.bufferevent** %3
%6 = load i32, i32* @EV_READ
%7 = load i32, i32* @EV_WRITE
%8 = or i32 %6, %7
%9 = load i32, i32* @BEV_FLUSH
%10 = call i32 @bufferevent_flush(%struct.bufferevent* %5, i32 %8, i32 %9)
%11 = load %struct.bufferevent*, %struct.bufferevent** %3
%12 = call i32 @strlen(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @socket_read_cb.buf, i64 0, i64 0))
%13 = call i32 @bufferevent_write(%struct.bufferevent* %11, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @socket_read_cb.buf, i64 0, i64 0), i32 %12)
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
@EV_READ = global i32 0
@EV_WRITE = global i32 0
@BEV_FLUSH = global i32 0
@socket_read_cb.buf = internal global [65 x i8] c"HTTP/1.1 200 0K\0D\0AConnection:keep-alive\0D\0AContent-length:4\0D\0A\0D\0Atest\00"
define void @socket_read_cb(%struct.bufferevent* %0, i8* nocapture readnone %1) {
%3 = load i32, i32* @EV_READ
%4 = load i32, i32* @EV_WRITE
%5 = or i32 %4, %3
%6 = load i32, i32* @BEV_FLUSH
%7 = tail call i32 @bufferevent_flush(%struct.bufferevent* %0, i32 %5, i32 %6)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @socket_read_cb.buf, i64 0, i64 0))
%9 = tail call i32 @bufferevent_write(%struct.bufferevent* %0, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @socket_read_cb.buf, i64 0, i64 0), i32 %8)
ret void
}