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

/* Variables and functions */
int /*<<< orphan*/ event_base_set(struct event_base *, struct event *);
int /*<<< orphan*/ event_set(struct event *, int, short,
                             void (*)(int, short, void *), void *);
struct event *malloc(int);
struct event *event_new(struct event_base *base, int sock, short what,
                        void (*cb)(int, short, void *), void *arg) {
  struct event *e = malloc(sizeof(struct event));
  event_set(e, sock, what, cb, arg);
  event_base_set(base, e);
  return e;
}


x86 assembly (clang, -O0):
<event_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dx,%ax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xe(%rbp),%ax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
movswl %ax,%edx
call   1050 <event_set@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <event_base_set@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<event_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%r12
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <event_set@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <event_base_set@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.event = type { i32 }
%struct.event_base = type { i32 }
define %struct.event* @event_new(%struct.event_base* %0, i32 %1, i16 signext %2, void (i32, i16, i8*)* %3, i8* %4) {
%6 = alloca %struct.event_base*
%7 = alloca i32
%8 = alloca i16
%9 = alloca void (i32, i16, i8*)*
%10 = alloca i8*
%11 = alloca %struct.event*
store %struct.event_base* %0, %struct.event_base** %6
store i32 %1, i32* %7
store i16 %2, i16* %8
store void (i32, i16, i8*)* %3, void (i32, i16, i8*)** %9
store i8* %4, i8** %10
%12 = call %struct.event* @malloc(i32 4)
store %struct.event* %12, %struct.event** %11
%13 = load %struct.event*, %struct.event** %11
%14 = load i32, i32* %7
%15 = load i16, i16* %8
%16 = load void (i32, i16, i8*)*, void (i32, i16, i8*)** %9
%17 = load i8*, i8** %10
%18 = call i32 @event_set(%struct.event* %13, i32 %14, i16 signext %15, void (i32, i16, i8*)* %16, i8* %17)
%19 = load %struct.event_base*, %struct.event_base** %6
%20 = load %struct.event*, %struct.event** %11
%21 = call i32 @event_base_set(%struct.event_base* %19, %struct.event* %20)
%22 = load %struct.event*, %struct.event** %11
ret %struct.event* %22
}

LLVM IR (-O2):
%struct.event = type { i32 }
%struct.event_base = type { i32 }
define %struct.event* @event_new(%struct.event_base* %0, i32 %1, i16 signext %2, void (i32, i16, i8*)* %3, i8* %4) {
%6 = tail call %struct.event* @malloc(i32 4)
%7 = tail call i32 @event_set(%struct.event* %6, i32 %1, i16 signext %2, void (i32, i16, i8*)* %3, i8* %4)
%8 = tail call i32 @event_base_set(%struct.event_base* %0, %struct.event* %6)
ret %struct.event* %6
}