#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 stat {
  scalar_t__ st_size;
};

/* Variables and functions */
int asm_stat(char *, struct stat *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, long long, long long);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i = 1, ret = 0, one_flag = 0;
  struct stat s;
  struct stat a;
  if (argc <= 1) {
    fprintf(stderr, "usage: %s [-1] [FILE...]\n", argv[0]);
    fprintf(stderr, "\t-1\t:\tStop as soon as one file fails\n");
    return 0;
  }
  if (strcmp(argv[1], "-1") == 0) {
    i = 2;
    one_flag = 1;
  }
  for (; i < argc; i++) {
    if (stat(argv[i], &s) == -1) {
      fprintf(stderr, "%s   ", argv[i]);
      perror("stat: ");
      continue;
    }
    if (asm_stat(argv[i], &a) == -1) {
      fprintf(stderr, "%s   ", argv[i]);
      perror("asm_stat: ");
      continue;
    }
    if (a.st_size != s.st_size) {
      printf("stat(%s) disagrees! stat == %lld != %lld == asm_stat\n", argv[i],
             (long long)s.st_size, (long long)a.st_size);
      if (one_flag)
        return 1;
      else
        ret = 1;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11d6 <main+0x76>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1320 <main+0x1c0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1202 <main+0xa2>
movl   $0x2,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1207 <main+0xa7>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131a <main+0x1ba>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    1265 <main+0x105>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    0xdf2(%rip),%rdi
call   1080 <perror@plt>
jmp    130c <main+0x1ac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <asm_stat@plt>
cmp    $0xffffffff,%eax
jne    12b7 <main+0x157>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    0xd9c(%rip),%rdi
call   1080 <perror@plt>
jmp    130c <main+0x1ac>
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1307 <main+0x1a7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd74(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     12fb <main+0x19b>
movl   $0x1,-0x4(%rbp)
jmp    1320 <main+0x1c0>
movl   $0x1,-0x18(%rbp)
jmp    1307 <main+0x1a7>
jmp    130c <main+0x1ac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1207 <main+0xa7>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11a9 <main+0x49>
mov    0x2e63(%rip),%r14
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xe76(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xe7d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1276 <main+0x116>
mov    %edi,%r15d
mov    0x8(%rbx),%rdi
lea    0xe89(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%r14
cmp    $0x1,%rax
mov    $0x1,%eax
adc    $0x0,%eax
xor    %ebp,%ebp
cmp    %r15d,%eax
jae    1276 <main+0x116>
mov    %eax,%r13d
mov    %r15d,%r15d
xor    %ebp,%ebp
jmp    1219 <main+0xb9>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r13,8),%rdx
lea    0xe4f(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r12,%rdi
call   1080 <perror@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
cmp    %r13,%r15
je     1276 <main+0x116>
mov    (%rbx,%r13,8),%rdi
lea    0x10(%rsp),%rsi
call   1070 <stat@plt>
lea    0xe1f(%rip),%r12
cmp    $0xffffffff,%eax
je     11e0 <main+0x80>
mov    (%rbx,%r13,8),%rdi
lea    0x8(%rsp),%rsi
call   1040 <asm_stat@plt>
lea    0xe01(%rip),%r12
cmp    $0xffffffff,%eax
je     11e0 <main+0x80>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rdx
cmp    %rdx,%rcx
je     1210 <main+0xb0>
mov    (%rbx,%r13,8),%rsi
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%ebp
test   %r14,%r14
jne    1210 <main+0xb0>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [26 x i8] c"usage: %s [-1] [FILE...]\0A\00"
@.str.1 = [38 x i8] c"\09-1\09:\09Stop as soon as one file fails\0A\00"
@.str.2 = [3 x i8] c"-1\00"
@.str.3 = [6 x i8] c"%s \00"
@.str.4 = [7 x i8] c"stat: \00"
@.str.5 = [11 x i8] c"asm_stat: \00"
@.str.6 = [54 x i8] c"stat(%s) disagrees! stat == %lld != %lld == asm_stat\0A\00"
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
%9 = alloca %struct.stat
%10 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %95
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 2, i32* %6
store i32 1, i32* %8
br label %28
28: ; preds = %27, %21
br label %29
29: ; preds = %90, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %93
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @stat(i8* %38, %struct.stat* %9)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %50
41: ; preds = %33
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %90
50: ; preds = %33
%51 = load i8**, i8*** %5
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @asm_stat(i8* %55, %struct.stat* %10)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %67
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = load i8**, i8*** %5
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %90
67: ; preds = %50
%68 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%69 = load i64, i64* %68
%70 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%71 = load i64, i64* %70
%72 = icmp ne i64 %69, %71
br i1 %72, label %73, label %89
73: ; preds = %67
%74 = load i8**, i8*** %5
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%80 = load i64, i64* %79
%81 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%82 = load i64, i64* %81
%83 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %78, i64 %80, i64 %82)
%84 = load i32, i32* %8
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %73
store i32 1, i32* %3
br label %95
87: ; preds = %73
store i32 1, i32* %7
br label %88
88: ; preds = %87
br label %89
89: ; preds = %88, %67
br label %90
90: ; preds = %89, %58, %41
%91 = load i32, i32* %6
%92 = add nsw i32 %91, 1
store i32 %92, i32* %6
br label %29
93: ; preds = %29
%94 = load i32, i32* %7
store i32 %94, i32* %3
br label %95
95: ; preds = %93, %86, %13
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [26 x i8] c"usage: %s [-1] [FILE...]\0A\00"
@.str.1 = [38 x i8] c"\09-1\09:\09Stop as soon as one file fails\0A\00"
@.str.2 = [3 x i8] c"-1\00"
@.str.3 = [6 x i8] c"%s \00"
@.str.4 = [7 x i8] c"stat: \00"
@.str.5 = [11 x i8] c"asm_stat: \00"
@.str.6 = [54 x i8] c"stat(%s) disagrees! stat == %lld != %lld == asm_stat\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %54
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 2, i32 1
%20 = icmp ult i32 %19, %0
br i1 %20, label %21, label %54
21: ; preds = %14
%22 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%24 = zext i32 %19 to i64
%25 = zext i32 %0 to i64
br label %26
26: ; preds = %21, %50
%27 = phi i64 [ %24, %21 ], [ %52, %50 ]
%28 = phi i32 [ 0, %21 ], [ %51, %50 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 %27
%30 = load i8*, i8** %29
%31 = call i32 @stat(i8* %30, %struct.stat* %3)
%32 = icmp eq i32 %31, -1
br i1 %32, label %44, label %33
33: ; preds = %26
%34 = load i8*, i8** %29
%35 = call i32 @asm_stat(i8* %34, %struct.stat* %4)
%36 = icmp eq i32 %35, -1
br i1 %36, label %44, label %37
37: ; preds = %33
%38 = load i64, i64* %22
%39 = load i64, i64* %23
%40 = icmp eq i64 %38, %39
br i1 %40, label %50, label %41
41: ; preds = %37
%42 = load i8*, i8** %29
%43 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i8* %42, i64 %39, i64 %38)
br i1 %18, label %54, label %50
44: ; preds = %33, %26
%45 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %26 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), %33 ]
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %29
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = call i32 @perror(i8* %45)
br label %50
50: ; preds = %44, %41, %37
%51 = phi i32 [ %28, %37 ], [ 1, %41 ], [ %28, %44 ]
%52 = add nuw nsw i64 %27, 1
%53 = icmp eq i64 %52, %25
br i1 %53, label %54, label %26
54: ; preds = %41, %50, %14, %8
%55 = phi i32 [ 0, %8 ], [ 0, %14 ], [ 1, %41 ], [ %51, %50 ]
ret i32 %55
}