#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct linger {
  int l_onoff;
  scalar_t__ l_linger;
};
struct TYPE_2__ {
  int /*<<< orphan*/ ev_fd;
};
struct bufferevent {
  TYPE_1__ ev_read;
};
typedef int /*<<< orphan*/ lingeropt;

/* Variables and functions */
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_LINGER;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ bev_close(struct bufferevent *);
int /*<<< orphan*/ bev_drain(struct bufferevent *);
scalar_t__ setsockopt(int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ shutdown(int /*<<< orphan*/, int /*<<< orphan*/);
void bev_abort(struct bufferevent *bev) {
  struct linger lingeropt;
  lingeropt.l_onoff = 1;
  lingeropt.l_linger = 0;
  assert((setsockopt(((bev)->ev_read.ev_fd), SOL_SOCKET, SO_LINGER,
                     (char *)&lingeropt, sizeof(lingeropt))) == 0);
  shutdown(((bev)->ev_read.ev_fd), SHUT_RDWR);
  bev_drain(bev);
  bev_close(bev);
}


x86 assembly (clang, -O0):
<bev_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x8(%rbp),%rdi
call   1050 <bev_drain@plt>
mov    -0x8(%rbp),%rdi
call   1070 <bev_close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bev_abort>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x1,(%rsp)
movq   $0x0,0x8(%rsp)
mov    (%rdi),%edi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    (%rbx),%edi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    %rbx,%rdi
call   1050 <bev_drain@plt>
mov    %rbx,%rdi
call   1070 <bev_close@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.bufferevent = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.linger = type { i32, i64 }
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@SHUT_RDWR = global i32 0
define void @bev_abort(%struct.bufferevent* %0) {
%2 = alloca %struct.bufferevent*
%3 = alloca %struct.linger
store %struct.bufferevent* %0, %struct.bufferevent** %2
%4 = getelementptr inbounds %struct.linger, %struct.linger* %3, i32 0, i32 0
store i32 1, i32* %4
%5 = getelementptr inbounds %struct.linger, %struct.linger* %3, i32 0, i32 1
store i64 0, i64* %5
%6 = load %struct.bufferevent*, %struct.bufferevent** %2
%7 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %6, i32 0, i32 0
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* @SOL_SOCKET
%11 = load i32, i32* @SO_LINGER
%12 = bitcast %struct.linger* %3 to i8*
%13 = call i64 @setsockopt(i32 %9, i32 %10, i32 %11, i8* %12, i32 16)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load %struct.bufferevent*, %struct.bufferevent** %2
%18 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32, i32* @SHUT_RDWR
%22 = call i32 @shutdown(i32 %20, i32 %21)
%23 = load %struct.bufferevent*, %struct.bufferevent** %2
%24 = call i32 @bev_drain(%struct.bufferevent* %23)
%25 = load %struct.bufferevent*, %struct.bufferevent** %2
%26 = call i32 @bev_close(%struct.bufferevent* %25)
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.linger = type { i32, i64 }
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@SHUT_RDWR = global i32 0
define void @bev_abort(%struct.bufferevent* %0) {
%2 = alloca %struct.linger
%3 = bitcast %struct.linger* %2 to i8*
%4 = getelementptr inbounds %struct.linger, %struct.linger* %2, i64 0, i32 0
store i32 1, i32* %4
%5 = getelementptr inbounds %struct.linger, %struct.linger* %2, i64 0, i32 1
store i64 0, i64* %5
%6 = getelementptr inbounds %struct.bufferevent, %struct.bufferevent* %0, i64 0, i32 0, i32 0
%7 = load i32, i32* %6
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_LINGER
%10 = call i64 @setsockopt(i32 %7, i32 %8, i32 %9, i8* %3, i32 16)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %6
%15 = load i32, i32* @SHUT_RDWR
%16 = call i32 @shutdown(i32 %14, i32 %15)
%17 = call i32 @bev_drain(%struct.bufferevent* %0)
%18 = call i32 @bev_close(%struct.bufferevent* %0)
ret void
}