#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 DecodeFile(char const *, int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
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]);
    exit(1);
  }
  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 = DecodeFile(filename, repeat_count);
    if (rc != 0) {
      printf("file '%s' can not be fully decoded\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    119b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d1 <main+0x81>
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    123b <main+0xeb>
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 <DecodeFile@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1228 <main+0xd8>
mov    -0x28(%rbp),%rsi
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1242 <main+0xf2>
jmp    122d <main+0xdd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d7 <main+0x87>
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
cmp    $0x1,%edi
je     11f5 <main+0xa5>
mov    %edi,%r14d
mov    0x8(%r12),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ecx
mov    $0x1,%r13d
test   %eax,%eax
jne    119c <main+0x4c>
mov    0x10(%r12),%rdi
call   1060 <atoi@plt>
mov    %eax,%r13d
mov    $0x3,%ecx
xor    %r15d,%r15d
cmp    %r14d,%ecx
jge    11e3 <main+0x93>
mov    %ecx,%ebp
mov    %r14d,%r14d
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rbx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1050 <DecodeFile@plt>
test   %eax,%eax
jne    11ce <main+0x7e>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11b0 <main+0x60>
jmp    11e3 <main+0x93>
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
mov    (%r12),%rsi
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

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