#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*/ uint8_t;
struct crypt_ops {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ mdchecklist(int /*<<< orphan*/ *, struct crypt_ops *,
                               int /*<<< orphan*/ *, size_t, int *, int *,
                               int *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ weprintf(char *, ...);
int cryptcheck(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md,
               size_t sz) {
  FILE *fp;
  int formatsucks = 0, noread = 0, nonmatch = 0, ret = 0;
  if (argc == 0) {
    mdchecklist(stdin, ops, md, sz, &formatsucks, &noread, &nonmatch);
  } else {
    for (; *argv; argc--, argv++) {
      if ((*argv)[0] == '-' && !(*argv)[1]) {
        fp = stdin;
      } else if (!(fp = fopen(*argv, "r"))) {
        weprintf("fopen %s:", *argv);
        ret = 1;
        continue;
      }
      mdchecklist(fp, ops, md, sz, &formatsucks, &noread, &nonmatch);
      if (fp != stdin)
        fclose(fp);
    }
  }
  if (formatsucks) {
    weprintf("%d lines are improperly formatted\n", formatsucks);
    ret = 1;
  }
  if (noread) {
    weprintf("%d listed file could not be read\n", noread);
    ret = 1;
  }
  if (nonmatch) {
    weprintf("%d computed checksums did NOT match\n", nonmatch);
    ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<cryptcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b1 <cryptcheck+0x71>
mov    0x2e60(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x3c(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <mdchecklist@plt>
jmp    12a8 <cryptcheck+0x168>
jmp    11b6 <cryptcheck+0x76>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     12a3 <cryptcheck+0x163>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11fb <cryptcheck+0xbb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,0x1(%rax)
jne    11fb <cryptcheck+0xbb>
mov    0x2df9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1242 <cryptcheck+0x102>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    123d <cryptcheck+0xfd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1050 <weprintf@plt>
movl   $0x1,-0x40(%rbp)
jmp    1289 <cryptcheck+0x149>
jmp    1242 <cryptcheck+0x102>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x3c(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <mdchecklist@plt>
mov    -0x30(%rbp),%rax
mov    0x2d76(%rip),%rcx
cmp    (%rcx),%rax
je     1284 <cryptcheck+0x144>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1289 <cryptcheck+0x149>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11b6 <cryptcheck+0x76>
jmp    12a8 <cryptcheck+0x168>
cmpl   $0x0,-0x34(%rbp)
je     12ca <cryptcheck+0x18a>
mov    -0x34(%rbp),%esi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1050 <weprintf@plt>
movl   $0x1,-0x40(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     12ec <cryptcheck+0x1ac>
mov    -0x38(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1050 <weprintf@plt>
movl   $0x1,-0x40(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     130e <cryptcheck+0x1ce>
mov    -0x3c(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1050 <weprintf@plt>
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cryptcheck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
test   %edi,%edi
je     121e <cryptcheck+0xde>
mov    %rsi,%rbp
mov    (%rsi),%rdi
test   %rdi,%rdi
je     1249 <cryptcheck+0x109>
add    $0x8,%rbp
xor    %r12d,%r12d
jmp    11b9 <cryptcheck+0x79>
nop
mov    -0x8(%rbp),%rsi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <weprintf@plt>
mov    $0x1,%r12d
mov    0x0(%rbp),%rdi
add    $0x8,%rbp
test   %rdi,%rdi
je     124c <cryptcheck+0x10c>
cmpb   $0x2d,(%rdi)
jne    11c4 <cryptcheck+0x84>
cmpb   $0x0,0x1(%rdi)
je     11da <cryptcheck+0x9a>
lea    0xe35(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    11e4 <cryptcheck+0xa4>
jmp    1190 <cryptcheck+0x50>
mov    0x2e07(%rip),%rax
mov    (%rax),%r13
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
call   1040 <mdchecklist@plt>
mov    0x2dd9(%rip),%rax
cmp    (%rax),%r13
je     11a8 <cryptcheck+0x68>
mov    %r13,%rdi
call   1030 <fclose@plt>
jmp    11a8 <cryptcheck+0x68>
mov    0x2dc3(%rip),%rax
mov    (%rax),%rdi
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <mdchecklist@plt>
xor    %r12d,%r12d
mov    0x14(%rsp),%esi
test   %esi,%esi
je     1268 <cryptcheck+0x128>
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1050 <weprintf@plt>
mov    $0x1,%r12d
mov    0x10(%rsp),%esi
test   %esi,%esi
je     1284 <cryptcheck+0x144>
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1050 <weprintf@plt>
mov    $0x1,%r12d
mov    0xc(%rsp),%esi
test   %esi,%esi
je     12a0 <cryptcheck+0x160>
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1050 <weprintf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.crypt_ops = type { i32 }
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"fopen %s:\00"
@.str.2 = [35 x i8] c"%d lines are improperly formatted\0A\00"
@.str.3 = [34 x i8] c"%d listed file could not be read\0A\00"
@.str.4 = [37 x i8] c"%d computed checksums did NOT match\0A\00"
define i32 @cryptcheck(i32 %0, i8** %1, %struct.crypt_ops* %2, i32* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca %struct.crypt_ops*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store %struct.crypt_ops* %2, %struct.crypt_ops** %8
store i32* %3, i32** %9
store i64 %4, i64* %10
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %5
%19 = load i32*, i32** @stdin
%20 = load %struct.crypt_ops*, %struct.crypt_ops** %8
%21 = load i32*, i32** %9
%22 = load i64, i64* %10
%23 = call i32 @mdchecklist(i32* %19, %struct.crypt_ops* %20, i32* %21, i64 %22, i32* %12, i32* %13, i32* %14)
br label %73
24: ; preds = %5
br label %25
25: ; preds = %67, %24
%26 = load i8**, i8*** %7
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %72
29: ; preds = %25
%30 = load i8**, i8*** %7
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 45
br i1 %35, label %36, label %44
36: ; preds = %29
%37 = load i8**, i8*** %7
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %36
%43 = load i32*, i32** @stdin
store i32* %43, i32** %11
br label %54
44: ; preds = %36, %29
%45 = load i8**, i8*** %7
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %47, i32** %11
%48 = icmp ne i32* %47, null
br i1 %48, label %53, label %49
49: ; preds = %44
%50 = load i8**, i8*** %7
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %51)
store i32 1, i32* %15
br label %67
53: ; preds = %44
br label %54
54: ; preds = %53, %42
%55 = load i32*, i32** %11
%56 = load %struct.crypt_ops*, %struct.crypt_ops** %8
%57 = load i32*, i32** %9
%58 = load i64, i64* %10
%59 = call i32 @mdchecklist(i32* %55, %struct.crypt_ops* %56, i32* %57, i64 %58, i32* %12, i32* %13, i32* %14)
%60 = load i32*, i32** %11
%61 = load i32*, i32** @stdin
%62 = icmp ne i32* %60, %61
br i1 %62, label %63, label %66
63: ; preds = %54
%64 = load i32*, i32** %11
%65 = call i32 @fclose(i32* %64)
br label %66
66: ; preds = %63, %54
br label %67
67: ; preds = %66, %49
%68 = load i32, i32* %6
%69 = add nsw i32 %68, -1
store i32 %69, i32* %6
%70 = load i8**, i8*** %7
%71 = getelementptr inbounds i8*, i8** %70, i32 1
store i8** %71, i8*** %7
br label %25
72: ; preds = %25
br label %73
73: ; preds = %72, %18
%74 = load i32, i32* %12
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i32, i32* %12
%78 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %77)
store i32 1, i32* %15
br label %79
79: ; preds = %76, %73
%80 = load i32, i32* %13
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* %13
%84 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %83)
store i32 1, i32* %15
br label %85
85: ; preds = %82, %79
%86 = load i32, i32* %14
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i32, i32* %14
%90 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %89)
store i32 1, i32* %15
br label %91
91: ; preds = %88, %85
%92 = load i32, i32* %15
ret i32 %92
}

LLVM IR (-O2):
%struct.crypt_ops = type { i32 }
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"fopen %s:\00"
@.str.2 = [35 x i8] c"%d lines are improperly formatted\0A\00"
@.str.3 = [34 x i8] c"%d listed file could not be read\0A\00"
@.str.4 = [37 x i8] c"%d computed checksums did NOT match\0A\00"
define i32 @cryptcheck(i32 %0, i8** nocapture %1, %struct.crypt_ops* %2, i32* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%10 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%11 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%12 = icmp eq i32 %0, 0
br i1 %12, label %16, label %13
13: ; preds = %5
%14 = load i8*, i8** %1
%15 = icmp eq i8* %14, null
br i1 %15, label %49, label %19
16: ; preds = %5
%17 = load i32*, i32** @stdin
%18 = call i32 @mdchecklist(i32* %17, %struct.crypt_ops* %2, i32* %3, i64 %4, i32* %6, i32* %7, i32* %8)
br label %49
19: ; preds = %13, %44
%20 = phi i8* [ %47, %44 ], [ %14, %13 ]
%21 = phi i32 [ %45, %44 ], [ 0, %13 ]
%22 = phi i8** [ %46, %44 ], [ %1, %13 ]
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 45
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = getelementptr inbounds i8, i8* %20, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32*, i32** @stdin
br label %37
31: ; preds = %25, %19
%32 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** %22
%36 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %44
37: ; preds = %31, %29
%38 = phi i32* [ %32, %31 ], [ %30, %29 ]
%39 = call i32 @mdchecklist(i32* %38, %struct.crypt_ops* %2, i32* %3, i64 %4, i32* %6, i32* %7, i32* %8)
%40 = load i32*, i32** @stdin
%41 = icmp eq i32* %38, %40
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = call i32 @fclose(i32* %38)
br label %44
44: ; preds = %37, %42, %34
%45 = phi i32 [ %21, %42 ], [ %21, %37 ], [ 1, %34 ]
%46 = getelementptr inbounds i8*, i8** %22, i64 1
%47 = load i8*, i8** %46
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %19
49: ; preds = %44, %13, %16
%50 = phi i32 [ 0, %16 ], [ 0, %13 ], [ %45, %44 ]
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %49
%54 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %51)
br label %55
55: ; preds = %53, %49
%56 = phi i32 [ 1, %53 ], [ %50, %49 ]
%57 = load i32, i32* %7
%58 = icmp eq i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %55
%60 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %61
61: ; preds = %59, %55
%62 = phi i32 [ 1, %59 ], [ %56, %55 ]
%63 = load i32, i32* %8
%64 = icmp eq i32 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 (i8*, ...) @weprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %67
67: ; preds = %65, %61
%68 = phi i32 [ 1, %65 ], [ %62, %61 ]
ret i32 %68
}