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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ bufferevent_base_set(struct event_base *,
                                        struct bufferevent *);
struct bufferevent *bufferevent_new(int, int /*<<< orphan*/, int /*<<< orphan*/,
                                    int /*<<< orphan*/, int /*<<< orphan*/);
struct bufferevent *bufferevent_socket_new(struct event_base *base, int fd,
                                           int flags) {
  assert(!flags);
  struct bufferevent *bev = bufferevent_new(fd, 0, 0, 0, 0);
  bufferevent_base_set(base, bev);
  return bev;
}


x86 assembly (clang, -O0):
<bufferevent_socket_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0xc(%rbp),%edi
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <bufferevent_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <bufferevent_base_set@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bufferevent_socket_new>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %edi,%edi
test   %edx,%edx
sete   %dil
call   1040 <assert@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <bufferevent_new@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <bufferevent_base_set@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
%struct.event_base = type { i32 }
define %struct.bufferevent* @bufferevent_socket_new(%struct.event_base* %0, i32 %1, i32 %2) {
%4 = alloca %struct.event_base*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.bufferevent*
store %struct.event_base* %0, %struct.event_base** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %5
%14 = call %struct.bufferevent* @bufferevent_new(i32 %13, i32 0, i32 0, i32 0, i32 0)
store %struct.bufferevent* %14, %struct.bufferevent** %7
%15 = load %struct.event_base*, %struct.event_base** %4
%16 = load %struct.bufferevent*, %struct.bufferevent** %7
%17 = call i32 @bufferevent_base_set(%struct.event_base* %15, %struct.bufferevent* %16)
%18 = load %struct.bufferevent*, %struct.bufferevent** %7
ret %struct.bufferevent* %18
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
%struct.event_base = type { i32 }
define %struct.bufferevent* @bufferevent_socket_new(%struct.event_base* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call %struct.bufferevent* @bufferevent_new(i32 %1, i32 0, i32 0, i32 0, i32 0)
%8 = tail call i32 @bufferevent_base_set(%struct.event_base* %0, %struct.bufferevent* %7)
ret %struct.bufferevent* %7
}