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

/* Variables and functions */
int EVUTIL_SOCKET_ERROR();
struct event_base *evconnlistener_get_base(struct evconnlistener *);
int /*<<< orphan*/ event_base_loopexit(struct event_base *,
                                       int /*<<< orphan*/ *);
char *evutil_socket_error_to_string(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stderr;
void srv_accept_error_cb(struct evconnlistener *listener, void *ctx) {
  struct event_base *base = evconnlistener_get_base(listener);
  int err = EVUTIL_SOCKET_ERROR();
  fprintf(stderr,
          "Got an error %d (%s) on the listener. "
          "Shutting down.\n",
          err, evutil_socket_error_to_string(err));
  event_base_loopexit(base, NULL);
}


x86 assembly (clang, -O0):
<srv_accept_error_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <evconnlistener_get_base@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <EVUTIL_SOCKET_ERROR@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1070 <evutil_socket_error_to_string@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    %rax,%rcx
lea    0xe5f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <event_base_loopexit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srv_accept_error_cb>:
push   %rbp
push   %r14
push   %rbx
call   1060 <evconnlistener_get_base@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <EVUTIL_SOCKET_ERROR@plt>
mov    %eax,%ebp
mov    0x2e74(%rip),%rax
mov    (%rax),%ebx
mov    %ebp,%edi
call   1070 <evutil_socket_error_to_string@plt>
lea    0xe84(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <event_base_loopexit@plt>

LLVM IR (-O0):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@stderr = global i32 0
@.str = [54 x i8] c"Got an error %d (%s) on the listener. Shutting down.\0A\00"
define void @srv_accept_error_cb(%struct.evconnlistener* %0, i8* %1) {
%3 = alloca %struct.evconnlistener*
%4 = alloca i8*
%5 = alloca %struct.event_base*
%6 = alloca i32
store %struct.evconnlistener* %0, %struct.evconnlistener** %3
store i8* %1, i8** %4
%7 = load %struct.evconnlistener*, %struct.evconnlistener** %3
%8 = call %struct.event_base* @evconnlistener_get_base(%struct.evconnlistener* %7)
store %struct.event_base* %8, %struct.event_base** %5
%9 = call i32 (...) @EVUTIL_SOCKET_ERROR()
store i32 %9, i32* %6
%10 = load i32, i32* @stderr
%11 = load i32, i32* %6
%12 = load i32, i32* %6
%13 = call i8* @evutil_socket_error_to_string(i32 %12)
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %13)
%15 = load %struct.event_base*, %struct.event_base** %5
%16 = call i32 @event_base_loopexit(%struct.event_base* %15, i32* null)
ret void
}

LLVM IR (-O2):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@stderr = global i32 0
@.str = [54 x i8] c"Got an error %d (%s) on the listener. Shutting down.\0A\00"
define void @srv_accept_error_cb(%struct.evconnlistener* %0, i8* nocapture readnone %1) {
%3 = tail call %struct.event_base* @evconnlistener_get_base(%struct.evconnlistener* %0)
%4 = tail call i32 (...) @EVUTIL_SOCKET_ERROR()
%5 = load i32, i32* @stderr
%6 = tail call i8* @evutil_socket_error_to_string(i32 %4)
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %4, i8* %6)
%8 = tail call i32 @event_base_loopexit(%struct.event_base* %3, i32* null)
ret void
}