#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*/ F_OK;
int access(char *, int /*<<< orphan*/);
char *basename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc == 1) {
    fprintf(stderr, "Usage: %s <file1> [file2...]\n", basename(argv[0]));
    fprintf(stderr, "When all files exist, return 0.\n");
    return 1;
  }
  while (1) {
    unsigned int i;
    for (i = 1; i < argc; i++) {
      if (!(access(argv[i], F_OK) != -1))
        break;
      if (i == argc - 1)
        return 0;
    }
    sleep(1);
  }
}


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    11af <main+0x6f>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <basename@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xed>
jmp    11b4 <main+0x74>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    121e <main+0xde>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
jne    11ee <main+0xae>
jmp    121e <main+0xde>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    120b <main+0xcb>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xed>
jmp    1210 <main+0xd0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <main+0x7b>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    11b4 <main+0x74>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
cmp    $0x1,%edi
jne    118c <main+0x4c>
mov    0x2e89(%rip),%rbx
mov    (%rbx),%ebp
mov    (%r12),%rdi
call   1040 <basename@plt>
lea    0xe97(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xea0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%eax
jmp    11ef <main+0xaf>
mov    %edi,%r14d
lea    -0x1(%r14),%ebp
add    $0xffffffffffffffff,%rbp
mov    0x2e32(%rip),%r15
jmp    11aa <main+0x6a>
mov    $0x1,%edi
call   1060 <sleep@plt>
test   %r14d,%r14d
je     11a0 <main+0x60>
mov    0x8(%r12),%rdi
mov    (%r15),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     11a0 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %rbx,%rbp
je     11ed <main+0xad>
mov    0x10(%r12,%rbx,8),%rdi
mov    (%r15),%esi
call   1050 <access@plt>
add    $0x1,%rbx
cmp    $0xffffffff,%eax
jne    11d0 <main+0x90>
jmp    11a0 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <file1> [file2...]\0A\00"
@.str.1 = [33 x i8] c"When all files exist, return 0.\0A\00"
@F_OK = global i32 0
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 %18
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i8* @basename(i8* %13)
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %46
18: ; preds = %2
br label %19
19: ; preds = %18, %44
store i32 1, i32* %6
br label %20
20: ; preds = %41, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %44
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* @F_OK
%31 = call i32 @access(i8* %29, i32 %30)
%32 = icmp ne i32 %31, -1
br i1 %32, label %34, label %33
33: ; preds = %24
br label %44
34: ; preds = %24
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 1
%38 = icmp eq i32 %35, %37
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 0, i32* %3
br label %46
40: ; preds = %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add i32 %42, 1
store i32 %43, i32* %6
br label %20
44: ; preds = %33, %20
%45 = call i32 @sleep(i32 1)
br label %19
46: ; preds = %39, %9
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <file1> [file2...]\0A\00"
@.str.1 = [33 x i8] c"When all files exist, return 0.\0A\00"
@F_OK = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = icmp eq i32 %0, 0
%7 = zext i32 %5 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 1
br label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i8* @basename(i8* %11)
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %34
16: ; preds = %4, %32
br i1 %6, label %32, label %17
17: ; preds = %16
%18 = load i8*, i8** %8
%19 = load i32, i32* @F_OK
%20 = tail call i32 @access(i8* %18, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %32, label %28
22: ; preds = %28
%23 = getelementptr inbounds i8*, i8** %1, i64 %31
%24 = load i8*, i8** %23
%25 = load i32, i32* @F_OK
%26 = tail call i32 @access(i8* %24, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %32, label %28
28: ; preds = %17, %22
%29 = phi i64 [ %31, %22 ], [ 1, %17 ]
%30 = icmp eq i64 %29, %7
%31 = add nuw nsw i64 %29, 1
br i1 %30, label %34, label %22
32: ; preds = %22, %17, %16
%33 = tail call i32 @sleep(i32 1)
br label %16
34: ; preds = %28, %9
%35 = phi i32 [ 1, %9 ], [ 0, %28 ]
ret i32 %35
}