#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 /*<<< orphan*/ _IONBF;
scalar_t__ adxtract(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int a, succeeded = 0, total = argc - 1;
  printf("adXtract 0.2\nextract ADX files from any archive, by recognizing "
         "signatures\n\n");
  if (total <= 0) {
    printf("usage: %s archive.zzz [ ... archive.zzz ]\n", argv[0]);
    return 1;
  }
  setvbuf(stdout, 0, _IONBF, 0);
  for (a = 1; a < argc; ++a)
    succeeded += adxtract(argv[a]);
  if (succeeded == total)
    return 0;
  else if (!succeeded)
    return 1;
  else
    return 2;
}


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)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jg     118f <main+0x5f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121e <main+0xee>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
mov    %ecx,%esi
call   1050 <setvbuf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0xb9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <adxtract@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <main+0x81>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1201 <main+0xd1>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xee>
cmpl   $0x0,-0x18(%rbp)
jne    1217 <main+0xe7>
movl   $0x1,-0x4(%rbp)
jmp    121e <main+0xee>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %edi,%r14d
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%r14d
jg     1179 <main+0x39>
mov    (%r12),%rsi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    11d6 <main+0x96>
lea    -0x1(%r14),%r15d
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
xor    %esi,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    %r14d,%r14d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rdi
call   1040 <adxtract@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11b0 <main+0x70>
xor    %eax,%eax
cmp    %r15d,%ebp
je     11d6 <main+0x96>
cmp    $0x1,%ebp
mov    $0x2,%eax
sbb    $0x0,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [77 x i8] c"adXtract 0.2\0Aextract ADX files from any archive, by recognizing signatures\0A\0A\00"
@.str.1 = [43 x i8] c"usage: %s archive.zzz [ ... archive.zzz ]\0A\00"
@stdout = global i32 0
@_IONBF = 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
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %8
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %51
19: ; preds = %2
%20 = load i32, i32* @stdout
%21 = load i32, i32* @_IONBF
%22 = call i32 @setvbuf(i32 %20, i32 0, i32 %21, i32 0)
store i32 1, i32* %6
br label %23
23: ; preds = %38, %19
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i64 @adxtract(i8* %32)
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = add nsw i64 %35, %33
%37 = trunc i64 %36 to i32
store i32 %37, i32* %7
br label %38
38: ; preds = %27
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %23
41: ; preds = %23
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 0, i32* %3
br label %51
46: ; preds = %41
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
store i32 1, i32* %3
br label %51
50: ; preds = %46
store i32 2, i32* %3
br label %51
51: ; preds = %50, %49, %45, %14
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"usage: %s archive.zzz [ ... archive.zzz ]\0A\00"
@stdout = global i32 0
@_IONBF = global i32 0
@str = [76 x i8] c"adXtract 0.2\0Aextract ADX files from any archive, by recognizing signatures\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str, i64 0, i64 0))
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %29
9: ; preds = %2
%10 = load i32, i32* @stdout
%11 = load i32, i32* @_IONBF
%12 = tail call i32 @setvbuf(i32 %10, i32 0, i32 %11, i32 0)
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ 1, %9 ], [ %22, %14 ]
%16 = phi i32 [ 0, %9 ], [ %21, %14 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %15
%18 = load i8*, i8** %17
%19 = tail call i64 @adxtract(i8* %18)
%20 = trunc i64 %19 to i32
%21 = add i32 %16, %20
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %13
br i1 %23, label %24, label %14
24: ; preds = %14
%25 = icmp eq i32 %21, %3
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = icmp eq i32 %21, 0
%28 = select i1 %27, i32 1, i32 2
br label %29
29: ; preds = %26, %24, %6
%30 = phi i32 [ 1, %6 ], [ 0, %24 ], [ %28, %26 ]
ret i32 %30
}