#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 ValidateFile(char const *, int);
int atoi(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int index, initial_index = 1, repeat_count = 1;
  if (argc == 1) {
    printf("%s: no input files\n", argv[0]);
  }
  if (!strcmp(argv[1], "--repeat"))
    repeat_count = atoi(argv[2]), initial_index += 2;
  for (index = initial_index; index < argc; ++index) {
    const char *filename = argv[index];
    int rc = ValidateFile(filename, repeat_count);
    if (rc != 0) {
      printf("file '%s' can not be fully validated\n", filename);
      return 1;
    }
  }
  return 0;
}


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,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1221 <main+0xe1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <ValidateFile@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     120e <main+0xce>
mov    -0x28(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xe8>
jmp    1213 <main+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <main+0x7d>
movl   $0x0,-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
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
cmp    $0x1,%edi
jne    1166 <main+0x26>
mov    (%r12),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%r12),%rdi
lea    0xea2(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ecx
mov    $0x1,%r13d
test   %eax,%eax
jne    1198 <main+0x58>
mov    0x10(%r12),%rdi
call   1060 <atoi@plt>
mov    %eax,%r13d
mov    $0x3,%ecx
xor    %r15d,%r15d
cmp    %r14d,%ecx
jge    11e3 <main+0xa3>
mov    %ecx,%ebp
mov    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbp,8),%rbx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1050 <ValidateFile@plt>
test   %eax,%eax
jne    11ce <main+0x8e>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11b0 <main+0x70>
jmp    11e3 <main+0xa3>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"%s: no input files\0A\00"
@.str.1 = [9 x i8] c"--repeat\00"
@.str.2 = [38 x i8] c"file '%s' can not be fully validated\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 i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 1, i32* %8
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 2
store i32 %30, i32* %7
br label %31
31: ; preds = %24, %18
%32 = load i32, i32* %7
store i32 %32, i32* %6
br label %33
33: ; preds = %52, %31
%34 = load i32, i32* %6
%35 = load i32, i32* %4
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load i8**, i8*** %5
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
store i8* %42, i8** %9
%43 = load i8*, i8** %9
%44 = load i32, i32* %8
%45 = call i32 @ValidateFile(i8* %43, i32 %44)
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %37
%49 = load i8*, i8** %9
%50 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %49)
store i32 1, i32* %3
br label %56
51: ; preds = %37
br label %52
52: ; preds = %51
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %33
55: ; preds = %33
store i32 0, i32* %3
br label %56
56: ; preds = %55, %48
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [20 x i8] c"%s: no input files\0A\00"
@.str.1 = [9 x i8] c"--repeat\00"
@.str.2 = [38 x i8] c"file '%s' can not be fully validated\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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
br label %16
16: ; preds = %12, %7
%17 = phi i32 [ 1, %7 ], [ 3, %12 ]
%18 = phi i32 [ 1, %7 ], [ %15, %12 ]
%19 = icmp slt i32 %17, %0
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = zext i32 %17 to i64
%22 = zext i32 %0 to i64
br label %25
23: ; preds = %25
%24 = icmp eq i64 %31, %22
br i1 %24, label %34, label %25
25: ; preds = %20, %23
%26 = phi i64 [ %21, %20 ], [ %31, %23 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 @ValidateFile(i8* %28, i32 %18)
%30 = icmp eq i32 %29, 0
%31 = add nuw nsw i64 %26, 1
br i1 %30, label %23, label %32
32: ; preds = %25
%33 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %34
34: ; preds = %23, %16, %32
%35 = phi i32 [ 1, %32 ], [ 0, %16 ], [ 0, %23 ]
ret i32 %35
}