#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ print_crc32(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int tbz_compute_file_crc32(char *, int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  uint32_t crc;
  int success;
  int ret = 0;
  char *error;
  if (argc <= 1 || strcmp("--help", argv[1]) == 0) {
    usage(argv[0]);
    return 1;
  }
  if (argc == 2) {
    success = tbz_compute_file_crc32(argv[1], &crc, &error);
    if (success == 0) {
      print_crc32(crc, NULL);
    } else {
      fprintf(stderr, "%s: %s: %s\n", "crc32", argv[1], error);
      ret = 2;
    }
  } else {
    for (int i = 1; i < argc; i++) {
      success = tbz_compute_file_crc32(argv[i], &crc, &error);
      if (success == 0) {
        print_crc32(crc, argv[i]);
      } else {
        fprintf(stderr, "%s: %s: %s\n", "crc32", argv[i], error);
        ret = 2;
        continue;
      }
    }
  }
  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   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1195 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ad <main+0x5d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c6 <main+0x176>
cmpl   $0x2,-0x8(%rbp)
jne    121e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <tbz_compute_file_crc32@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11ea <main+0x9a>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <print_crc32@plt>
jmp    1219 <main+0xc9>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x28(%rbp),%r8
lea    0xe01(%rip),%rsi
lea    0xe06(%rip),%rdx
call   1050 <fprintf@plt>
movl   $0x2,-0x1c(%rbp)
jmp    12c0 <main+0x170>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12bb <main+0x16b>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <tbz_compute_file_crc32@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1270 <main+0x120>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <print_crc32@plt>
jmp    12a8 <main+0x158>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x28(%rbp),%r8
lea    0xd77(%rip),%rsi
lea    0xd7c(%rip),%rdx
call   1050 <fprintf@plt>
movl   $0x2,-0x1c(%rbp)
jmp    12ad <main+0x15d>
jmp    12ad <main+0x15d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1225 <main+0xd5>
jmp    12c0 <main+0x170>
mov    -0x1c(%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    $0x2,%edi
jl     11ca <main+0x7a>
mov    %edi,%ebp
mov    0x8(%rbx),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ca <main+0x7a>
cmp    $0x2,%ebp
jne    11ea <main+0x9a>
mov    0x8(%rbx),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1030 <tbz_compute_file_crc32@plt>
test   %eax,%eax
je     1266 <main+0x116>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rcx
mov    0x10(%rsp),%r8
lea    0xe51(%rip),%rsi
lea    0xe56(%rip),%rdx
call   1050 <fprintf@plt>
mov    $0x2,%r14d
jmp    11d8 <main+0x88>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%r13d
xor    %r14d,%r14d
mov    $0x1,%ebp
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    1244 <main+0xf4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%rbp,8),%rcx
mov    0x10(%rsp),%r8
lea    0xdde(%rip),%rsi
lea    0xde3(%rip),%rdx
call   1050 <fprintf@plt>
mov    $0x2,%r14d
add    $0x1,%rbp
cmp    %rbp,%r13
je     11d8 <main+0x88>
mov    (%rbx,%rbp,8),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <tbz_compute_file_crc32@plt>
test   %eax,%eax
jne    1210 <main+0xc0>
mov    0xc(%rsp),%edi
mov    (%rbx,%rbp,8),%rsi
call   1070 <print_crc32@plt>
jmp    123b <main+0xeb>
mov    0xc(%rsp),%edi
xor    %r14d,%r14d
xor    %esi,%esi
call   1070 <print_crc32@plt>
jmp    11d8 <main+0x88>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"%s: %s: %s\0A\00"
@.str.2 = [6 x i8] c"crc32\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 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13, %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usage(i8* %22)
store i32 1, i32* %3
br label %83
24: ; preds = %13
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %45
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @tbz_compute_file_crc32(i8* %30, i32* %6, i8** %9)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* %6
%36 = call i32 @print_crc32(i32 %35, i8* null)
br label %44
37: ; preds = %27
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = load i8*, i8** %9
%43 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* %42)
store i32 2, i32* %8
br label %44
44: ; preds = %37, %34
br label %81
45: ; preds = %24
store i32 1, i32* %10
br label %46
46: ; preds = %77, %45
%47 = load i32, i32* %10
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %80
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @tbz_compute_file_crc32(i8* %55, i32* %6, i8** %9)
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %67
59: ; preds = %50
%60 = load i32, i32* %6
%61 = load i8**, i8*** %5
%62 = load i32, i32* %10
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 @print_crc32(i32 %60, i8* %65)
br label %76
67: ; preds = %50
%68 = load i32, i32* @stderr
%69 = load i8**, i8*** %5
%70 = load i32, i32* %10
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = load i8*, i8** %9
%75 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %73, i8* %74)
store i32 2, i32* %8
br label %77
76: ; preds = %59
br label %77
77: ; preds = %76, %67
%78 = load i32, i32* %10
%79 = add nsw i32 %78, 1
store i32 %79, i32* %10
br label %46
80: ; preds = %46
br label %81
81: ; preds = %80, %44
%82 = load i32, i32* %8
store i32 %82, i32* %3
br label %83
83: ; preds = %81, %19
%84 = load i32, i32* %3
ret i32 %84
}

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