#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 */

/* Variables and functions */
int /*<<< orphan*/ EPOLLIN;
int STDIN_FILENO;
int epoll_create(int);
int /*<<< orphan*/ fatal(char *);
int /*<<< orphan*/ register_epoll(int, int, int /*<<< orphan*/);
int init_epoll(int cmdfd) {
  int epfd = epoll_create(2);
  if (epfd == -1) {
    fatal("epoll_create failed");
  }
  register_epoll(epfd, STDIN_FILENO, EPOLLIN);
  register_epoll(epfd, cmdfd, EPOLLIN);
  return epfd;
}


x86 assembly (clang, -O0):
<init_epoll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x2,%edi
call   1030 <epoll_create@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    115e <init_epoll+0x2e>
lea    0xea7(%rip),%rdi
call   1050 <fatal@plt>
mov    -0x8(%rbp),%edi
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
call   1040 <register_epoll@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
call   1040 <register_epoll@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_epoll>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x2,%edi
call   1030 <epoll_create@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1154 <init_epoll+0x24>
lea    0xeb1(%rip),%rdi
call   1050 <fatal@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    0x2e84(%rip),%rbx
mov    (%rbx),%edx
mov    %ebp,%edi
call   1040 <register_epoll@plt>
mov    (%rbx),%edx
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <register_epoll@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"epoll_create failed\00"
@STDIN_FILENO = global i32 0
@EPOLLIN = global i32 0
define i32 @init_epoll(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @epoll_create(i32 2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @fatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i32, i32* %3
%11 = load i32, i32* @STDIN_FILENO
%12 = load i32, i32* @EPOLLIN
%13 = call i32 @register_epoll(i32 %10, i32 %11, i32 %12)
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = load i32, i32* @EPOLLIN
%17 = call i32 @register_epoll(i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@.str = [20 x i8] c"epoll_create failed\00"
@STDIN_FILENO = global i32 0
@EPOLLIN = global i32 0
define i32 @init_epoll(i32 %0) {
%2 = tail call i32 @epoll_create(i32 2)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fatal(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = load i32, i32* @STDIN_FILENO
%8 = load i32, i32* @EPOLLIN
%9 = tail call i32 @register_epoll(i32 %2, i32 %7, i32 %8)
%10 = load i32, i32* @EPOLLIN
%11 = tail call i32 @register_epoll(i32 %2, i32 %0, i32 %10)
ret i32 %2
}