#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 /*<<< orphan*/ evconnlistener_free(struct evconnlistener *);
int /*<<< orphan*/ event_base_free(struct event_base *);
struct event_base *event_base_new();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setup_unix(struct event_base *, struct evconnlistener **,
                              char *);
int main(void) {
  struct evconnlistener *listener;
  struct event_base *base = event_base_new();
  if (base == NULL) {
    printf("Could not create libevent base\n");
    return 1;
  }
  setup_unix(base, &listener, "/tmp/unix_ipc.sock");
  evconnlistener_free(listener);
  event_base_free(base);
  printf("Success!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <event_base_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <main+0x3d>
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <main+0x76>
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    0xe84(%rip),%rdx
call   1040 <setup_unix@plt>
mov    -0x10(%rbp),%rdi
call   1060 <evconnlistener_free@plt>
mov    -0x18(%rbp),%rdi
call   1070 <event_base_free@plt>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <event_base_new@plt>
test   %rax,%rax
je     1195 <main+0x45>
mov    %rax,%rbx
lea    0xe95(%rip),%rdx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <setup_unix@plt>
mov    (%rsp),%rdi
call   1060 <evconnlistener_free@plt>
mov    %rbx,%rdi
call   1070 <event_base_free@plt>
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
jmp    11a6 <main+0x56>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@.str = [32 x i8] c"Could not create libevent base\0A\00"
@.str.1 = [19 x i8] c"/tmp/unix_ipc.sock\00"
@.str.2 = [10 x i8] c"Success!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.evconnlistener*
%3 = alloca %struct.event_base*
store i32 0, i32* %1
%4 = call %struct.event_base* (...) @event_base_new()
store %struct.event_base* %4, %struct.event_base** %3
%5 = load %struct.event_base*, %struct.event_base** %3
%6 = icmp eq %struct.event_base* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %17
9: ; preds = %0
%10 = load %struct.event_base*, %struct.event_base** %3
%11 = call i32 @setup_unix(%struct.event_base* %10, %struct.evconnlistener** %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%12 = load %struct.evconnlistener*, %struct.evconnlistener** %2
%13 = call i32 @evconnlistener_free(%struct.evconnlistener* %12)
%14 = load %struct.event_base*, %struct.event_base** %3
%15 = call i32 @event_base_free(%struct.event_base* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %17
17: ; preds = %9, %7
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
%struct.evconnlistener = type { i32 }
%struct.event_base = type { i32 }
@.str.1 = [19 x i8] c"/tmp/unix_ipc.sock\00"
@str = [9 x i8] c"Success!\00"
@str.3 = [31 x i8] c"Could not create libevent base\00"
define i32 @main() {
%1 = alloca %struct.evconnlistener*
%2 = bitcast %struct.evconnlistener** %1 to i8*
%3 = tail call %struct.event_base* (...) @event_base_new()
%4 = icmp eq %struct.event_base* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.3, i64 0, i64 0))
br label %13
7: ; preds = %0
%8 = call i32 @setup_unix(%struct.event_base* %3, %struct.evconnlistener** %1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = load %struct.evconnlistener*, %struct.evconnlistener** %1
%10 = call i32 @evconnlistener_free(%struct.evconnlistener* %9)
%11 = call i32 @event_base_free(%struct.event_base* %3)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %7, %5
%14 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %14
}