#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*/ printf(char *, char *);
int /*<<< orphan*/ umask(int);
int /*<<< orphan*/ wake(char *);
int /*<<< orphan*/ yield();
int main(int argc, char **argv) {
  int i;
  if (argc == 1) {
    printf("Usage: %s [disk] [disk]...\n", argv[0]);
    return 1;
  }
  umask(0600);
  while (1) {
    for (i = 1; i < argc; i++) {
      wake(argv[i]);
    }
    yield();
  }
  return 0;
}


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)
cmpl   $0x1,-0x8(%rbp)
jne    117e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x180,%edi
call   1050 <umask@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <main+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <wake@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x4f>
mov    $0x0,%al
call   1030 <yield@plt>
jmp    1188 <main+0x48>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x1,%edi
jne    116e <main+0x2e>
mov    (%r15),%rsi
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r14d
mov    $0x180,%edi
call   1050 <umask@plt>
mov    %r14d,%ebp
jmp    1187 <main+0x47>
xor    %eax,%eax
call   1030 <yield@plt>
cmp    $0x2,%r14d
jl     1180 <main+0x40>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1060 <wake@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x60>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [28 x i8] c"Usage: %s [disk] [disk]...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %12)
ret i32 1
14: ; preds = %2
%15 = call i32 @umask(i32 384)
br label %16
16: ; preds = %14, %31
store i32 1, i32* %6
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @wake(i8* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %17
31: ; preds = %17
%32 = call i32 (...) @yield()
br label %16
}

LLVM IR (-O2):
@.str = [28 x i8] c"Usage: %s [disk] [disk]...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %5)
ret i32 1
7: ; preds = %2
%8 = tail call i32 @umask(i32 384)
%9 = icmp sgt i32 %0, 1
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %19, %7
br i1 %9, label %12, label %19
12: ; preds = %11, %12
%13 = phi i64 [ %17, %12 ], [ 1, %11 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @wake(i8* %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %12
19: ; preds = %12, %11
%20 = tail call i32 (...) @yield()
br label %11
}