#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*/ exit(int);
int mediaCheckFile(char *, int);
int /*<<< orphan*/ printMD5SUM(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int i;
  int rc;
  int verbose;
  int md5only;
  int filearg;
  if (argc < 2) {
    printf("Usage: checkisomd5 [--md5sumonly] [--verbose] "
           "<isofilename>|<blockdevice>\n\n");
    exit(1);
  }
  md5only = 0;
  verbose = 0;
  filearg = 1;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--md5sumonly") == 0) {
      md5only = 1;
      filearg++;
    } else if (strcmp(argv[i], "--verbose") == 0) {
      filearg++;
      verbose = 1;
    } else
      break;
  }
  if (md5only | verbose)
    printMD5SUM(argv[filearg]);
  if (md5only)
    exit(0);
  rc = mediaCheckFile(argv[filearg], !verbose);
  if (rc == 1)
    exit(0);
  else
    exit(1);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1186 <main+0x36>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1239 <main+0xe9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e5 <main+0x95>
movl   $0x1,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1226 <main+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <main+0xcc>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1221 <main+0xd1>
jmp    1239 <main+0xe9>
jmp    1226 <main+0xd6>
jmp    122b <main+0xdb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a2 <main+0x52>
mov    -0x20(%rbp),%eax
or     -0x1c(%rbp),%eax
cmp    $0x0,%eax
je     1259 <main+0x109>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <printMD5SUM@plt>
cmpl   $0x0,-0x20(%rbp)
je     126a <main+0x11a>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1030 <mediaCheckFile@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    129d <main+0x14d>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    1176 <main+0x26>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rsi,%rbx
mov    %edi,%r12d
movl   $0x0,0x4(%rsp)
mov    $0x1,%ebp
lea    0xe70(%rip),%r14
lea    0xe76(%rip),%r15
xor    %r13d,%r13d
jmp    11b1 <main+0x61>
nopl   0x0(%rax)
movl   $0x1,0x4(%rsp)
add    $0x1,%rbp
cmp    %rbp,%r12
je     11db <main+0x8b>
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a0 <main+0x50>
mov    (%rbx,%rbp,8),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11de <main+0x8e>
mov    $0x1,%r13d
jmp    11a8 <main+0x58>
mov    %r12d,%ebp
mov    0x4(%rsp),%r14d
mov    %r14d,%eax
or     %r13d,%eax
je     11f6 <main+0xa6>
mov    %ebp,%eax
mov    (%rbx,%rax,8),%rdi
call   1050 <printMD5SUM@plt>
test   %r14d,%r14d
jne    1214 <main+0xc4>
mov    %ebp,%eax
mov    (%rbx,%rax,8),%rdi
xor    %esi,%esi
test   %r13d,%r13d
sete   %sil
call   1030 <mediaCheckFile@plt>
cmp    $0x1,%eax
jne    121b <main+0xcb>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str.1 = [13 x i8] c"--md5sumonly\00"
@.str.2 = [10 x i8] c"--verbose\00"
@str = [75 x i8] c"Usage: checkisomd5 [--md5sumonly] [--verbose] <isofilename>|<blockdevice>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %4, %21
%10 = phi i64 [ 1, %4 ], [ %24, %21 ]
%11 = phi i32 [ 0, %4 ], [ %23, %21 ]
%12 = phi i32 [ 0, %4 ], [ %22, %21 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %10
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %9
%18 = load i8*, i8** %13
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17, %9
%22 = phi i32 [ %12, %9 ], [ 1, %17 ]
%23 = phi i32 [ 1, %9 ], [ %11, %17 ]
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %28, label %9
26: ; preds = %17
%27 = trunc i64 %10 to i32
br label %28
28: ; preds = %21, %26
%29 = phi i32 [ %12, %26 ], [ %22, %21 ]
%30 = phi i32 [ %11, %26 ], [ %23, %21 ]
%31 = phi i32 [ %27, %26 ], [ %0, %21 ]
%32 = or i32 %30, %29
%33 = icmp eq i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %28
%35 = zext i32 %31 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @printMD5SUM(i8* %37)
br label %39
39: ; preds = %34, %28
%40 = icmp eq i32 %30, 0
br i1 %40, label %43, label %41
41: ; preds = %39
%42 = tail call i32 @exit(i32 0)
unreachable
43: ; preds = %39
%44 = zext i32 %31 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = icmp eq i32 %29, 0
%48 = zext i1 %47 to i32
%49 = tail call i32 @mediaCheckFile(i8* %46, i32 %48)
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = tail call i32 @exit(i32 0)
unreachable
53: ; preds = %43
%54 = tail call i32 @exit(i32 1)
unreachable
}