#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*/ *);
int /*<<< orphan*/ evutil_socket_error_to_string(int);
int /*<<< orphan*/ paxos_log_error(char *, int, int /*<<< orphan*/);
void on_listener_error(struct evconnlistener *l, void *arg) {
  int err = EVUTIL_SOCKET_ERROR();
  struct event_base *base = evconnlistener_get_base(l);
  paxos_log_error("Listener error %d: %s. Shutting down event loop.", err,
                  evutil_socket_error_to_string(err));
  event_base_loopexit(base, NULL);
}


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

x86 assembly (clang, -O2):
<on_listener_error>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <EVUTIL_SOCKET_ERROR@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <evconnlistener_get_base@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1060 <evutil_socket_error_to_string@plt>
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1070 <paxos_log_error@plt>
mov    %rbx,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <event_base_loopexit@plt>

LLVM IR (-O0):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@.str = [49 x i8] c"Listener error %d: %s. Shutting down event loop.\00"
define void @on_listener_error(%struct.evconnlistener* %0, i8* %1) {
%3 = alloca %struct.evconnlistener*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.event_base*
store %struct.evconnlistener* %0, %struct.evconnlistener** %3
store i8* %1, i8** %4
%7 = call i32 (...) @EVUTIL_SOCKET_ERROR()
store i32 %7, i32* %5
%8 = load %struct.evconnlistener*, %struct.evconnlistener** %3
%9 = call %struct.event_base* @evconnlistener_get_base(%struct.evconnlistener* %8)
store %struct.event_base* %9, %struct.event_base** %6
%10 = load i32, i32* %5
%11 = load i32, i32* %5
%12 = call i32 @evutil_socket_error_to_string(i32 %11)
%13 = call i32 @paxos_log_error(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
%14 = load %struct.event_base*, %struct.event_base** %6
%15 = call i32 @event_base_loopexit(%struct.event_base* %14, i32* null)
ret void
}

LLVM IR (-O2):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@.str = [49 x i8] c"Listener error %d: %s. Shutting down event loop.\00"
define void @on_listener_error(%struct.evconnlistener* %0, i8* nocapture readnone %1) {
%3 = tail call i32 (...) @EVUTIL_SOCKET_ERROR()
%4 = tail call %struct.event_base* @evconnlistener_get_base(%struct.evconnlistener* %0)
%5 = tail call i32 @evutil_socket_error_to_string(i32 %3)
%6 = tail call i32 @paxos_log_error(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5)
%7 = tail call i32 @event_base_loopexit(%struct.event_base* %4, i32* null)
ret void
}