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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ runtime_block(int);
int epoll_wait(int epfd __attribute__((unused)),
               struct epoll_event *events __attribute__((unused)),
               int maxevents __attribute__((unused)), int timeout) {
  switch (timeout) {
  case -1:
    printf("epoll_wait with endless wait. aborting.\n");
    abort();
  case 0:
    return 0;
  default:
    runtime_block(timeout);
    return 0;
  }
}


x86 assembly (clang, -O0):
<epoll_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0xffffffff,%eax
je     1169 <epoll_wait+0x39>
jmp    1159 <epoll_wait+0x29>
mov    -0x1c(%rbp),%eax
test   %eax,%eax
je     117c <epoll_wait+0x4c>
jmp    1188 <epoll_wait+0x58>
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,-0x4(%rbp)
jmp    1197 <epoll_wait+0x67>
mov    -0x18(%rbp),%edi
call   1040 <runtime_block@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epoll_wait>:
push   %rax
test   %ecx,%ecx
je     1141 <epoll_wait+0x11>
cmp    $0xffffffff,%ecx
je     1145 <epoll_wait+0x15>
mov    %ecx,%edi
call   1050 <runtime_block@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.epoll_event = type { i32 }
@.str = [41 x i8] c"epoll_wait with endless wait. aborting.\0A\00"
define i32 @epoll_wait(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.epoll_event*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store %struct.epoll_event* %1, %struct.epoll_event** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
switch i32 %10, label %15 [
i32 -1, label %11
i32 0, label %14
]
11: ; preds = %4
%12 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %4
store i32 0, i32* %5
br label %18
15: ; preds = %4
%16 = load i32, i32* %9
%17 = call i32 @runtime_block(i32 %16)
store i32 0, i32* %5
br label %18
18: ; preds = %15, %14
%19 = load i32, i32* %5
ret i32 %19
}

LLVM IR (-O2):
%struct.epoll_event = type { i32 }
@str = [40 x i8] c"epoll_wait with endless wait. aborting.\00"
define i32 @epoll_wait(i32 %0, %struct.epoll_event* nocapture readnone %1, i32 %2, i32 %3) {
switch i32 %3, label %8 [
i32 -1, label %5
i32 0, label %10
]
5: ; preds = %4
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %4
%9 = tail call i32 @runtime_block(i32 %3)
br label %10
10: ; preds = %4, %8
ret i32 0
}