#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 EX_NOINPUT;
int EX_OK;
int EX_OSERR;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int fsync(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ warn(char *, char *);
int main(int argc, char *argv[]) {
  int fd;
  int i;
  int rval;
  if (argc < 2) {
    usage();
  }
  rval = EX_OK;
  for (i = 1; i < argc; ++i) {
    if ((fd = open(argv[i], O_RDONLY)) == -1) {
      warn("open %s", argv[i]);
      if (rval == EX_OK)
        rval = EX_NOINPUT;
      continue;
    }
    if (fsync(fd) == -1) {
      warn("fsync %s", argv[i]);
      if (rval == EX_OK)
        rval = EX_OSERR;
    }
    close(fd);
  }
  exit(rval);
}


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   $0x2,-0x8(%rbp)
jge    1187 <main+0x27>
mov    $0x0,%al
call   1050 <usage@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1269 <main+0x109>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1207 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe21(%rip),%rdi
call   1030 <warn@plt>
mov    -0x1c(%rbp),%eax
mov    0x2de2(%rip),%rcx
cmp    (%rcx),%eax
jne    1202 <main+0xa2>
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    125b <main+0xfb>
mov    -0x14(%rbp),%edi
call   1060 <fsync@plt>
cmp    $0xffffffff,%eax
jne    1253 <main+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xddd(%rip),%rdi
call   1030 <warn@plt>
mov    -0x1c(%rbp),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
jne    124e <main+0xee>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1253 <main+0xf3>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119a <main+0x3a>
mov    -0x1c(%rbp),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1185 <main+0x25>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rsi,%rbx
mov    0x2e41(%rip),%rax
mov    (%rax),%r12d
mov    %edi,%r15d
mov    $0x1,%r14d
mov    0x2e3e(%rip),%r13
jmp    11c0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1040 <close@plt>
add    $0x1,%r14
cmp    %r14,%r15
je     123b <main+0xdb>
mov    (%rbx,%r14,8),%rdi
mov    0x0(%r13),%esi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1210 <main+0xb0>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <fsync@plt>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x50>
mov    (%rbx,%r14,8),%rsi
lea    0xe1d(%rip),%rdi
call   1030 <warn@plt>
mov    0x2dd9(%rip),%rax
cmp    (%rax),%r12d
jne    11b0 <main+0x50>
mov    0x2dc5(%rip),%rax
mov    (%rax),%r12d
jmp    11b0 <main+0x50>
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r14,8),%rsi
lea    0xde5(%rip),%rdi
call   1030 <warn@plt>
mov    0x2da9(%rip),%rax
cmp    (%rax),%r12d
jne    11b7 <main+0x57>
mov    0x2db5(%rip),%rax
mov    (%rax),%r12d
jmp    11b7 <main+0x57>
mov    %r12d,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EX_OK = global i32 0
@O_RDONLY = global i32 0
@.str = [8 x i8] c"open %s\00"
@EX_NOINPUT = global i32 0
@.str.1 = [9 x i8] c"fsync %s\00"
@EX_OSERR = global i32 0
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
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @usage()
br label %13
13: ; preds = %11, %2
%14 = load i32, i32* @EX_OK
store i32 %14, i32* %8
store i32 1, i32* %7
br label %15
15: ; preds = %61, %13
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %64
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = call i32 @open(i8* %24, i32 %25)
store i32 %26, i32* %6
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %41
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @warn(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %8
%36 = load i32, i32* @EX_OK
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %28
%39 = load i32, i32* @EX_NOINPUT
store i32 %39, i32* %8
br label %40
40: ; preds = %38, %28
br label %61
41: ; preds = %19
%42 = load i32, i32* %6
%43 = call i32 @fsync(i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %58
45: ; preds = %41
%46 = load i8**, i8*** %5
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @warn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = load i32, i32* %8
%53 = load i32, i32* @EX_OK
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %45
%56 = load i32, i32* @EX_OSERR
store i32 %56, i32* %8
br label %57
57: ; preds = %55, %45
br label %58
58: ; preds = %57, %41
%59 = load i32, i32* %6
%60 = call i32 @close(i32 %59)
br label %61
61: ; preds = %58, %40
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %15
64: ; preds = %15
%65 = load i32, i32* %8
%66 = call i32 @exit(i32 %65)
unreachable
}

LLVM IR (-O2):
@EX_OK = global i32 0
@O_RDONLY = global i32 0
@.str = [8 x i8] c"open %s\00"
@EX_NOINPUT = global i32 0
@.str.1 = [9 x i8] c"fsync %s\00"
@EX_OSERR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = load i32, i32* @EX_OK
br label %42
7: ; preds = %2
%8 = load i32, i32* @EX_OK
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %7, %38
%11 = phi i64 [ 1, %7 ], [ %40, %38 ]
%12 = phi i32 [ %8, %7 ], [ %39, %38 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %11
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 @open(i8* %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = load i8*, i8** %13
%20 = tail call i32 @warn(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EX_OK
%22 = icmp eq i32 %12, %21
%23 = load i32, i32* @EX_NOINPUT
%24 = select i1 %22, i32 %23, i32 %12
br label %38
25: ; preds = %10
%26 = tail call i32 @fsync(i32 %16)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i8*, i8** %13
%30 = tail call i32 @warn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EX_OK
%32 = icmp eq i32 %12, %31
%33 = load i32, i32* @EX_OSERR
%34 = select i1 %32, i32 %33, i32 %12
br label %35
35: ; preds = %28, %25
%36 = phi i32 [ %12, %25 ], [ %34, %28 ]
%37 = tail call i32 @close(i32 %16)
br label %38
38: ; preds = %18, %35
%39 = phi i32 [ %36, %35 ], [ %24, %18 ]
%40 = add nuw nsw i64 %11, 1
%41 = icmp eq i64 %40, %9
br i1 %41, label %42, label %10
42: ; preds = %38, %4
%43 = phi i32 [ %6, %4 ], [ %39, %38 ]
%44 = tail call i32 @exit(i32 %43)
unreachable
}