#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*/ cryptsum(struct crypt_ops *, int /*<<< orphan*/ *, char *,
                            int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/ *);
int mdcheckline(char *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ printf(char *, char *);
char *strstr(char *, char *);
int /*<<< orphan*/ weprintf(char *, char *);
void mdchecklist(FILE *listfp, struct crypt_ops *ops, uint8_t *md, size_t sz,
                 int *formatsucks, int *noread, int *nonmatch) {
  FILE *fp;
  size_t bufsiz = 0;
  int r;
  char *line = NULL, *file, *p;
  while (getline(&line, &bufsiz, listfp) > 0) {
    if (!(file = strstr(line, "  "))) {
      (*formatsucks)++;
      continue;
    }
    if ((file - line) / 2 != sz) {
      (*formatsucks)++;
      continue;
    }
    *file = '\0';
    file += 2;
    for (p = file; *p && *p != '\n' && *p != '\r'; p++)
      ;
    *p = '\0';
    if (!(fp = fopen(file, "r"))) {
      weprintf("fopen %s:", file);
      (*noread)++;
      continue;
    }
    cryptsum(ops, fp, file, md);
    r = mdcheckline(line, md, sz);
    if (r == 1) {
      printf("%s: OK\n", file);
    } else if (r == 0) {
      printf("%s: FAILED\n", file);
      (*nonmatch)++;
    } else {
      (*formatsucks)++;
    }
    fclose(fp);
  }
  free(line);
}


x86 assembly (clang, -O0):
<mdchecklist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10a0 <getline@plt>
cmp    $0x0,%rax
jle    138c <mdchecklist+0x1fc>
mov    -0x50(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    120d <mdchecklist+0x7d>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11c4 <mdchecklist+0x34>
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    -0x20(%rbp),%rax
je     123c <mdchecklist+0xac>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11c4 <mdchecklist+0x34>
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x58(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
je     1291 <mdchecklist+0x101>
mov    -0x60(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x61(%rbp)
je     1291 <mdchecklist+0x101>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    12a1 <mdchecklist+0x111>
jmp    12b7 <mdchecklist+0x127>
jmp    12a6 <mdchecklist+0x116>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1257 <mdchecklist+0xc7>
mov    -0x60(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x58(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    12fc <mdchecklist+0x16c>
mov    -0x58(%rbp),%rsi
lea    0xd1e(%rip),%rdi
call   1080 <weprintf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11c4 <mdchecklist+0x34>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1070 <cryptsum@plt>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <mdcheckline@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
jne    1344 <mdchecklist+0x1b4>
mov    -0x58(%rbp),%rsi
lea    0xcd5(%rip),%rdi
call   1050 <printf@plt>
jmp    137e <mdchecklist+0x1ee>
cmpl   $0x0,-0x44(%rbp)
jne    136e <mdchecklist+0x1de>
mov    -0x58(%rbp),%rsi
lea    0xcbe(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1379 <mdchecklist+0x1e9>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    137e <mdchecklist+0x1ee>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11c4 <mdchecklist+0x34>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdchecklist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,%r13
mov    %rcx,0x10(%rsp)
mov    %rdx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%r15
movq   $0x0,0x18(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    %r15,%rdx
call   10a0 <getline@plt>
test   %rax,%rax
jle    131f <mdchecklist+0x18f>
lea    0xe14(%rip),%r12
lea    0x8(%rsp),%rbp
jmp    121e <mdchecklist+0x8e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addl   $0x1,0x0(%r13)
mov    %rbp,%rdi
lea    0x18(%rsp),%rsi
mov    %r15,%rdx
call   10a0 <getline@plt>
test   %rax,%rax
jle    131f <mdchecklist+0x18f>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1200 <mdchecklist+0x70>
mov    %rax,%r14
sub    %rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
add    %rax,%rcx
sar    %rcx
cmp    0x10(%rsp),%rcx
jne    1200 <mdchecklist+0x70>
movb   $0x0,(%r14)
add    $0x2,%r14
mov    %r14,%rax
mov    $0x2401,%edx
jmp    1264 <mdchecklist+0xd4>
nop
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0xd,%rcx
ja     1260 <mdchecklist+0xd0>
bt     %rcx,%rdx
jae    1260 <mdchecklist+0xd0>
mov    %r13,%rbp
movb   $0x0,(%rax)
mov    %r14,%rdi
lea    0xd80(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12d4 <mdchecklist+0x144>
mov    %rax,%r13
mov    0x28(%rsp),%rdi
mov    %rax,%rsi
mov    %r14,%rdx
mov    0x30(%rsp),%rbx
mov    %rbx,%rcx
call   1070 <cryptsum@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    0x10(%rsp),%rdx
call   1060 <mdcheckline@plt>
test   %eax,%eax
je     12ed <mdchecklist+0x15d>
cmp    $0x1,%eax
jne    1306 <mdchecklist+0x176>
lea    0xd45(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
jmp    130a <mdchecklist+0x17a>
lea    0xd2a(%rip),%rdi
mov    %r14,%rsi
call   1080 <weprintf@plt>
mov    0x20(%rsp),%rax
addl   $0x1,(%rax)
jmp    1312 <mdchecklist+0x182>
lea    0xd23(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    0x70(%rsp),%rax
addl   $0x1,(%rax)
jmp    130a <mdchecklist+0x17a>
addl   $0x1,0x0(%rbp)
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %rbp,%r13
lea    0x8(%rsp),%rbp
jmp    1205 <mdchecklist+0x75>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.crypt_ops = type { i32 }
@.str = [3 x i8] c" \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"fopen %s:\00"
@.str.3 = [8 x i8] c"%s: OK\0A\00"
@.str.4 = [12 x i8] c"%s: FAILED\0A\00"
define void @mdchecklist(i32* %0, %struct.crypt_ops* %1, i32* %2, i64 %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32*
%9 = alloca %struct.crypt_ops*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i64
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
store i32* %0, i32** %8
store %struct.crypt_ops* %1, %struct.crypt_ops** %9
store i32* %2, i32** %10
store i64 %3, i64* %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
store i64 0, i64* %16
store i8* null, i8** %18
br label %21
21: ; preds = %112, %77, %42, %29, %7
%22 = load i32*, i32** %8
%23 = call i64 @getline(i8** %18, i64* %16, i32* %22)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %115
25: ; preds = %21
%26 = load i8*, i8** %18
%27 = call i8* @strstr(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %19
%28 = icmp ne i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32*, i32** %12
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %21
33: ; preds = %25
%34 = load i8*, i8** %19
%35 = load i8*, i8** %18
%36 = ptrtoint i8* %34 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = sdiv i64 %38, 2
%40 = load i64, i64* %11
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %33
%43 = load i32*, i32** %12
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
br label %21
46: ; preds = %33
%47 = load i8*, i8** %19
store i8 0, i8* %47
%48 = load i8*, i8** %19
%49 = getelementptr inbounds i8, i8* %48, i64 2
store i8* %49, i8** %19
%50 = load i8*, i8** %19
store i8* %50, i8** %20
br label %51
51: ; preds = %69, %46
%52 = load i8*, i8** %20
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %51
%57 = load i8*, i8** %20
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 10
br i1 %60, label %61, label %66
61: ; preds = %56
%62 = load i8*, i8** %20
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 13
br label %66
66: ; preds = %61, %56, %51
%67 = phi i1 [ false, %56 ], [ false, %51 ], [ %65, %61 ]
br i1 %67, label %68, label %72
68: ; preds = %66
br label %69
69: ; preds = %68
%70 = load i8*, i8** %20
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %20
br label %51
72: ; preds = %66
%73 = load i8*, i8** %20
store i8 0, i8* %73
%74 = load i8*, i8** %19
%75 = call i32* @fopen(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %75, i32** %15
%76 = icmp ne i32* %75, null
br i1 %76, label %83, label %77
77: ; preds = %72
%78 = load i8*, i8** %19
%79 = call i32 @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %78)
%80 = load i32*, i32** %13
%81 = load i32, i32* %80
%82 = add nsw i32 %81, 1
store i32 %82, i32* %80
br label %21
83: ; preds = %72
%84 = load %struct.crypt_ops*, %struct.crypt_ops** %9
%85 = load i32*, i32** %15
%86 = load i8*, i8** %19
%87 = load i32*, i32** %10
%88 = call i32 @cryptsum(%struct.crypt_ops* %84, i32* %85, i8* %86, i32* %87)
%89 = load i8*, i8** %18
%90 = load i32*, i32** %10
%91 = load i64, i64* %11
%92 = call i32 @mdcheckline(i8* %89, i32* %90, i64 %91)
store i32 %92, i32* %17
%93 = load i32, i32* %17
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %98
95: ; preds = %83
%96 = load i8*, i8** %19
%97 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %96)
br label %112
98: ; preds = %83
%99 = load i32, i32* %17
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %98
%102 = load i8*, i8** %19
%103 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %102)
%104 = load i32*, i32** %14
%105 = load i32, i32* %104
%106 = add nsw i32 %105, 1
store i32 %106, i32* %104
br label %111
107: ; preds = %98
%108 = load i32*, i32** %12
%109 = load i32, i32* %108
%110 = add nsw i32 %109, 1
store i32 %110, i32* %108
br label %111
111: ; preds = %107, %101
br label %112
112: ; preds = %111, %95
%113 = load i32*, i32** %15
%114 = call i32 @fclose(i32* %113)
br label %21
115: ; preds = %21
%116 = load i8*, i8** %18
%117 = call i32 @free(i8* %116)
ret void
}

LLVM IR (-O2):
%struct.crypt_ops = type { i32 }
@.str = [3 x i8] c" \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"fopen %s:\00"
@.str.3 = [8 x i8] c"%s: OK\0A\00"
@.str.4 = [12 x i8] c"%s: FAILED\0A\00"
define void @mdchecklist(i32* %0, %struct.crypt_ops* %1, i32* %2, i64 %3, i32* nocapture %4, i32* nocapture %5, i32* nocapture %6) {
%8 = alloca i64
%9 = alloca i8*
%10 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%11 = bitcast i8** %9 to i8*
store i8* null, i8** %9
%12 = call i64 @getline(i8** %9, i64* %8, i32* %0)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %62
14: ; preds = %7, %21
%15 = load i8*, i8** %9
%16 = call i8* @strstr(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %18, %30, %43, %60
%22 = call i64 @getline(i8** %9, i64* %8, i32* %0)
%23 = icmp sgt i64 %22, 0
br i1 %23, label %14, label %62
24: ; preds = %14
%25 = ptrtoint i8* %16 to i64
%26 = ptrtoint i8* %15 to i64
%27 = sub i64 %25, %26
%28 = sdiv i64 %27, 2
%29 = icmp eq i64 %28, %3
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %21
33: ; preds = %24
store i8 0, i8* %16
%34 = getelementptr inbounds i8, i8* %16, i64 2
br label %35
35: ; preds = %38, %33
%36 = phi i8* [ %34, %33 ], [ %39, %38 ]
%37 = load i8, i8* %36
switch i8 %37, label %38 [
i8 0, label %40
i8 10, label %40
i8 13, label %40
]
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %36, i64 1
br label %35
40: ; preds = %35, %35, %35
store i8 0, i8* %36
%41 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = call i32 @weprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %21
47: ; preds = %40
%48 = call i32 @cryptsum(%struct.crypt_ops* %1, i32* %41, i8* %34, i32* %2)
%49 = load i8*, i8** %9
%50 = call i32 @mdcheckline(i8* %49, i32* %2, i64 %3)
switch i32 %50, label %57 [
i32 1, label %51
i32 0, label %53
]
51: ; preds = %47
%52 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %60
53: ; preds = %47
%54 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %60
57: ; preds = %47
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %60
60: ; preds = %53, %57, %51
%61 = call i32 @fclose(i32* %41)
br label %21
62: ; preds = %21, %7
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
ret void
}