#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 */
scalar_t__ close(int);
int epoll_create1(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int test_timeout(int);
int main(int argc, char **argv) {
  int failed = 0;
  int fd, i;
  fd = epoll_create1(0x1);
  if (fd == -1)
    error(1, errno, "epoll_create");
  for (i = 0; i < 5; i++)
    failed |= test_timeout(fd);
  if (close(fd))
    error(1, errno, "close");
  return failed;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x1,%edi
call   1060 <epoll_create1@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    118e <main+0x4e>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe77(%rip),%rdx
call   1050 <error@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11bb <main+0x7b>
mov    -0x18(%rbp),%edi
call   1040 <test_timeout@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1195 <main+0x55>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
cmp    $0x0,%rax
je     11e7 <main+0xa7>
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe2b(%rip),%rdx
call   1050 <error@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1060 <epoll_create1@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1176 <main+0x36>
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
lea    0xe94(%rip),%rdx
mov    $0x1,%edi
call   1050 <error@plt>
mov    %ebx,%edi
call   1040 <test_timeout@plt>
mov    %eax,%r14d
mov    %ebx,%edi
call   1040 <test_timeout@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1040 <test_timeout@plt>
mov    %eax,%r12d
mov    %ebx,%edi
call   1040 <test_timeout@plt>
mov    %eax,%r13d
mov    %ebx,%edi
call   1040 <test_timeout@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
test   %rax,%rax
je     11cd <main+0x8d>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xe4a(%rip),%rdx
mov    $0x1,%edi
call   1050 <error@plt>
or     %r14d,%r15d
or     %r15d,%r12d
or     %r12d,%r13d
or     %r13d,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [13 x i8] c"epoll_create\00"
@.str.1 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = call i32 @epoll_create1(i32 1)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = call i32 @error(i32 1, i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %2
store i32 0, i32* %8
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 5
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32, i32* %7
%21 = call i32 @test_timeout(i32 %20)
%22 = load i32, i32* %6
%23 = or i32 %22, %21
store i32 %23, i32* %6
br label %24
24: ; preds = %19
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %16
27: ; preds = %16
%28 = load i32, i32* %7
%29 = call i64 @close(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* @errno
%33 = call i32 @error(i32 1, i32 %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %6
ret i32 %35
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [13 x i8] c"epoll_create\00"
@.str.1 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @epoll_create1(i32 1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @error(i32 1, i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = tail call i32 @test_timeout(i32 %3)
%10 = tail call i32 @test_timeout(i32 %3)
%11 = tail call i32 @test_timeout(i32 %3)
%12 = tail call i32 @test_timeout(i32 %3)
%13 = tail call i32 @test_timeout(i32 %3)
%14 = tail call i64 @close(i32 %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %8
%17 = load i32, i32* @errno
%18 = tail call i32 @error(i32 1, i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %8
%20 = or i32 %10, %9
%21 = or i32 %11, %20
%22 = or i32 %12, %21
%23 = or i32 %13, %22
ret i32 %23
}