#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 TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};

/* Variables and functions */
int EPOLLET;
int EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ bind_address(int, int);
int create_epoll();
int create_server_socket();
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             struct epoll_event *);
int /*<<< orphan*/ listen_socket(int);
int /*<<< orphan*/ loop(int);
int main(int argc, char **argv) {
  int epollfd = create_epoll();
  int serverfd = create_server_socket();
  bind_address(serverfd, 1234);
  struct epoll_event event;
  event.data.fd = serverfd;
  event.events = EPOLLIN | EPOLLET;
  epoll_ctl(epollfd, EPOLL_CTL_ADD, serverfd, &event);
  listen_socket(serverfd);
  loop(epollfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <create_epoll@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <create_server_socket@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x4d2,%esi
call   1060 <bind_address@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    0x2e2a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
lea    -0x20(%rbp),%rcx
call   1050 <epoll_ctl@plt>
mov    -0x18(%rbp),%edi
call   1070 <listen_socket@plt>
mov    -0x14(%rbp),%edi
call   1040 <loop@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <create_epoll@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <create_server_socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x4d2,%esi
call   1060 <bind_address@plt>
mov    0x2e60(%rip),%rax
mov    0x2e41(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ebp,0x4(%rsp)
mov    %ecx,(%rsp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    %ebp,%edx
call   1050 <epoll_ctl@plt>
mov    %ebp,%edi
call   1070 <listen_socket@plt>
mov    %ebx,%edi
call   1040 <loop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.epoll_event
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = call i32 (...) @create_epoll()
store i32 %8, i32* %5
%9 = call i32 (...) @create_server_socket()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @bind_address(i32 %10, i32 1234)
%12 = load i32, i32* %6
%13 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
store i32 %12, i32* %14
%15 = load i32, i32* @EPOLLIN
%16 = load i32, i32* @EPOLLET
%17 = or i32 %15, %16
%18 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
store i32 %17, i32* %18
%19 = load i32, i32* %5
%20 = load i32, i32* @EPOLL_CTL_ADD
%21 = load i32, i32* %6
%22 = call i32 @epoll_ctl(i32 %19, i32 %20, i32 %21, %struct.epoll_event* %7)
%23 = load i32, i32* %6
%24 = call i32 @listen_socket(i32 %23)
%25 = load i32, i32* %5
%26 = call i32 @loop(i32 %25)
ret i32 0
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.epoll_event
%4 = tail call i32 (...) @create_epoll()
%5 = tail call i32 (...) @create_server_socket()
%6 = tail call i32 @bind_address(i32 %5, i32 1234)
%7 = bitcast %struct.epoll_event* %3 to i8*
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1, i32 0
store i32 %5, i32* %8
%9 = load i32, i32* @EPOLLIN
%10 = load i32, i32* @EPOLLET
%11 = or i32 %10, %9
%12 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* @EPOLL_CTL_ADD
%14 = call i32 @epoll_ctl(i32 %4, i32 %13, i32 %5, %struct.epoll_event* %3)
%15 = call i32 @listen_socket(i32 %5)
%16 = call i32 @loop(i32 %4)
ret i32 0
}