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

/* Variables and functions */
int /*<<< orphan*/ SIGIO;
int /*<<< orphan*/ STDIN_FILENO;
int setup_signals();
int setup_timer(struct bar *);
int sys_async(int /*<<< orphan*/, int /*<<< orphan*/);
int sys_cloexec(int /*<<< orphan*/);
int sched_init(struct bar *bar) {
  int flags;
  int err;
  err = setup_signals();
  if (err)
    return err;
  err = setup_timer(bar);
  if (err)
    return err;
  err = sys_cloexec(STDIN_FILENO);
  if (err)
    return err;
  return sys_async(STDIN_FILENO, SIGIO);
}


x86 assembly (clang, -O0):
<sched_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <setup_signals@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     116b <sched_init+0x2b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <sched_init+0x8c>
mov    -0x10(%rbp),%rdi
call   1030 <setup_timer@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     118c <sched_init+0x4c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <sched_init+0x8c>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <sys_cloexec@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11b2 <sched_init+0x72>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <sched_init+0x8c>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
call   1040 <sys_async@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sched_init>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <setup_signals@plt>
test   %eax,%eax
jne    116d <sched_init+0x2d>
mov    %rbx,%rdi
call   1030 <setup_timer@plt>
test   %eax,%eax
jne    116d <sched_init+0x2d>
mov    0x2e76(%rip),%rbx
mov    (%rbx),%edi
call   1060 <sys_cloexec@plt>
test   %eax,%eax
je     116f <sched_init+0x2f>
pop    %rbx
ret
mov    (%rbx),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
pop    %rbx
jmp    1040 <sys_async@plt>

LLVM IR (-O0):
%struct.bar = type { i32 }
@STDIN_FILENO = global i32 0
@SIGIO = global i32 0
define i32 @sched_init(%struct.bar* %0) {
%2 = alloca i32
%3 = alloca %struct.bar*
%4 = alloca i32
%5 = alloca i32
store %struct.bar* %0, %struct.bar** %3
%6 = call i32 (...) @setup_signals()
store i32 %6, i32* %5
%7 = load i32, i32* %5
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32, i32* %5
store i32 %10, i32* %2
br label %29
11: ; preds = %1
%12 = load %struct.bar*, %struct.bar** %3
%13 = call i32 @setup_timer(%struct.bar* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = load i32, i32* %5
store i32 %17, i32* %2
br label %29
18: ; preds = %11
%19 = load i32, i32* @STDIN_FILENO
%20 = call i32 @sys_cloexec(i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i32, i32* %5
store i32 %24, i32* %2
br label %29
25: ; preds = %18
%26 = load i32, i32* @STDIN_FILENO
%27 = load i32, i32* @SIGIO
%28 = call i32 @sys_async(i32 %26, i32 %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %25, %23, %16, %9
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.bar = type { i32 }
@STDIN_FILENO = global i32 0
@SIGIO = global i32 0
define i32 @sched_init(%struct.bar* %0) {
%2 = tail call i32 (...) @setup_signals()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 @setup_timer(%struct.bar* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i32, i32* @STDIN_FILENO
%9 = tail call i32 @sys_cloexec(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* @STDIN_FILENO
%13 = load i32, i32* @SIGIO
%14 = tail call i32 @sys_async(i32 %12, i32 %13)
br label %15
15: ; preds = %7, %4, %1, %11
%16 = phi i32 [ %14, %11 ], [ %2, %1 ], [ %5, %4 ], [ %9, %7 ]
ret i32 %16
}