#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 option {
  char *member_0;
  int member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errx(int, char *);
scalar_t__ fsync(int);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int help(char *, char *);
int /*<<< orphan*/ no_argument;
int open(char *, int /*<<< orphan*/);
int optind;
int version(char *);
int /*<<< orphan*/ warn(char *, char *);
int main(int argc, char *argv[]) {
  struct option longopts[] = {{"help", no_argument, 0, 0},
                              {"version", no_argument, 0, 1},
                              {0, 0, 0, 0}};
  int c;
  while ((c = getopt_long(argc, argv, "", longopts, NULL)) != -1) {
    switch (c) {
    case 0:
      return help(argv[0], "[OPTIONS] FILE...\n"
                           "      --help               display this help\n"
                           "      --version            display version info");
    case 1:
      return version(argv[0]);
    }
  }
  if (optind >= argc)
    errx(1, "missing file operand");
  int status = 0;
  for (int i = optind; i < argc; i++) {
    int fd = open(argv[i], O_RDONLY);
    if (fd < 0) {
      warn("cannot open '%s'", argv[i]);
      status = 1;
      continue;
    }
    if (fsync(fd) < 0) {
      warn("cannot sync '%s'", argv[i]);
      status = 1;
    }
    close(fd);
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe4c(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x50(%rbp)
add    $0x18,%rdi
lea    0xe28(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x38(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rcx
lea    0xe95(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x64(%rbp)
cmp    $0xffffffff,%eax
je     128b <main+0xfb>
mov    -0x64(%rbp),%eax
mov    %eax,-0x74(%rbp)
test   %eax,%eax
je     1257 <main+0xc7>
jmp    1246 <main+0xb6>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
je     1272 <main+0xe2>
jmp    1286 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xda8(%rip),%rsi
call   10b0 <help@plt>
mov    %eax,-0x4(%rbp)
jmp    1365 <main+0x1d5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <version@plt>
mov    %eax,-0x4(%rbp)
jmp    1365 <main+0x1d5>
jmp    120b <main+0x7b>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12ae <main+0x11e>
mov    $0x1,%edi
lea    0xdd3(%rip),%rsi
call   1050 <errx@plt>
movl   $0x0,-0x68(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    135f <main+0x1cf>
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d08(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1318 <main+0x188>
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd8a(%rip),%rdi
call   1030 <warn@plt>
movl   $0x1,-0x68(%rbp)
jmp    1351 <main+0x1c1>
mov    -0x70(%rbp),%edi
call   1090 <fsync@plt>
cmp    $0x0,%rax
jge    1349 <main+0x1b9>
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd65(%rip),%rdi
call   1030 <warn@plt>
movl   $0x1,-0x68(%rbp)
mov    -0x70(%rbp),%edi
call   1070 <close@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12c1 <main+0x131>
mov    -0x68(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xe65(%rip),%rax
mov    %rax,(%rsp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
movq   $0x0,0xc(%rsp)
lea    0xe49(%rip),%rcx
mov    %rcx,0x18(%rsp)
mov    %eax,0x20(%rsp)
movabs $0x100000000,%rax
mov    %rax,0x24(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
lea    0xec6(%rip),%r15
mov    %rsp,%rbp
nop
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     122a <main+0xaa>
cmp    $0x1,%eax
je     12e9 <main+0x169>
test   %eax,%eax
jne    11f0 <main+0x70>
mov    (%rbx),%rdi
lea    0xded(%rip),%rsi
call   10a0 <help@plt>
jmp    12f1 <main+0x171>
mov    0x2daf(%rip),%rbp
mov    0x0(%rbp),%eax
cmp    %r14d,%eax
jl     124d <main+0xcd>
lea    0xe3c(%rip),%rsi
mov    $0x1,%edi
call   1050 <errx@plt>
mov    0x0(%rbp),%eax
xor    %r13d,%r13d
cmp    %r14d,%eax
jge    12f4 <main+0x174>
movslq %eax,%rcx
lea    (%rbx,%rcx,8),%rbp
sub    %eax,%r14d
xor    %r15d,%r15d
mov    0x2d7b(%rip),%r12
xor    %r13d,%r13d
jmp    1290 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1060 <close@plt>
add    $0x1,%r15
cmp    %r15d,%r14d
je     12f4 <main+0x174>
mov    0x0(%rbp,%r15,8),%rdi
mov    (%r12),%esi
call   1090 <open@plt>
test   %eax,%eax
js     12d0 <main+0x150>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <fsync@plt>
test   %rax,%rax
jns    1280 <main+0x100>
mov    0x0(%rbp,%r15,8),%rsi
lea    0xde6(%rip),%rdi
call   1030 <warn@plt>
mov    $0x1,%r13d
jmp    1280 <main+0x100>
nopl   0x0(%rax)
mov    0x0(%rbp,%r15,8),%rsi
lea    0xdb5(%rip),%rdi
call   1030 <warn@plt>
mov    $0x1,%r13d
jmp    1287 <main+0x107>
mov    (%rbx),%rdi
call   1070 <version@plt>
mov    %eax,%r13d
mov    %r13d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [111 x i8] c"[OPTIONS] FILE...\0A --help display this help\0A --version display version info\00"
@optind = global i32 0
@.str.4 = [21 x i8] c"missing file operand\00"
@O_RDONLY = global i32 0
@.str.5 = [17 x i8] c"cannot open '%s'\00"
@.str.6 = [17 x i8] c"cannot sync '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x %struct.option]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %6, i64 0, i64 0
%12 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 1
%14 = load i32, i32* @no_argument
store i32 %14, i32* %13
%15 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 2
store i32 0, i32* %15
%16 = getelementptr inbounds %struct.option, %struct.option* %11, i32 0, i32 3
store i32 0, i32* %16
%17 = getelementptr inbounds %struct.option, %struct.option* %11, i64 1
%18 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 1
%20 = load i32, i32* @no_argument
store i32 %20, i32* %19
%21 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 2
store i32 0, i32* %21
%22 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 3
store i32 1, i32* %22
%23 = getelementptr inbounds %struct.option, %struct.option* %17, i64 1
%24 = bitcast %struct.option* %23 to i8*
br label %25
25: ; preds = %43, %2
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %6, i64 0, i64 0
%29 = call i32 @getopt_long(i32 %26, i8** %27, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %struct.option* %28, i32* null)
store i32 %29, i32* %7
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %44
31: ; preds = %25
%32 = load i32, i32* %7
switch i32 %32, label %43 [
i32 0, label %33
i32 1, label %38
]
33: ; preds = %31
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @help(i8* %36, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
store i32 %37, i32* %3
br label %92
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @version(i8* %41)
store i32 %42, i32* %3
br label %92
43: ; preds = %31
br label %25
44: ; preds = %25
%45 = load i32, i32* @optind
%46 = load i32, i32* %4
%47 = icmp sge i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
store i32 0, i32* %8
%51 = load i32, i32* @optind
store i32 %51, i32* %9
br label %52
52: ; preds = %87, %50
%53 = load i32, i32* %9
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %90
56: ; preds = %52
%57 = load i8**, i8*** %5
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = load i32, i32* @O_RDONLY
%63 = call i32 @open(i8* %61, i32 %62)
store i32 %63, i32* %10
%64 = load i32, i32* %10
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %56
%67 = load i8**, i8*** %5
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %71)
store i32 1, i32* %8
br label %87
73: ; preds = %56
%74 = load i32, i32* %10
%75 = call i64 @fsync(i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %84
77: ; preds = %73
%78 = load i8**, i8*** %5
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %82)
store i32 1, i32* %8
br label %84
84: ; preds = %77, %73
%85 = load i32, i32* %10
%86 = call i32 @close(i32 %85)
br label %87
87: ; preds = %84, %66
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
store i32 %89, i32* %9
br label %52
90: ; preds = %52
%91 = load i32, i32* %8
store i32 %91, i32* %3
br label %92
92: ; preds = %90, %38, %33
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [111 x i8] c"[OPTIONS] FILE...\0A --help display this help\0A --version display version info\00"
@optind = global i32 0
@.str.4 = [21 x i8] c"missing file operand\00"
@O_RDONLY = global i32 0
@.str.5 = [17 x i8] c"cannot open '%s'\00"
@.str.6 = [17 x i8] c"cannot sync '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [3 x %struct.option]
%4 = bitcast [3 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 1
%8 = load i32, i32* @no_argument
store i32 %8, i32* %7
%9 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 2
store i32 0, i32* %9
%10 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 3
store i32 0, i32* %10
%11 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 1
store i32 %8, i32* %12
%13 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 2
store i32 0, i32* %13
%14 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 3
store i32 1, i32* %14
%15 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 2
%16 = bitcast %struct.option* %15 to i8*
br label %17
17: ; preds = %17, %2
%18 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %struct.option* %5, i32* null)
switch i32 %18, label %17 [
i32 -1, label %25
i32 0, label %19
i32 1, label %22
]
19: ; preds = %17
%20 = load i8*, i8** %1
%21 = call i32 @help(i8* %20, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
br label %61
22: ; preds = %17
%23 = load i8*, i8** %1
%24 = call i32 @version(i8* %23)
br label %61
25: ; preds = %17
%26 = load i32, i32* @optind
%27 = icmp slt i32 %26, %0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32, i32* @optind
br label %31
31: ; preds = %28, %25
%32 = phi i32 [ %30, %28 ], [ %26, %25 ]
%33 = icmp slt i32 %32, %0
br i1 %33, label %34, label %61
34: ; preds = %31
%35 = sext i32 %32 to i64
br label %36
36: ; preds = %34, %56
%37 = phi i64 [ %35, %34 ], [ %58, %56 ]
%38 = phi i32 [ 0, %34 ], [ %57, %56 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %37
%40 = load i8*, i8** %39
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* %40, i32 %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %36
%45 = load i8*, i8** %39
%46 = call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %45)
br label %56
47: ; preds = %36
%48 = call i64 @fsync(i32 %42)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i8*, i8** %39
%52 = call i32 @warn(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %47
%54 = phi i32 [ 1, %50 ], [ %38, %47 ]
%55 = call i32 @close(i32 %42)
br label %56
56: ; preds = %53, %44
%57 = phi i32 [ 1, %44 ], [ %54, %53 ]
%58 = add nsw i64 %37, 1
%59 = trunc i64 %58 to i32
%60 = icmp eq i32 %59, %0
br i1 %60, label %61, label %36
61: ; preds = %56, %31, %22, %19
%62 = phi i32 [ %24, %22 ], [ %21, %19 ], [ 0, %31 ], [ %57, %56 ]
ret i32 %62
}