#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 {
  scalar_t__ writecb;
  scalar_t__ readcb;
};

/* Variables and functions */
int EV_READ;
int EV_WRITE;
int /*<<< orphan*/ bufferevent_disable(struct bufferevent *, int);
void bev_disable(struct bufferevent *bev) {
  int events = 0;
  if (bev->readcb)
    events |= EV_READ;
  if (bev->writecb)
    events |= EV_WRITE;
  bufferevent_disable(bev, events);
}


x86 assembly (clang, -O0):
<bev_disable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1141 <bev_disable+0x31>
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     115e <bev_disable+0x4e>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <bufferevent_disable@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bev_disable>:
xor    %esi,%esi
cmpq   $0x0,0x8(%rdi)
mov    $0x0,%eax
jne    112b <bev_disable+0x1b>
cmpq   $0x0,(%rdi)
jne    113a <bev_disable+0x2a>
or     %eax,%esi
jmp    1030 <bufferevent_disable@plt>
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
cmpq   $0x0,(%rdi)
je     1124 <bev_disable+0x14>
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%esi
or     %eax,%esi
jmp    1030 <bufferevent_disable@plt>

LLVM IR (-O0):
%struct.bufferevent = type { i64, i64 }
@EV_READ = global i32 0
@EV_WRITE = global i32 0
define void @bev_disable(%struct.bufferevent* %0) {
%2 = alloca %struct.bufferevent*
%3 = alloca i32
store %struct.bufferevent* %0, %struct.bufferevent** %2
store i32 0, i32* %3
%4 = load %struct.bufferevent*, %struct.bufferevent** %2
%5 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %4, i32 0, i32 1
%6 = load i64, i64* %5
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @EV_READ
%10 = load i32, i32* %3
%11 = or i32 %10, %9
store i32 %11, i32* %3
br label %12
12: ; preds = %8, %1
%13 = load %struct.bufferevent*, %struct.bufferevent** %2
%14 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %13, i32 0, i32 0
%15 = load i64, i64* %14
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* @EV_WRITE
%19 = load i32, i32* %3
%20 = or i32 %19, %18
store i32 %20, i32* %3
br label %21
21: ; preds = %17, %12
%22 = load %struct.bufferevent*, %struct.bufferevent** %2
%23 = load i32, i32* %3
%24 = call i32 @bufferevent_disable(%struct.bufferevent* %22, i32 %23)
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i64, i64 }
@EV_READ = global i32 0
@EV_WRITE = global i32 0
define void @bev_disable(%struct.bufferevent* %0) {
%2 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %0, i64 0, i32 1
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
%5 = load i32, i32* @EV_READ
%6 = select i1 %4, i32 0, i32 %5
%7 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
%10 = load i32, i32* @EV_WRITE
%11 = select i1 %9, i32 0, i32 %10
%12 = or i32 %11, %6
%13 = tail call i32 @bufferevent_disable(%struct.bufferevent* %0, i32 %12)
ret void
}