#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 check_md5sum(void *, unsigned char *, unsigned int);
int /*<<< orphan*/ close_file(void *);
int errno;
int /*<<< orphan*/ errx(int, char *, ...);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
void *open_file(char const *, unsigned int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strerror(int);
int string_to_digest(char const *, unsigned char *);
int check_one_file(const char *pszFilename, const char *pszDigest,
                   unsigned fText, unsigned fQuiet, unsigned fProgress) {
  unsigned char Digest[16];
  int rc;
  rc = string_to_digest(pszDigest, Digest);
  if (!rc) {
    void *pvFile;
    pvFile = open_file(pszFilename, fText);
    if (pvFile) {
      if (!fQuiet)
        fprintf(stdout, "%s: ", pszFilename);
      rc = check_md5sum(pvFile, Digest, fProgress);
      close_file(pvFile);
      if (!fQuiet) {
        fprintf(stdout, "%s\n", !rc ? "OK" : rc < 0 ? "FAILURE" : "ERROR");
        fflush(stdout);
        if (rc > 0)
          errx(1, "Error reading '%s': %s", pszFilename, strerror(rc));
      }
      if (rc)
        rc = 1;
    } else {
      if (!fQuiet)
        errx(1, "Failed to open '%s': %s", pszFilename, strerror(errno));
      rc = 1;
    }
  } else {
    errx(1, "Malformed MD5 digest '%s'!", pszDigest);
    errx(1, "                      %*s^", rc - 1, "");
    rc = 1;
  }
  return rc;
}


x86 assembly (clang, -O0):
<check_one_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <string_to_digest@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    130e <check_one_file+0x18e>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <open_file@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     12c9 <check_one_file+0x149>
cmpl   $0x0,-0x18(%rbp)
jne    11f2 <check_one_file+0x72>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe13(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <check_md5sum@plt>
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <close_file@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12b3 <check_one_file+0x133>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    123e <check_one_file+0xbe>
lea    0xdd4(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    125a <check_one_file+0xda>
mov    -0x34(%rbp),%edx
lea    0xdcc(%rip),%rax
lea    0xdbd(%rip),%rcx
cmp    $0x0,%edx
cmovl  %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x50(%rbp),%rdx
lea    0xd9d(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
cmpl   $0x0,-0x34(%rbp)
jle    12ae <check_one_file+0x12e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x34(%rbp),%edi
call   10a0 <strerror@plt>
mov    -0x58(%rbp),%rdx
mov    %eax,%ecx
mov    $0x1,%edi
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
jmp    12b3 <check_one_file+0x133>
cmpl   $0x0,-0x34(%rbp)
je     12c4 <check_one_file+0x144>
movl   $0x1,-0x34(%rbp)
jmp    1309 <check_one_file+0x189>
cmpl   $0x0,-0x18(%rbp)
jne    1302 <check_one_file+0x182>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x60(%rbp),%rdx
mov    %eax,%ecx
mov    $0x1,%edi
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
movl   $0x1,-0x34(%rbp)
jmp    134c <check_one_file+0x1cc>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xd2b(%rip),%rsi
mov    $0x0,%al
call   1070 <errx@plt>
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    $0x1,%edi
lea    0xd2d(%rip),%rsi
lea    0xcca(%rip),%rcx
mov    $0x0,%al
call   1070 <errx@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_one_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <string_to_digest@plt>
test   %eax,%eax
je     11ee <check_one_file+0x6e>
mov    %eax,%ebp
lea    0xe94(%rip),%rsi
mov    $0x1,%r13d
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <errx@plt>
add    $0xffffffff,%ebp
lea    0xe90(%rip),%rsi
lea    0xe2d(%rip),%rcx
mov    $0x1,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <errx@plt>
jmp    12e4 <check_one_file+0x164>
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <open_file@plt>
test   %rax,%rax
je     12ad <check_one_file+0x12d>
mov    %rax,%rbx
test   %r12d,%r12d
jne    1222 <check_one_file+0xa2>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
mov    %r15,%rdx
call   1080 <fprintf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1050 <check_md5sum@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <close_file@plt>
test   %r12d,%r12d
jne    12a1 <check_one_file+0x121>
mov    0x2d91(%rip),%rbx
lea    0xdbe(%rip),%rax
lea    0xdbf(%rip),%rcx
test   %r14d,%r14d
cmovs  %rax,%rcx
mov    (%rbx),%edi
lea    0xda4(%rip),%rdx
cmovne %rcx,%rdx
lea    0xd95(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%rbx),%edi
call   1090 <fflush@plt>
test   %r14d,%r14d
jle    12a1 <check_one_file+0x121>
mov    %r14d,%edi
call   10a0 <strerror@plt>
lea    0xd8a(%rip),%rsi
mov    $0x1,%edi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <errx@plt>
xor    %r13d,%r13d
test   %r14d,%r14d
setne  %r13b
jmp    12e4 <check_one_file+0x164>
mov    $0x1,%r13d
test   %r12d,%r12d
jne    12e4 <check_one_file+0x164>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd64(%rip),%rsi
mov    $0x1,%r13d
mov    $0x1,%edi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <errx@plt>
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [6 x i8] c"ERROR\00"
@.str.5 = [23 x i8] c"Error reading '%s': %s\00"
@.str.6 = [24 x i8] c"Failed to open '%s': %s\00"
@errno = global i32 0
@.str.7 = [27 x i8] c"Malformed MD5 digest '%s'!\00"
@.str.8 = [27 x i8] c" %*s^\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @check_one_file(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [16 x i8]
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i8*, i8** %7
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%16 = call i32 @string_to_digest(i8* %14, i8* %15)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp ne i32 %17, 0
br i1 %18, label %79, label %19
19: ; preds = %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %8
%22 = call i8* @open_file(i8* %20, i32 %21)
store i8* %22, i8** %13
%23 = load i8*, i8** %13
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %69
25: ; preds = %19
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i32, i32* @stdout
%30 = load i8*, i8** %6
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %25
%33 = load i8*, i8** %13
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%35 = load i32, i32* %10
%36 = call i32 @check_md5sum(i8* %33, i8* %34, i32 %35)
store i32 %36, i32* %12
%37 = load i8*, i8** %13
%38 = call i32 @close_file(i8* %37)
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %64, label %41
41: ; preds = %32
%42 = load i32, i32* @stdout
%43 = load i32, i32* %12
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %41
br label %51
46: ; preds = %41
%47 = load i32, i32* %12
%48 = icmp slt i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
br label %51
51: ; preds = %46, %45
%52 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %45 ], [ %50, %46 ]
%53 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = load i32, i32* @stdout
%55 = call i32 @fflush(i32 %54)
%56 = load i32, i32* %12
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %51
%59 = load i8*, i8** %6
%60 = load i32, i32* %12
%61 = call i32 @strerror(i32 %60)
%62 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %59, i32 %61)
br label %63
63: ; preds = %58, %51
br label %64
64: ; preds = %63, %32
%65 = load i32, i32* %12
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 1, i32* %12
br label %68
68: ; preds = %67, %64
br label %78
69: ; preds = %19
%70 = load i32, i32* %9
%71 = icmp ne i32 %70, 0
br i1 %71, label %77, label %72
72: ; preds = %69
%73 = load i8*, i8** %6
%74 = load i32, i32* @errno
%75 = call i32 @strerror(i32 %74)
%76 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %73, i32 %75)
br label %77
77: ; preds = %72, %69
store i32 1, i32* %12
br label %78
78: ; preds = %77, %68
br label %85
79: ; preds = %5
%80 = load i8*, i8** %7
%81 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %80)
%82 = load i32, i32* %12
%83 = sub nsw i32 %82, 1
%84 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %83, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %12
br label %85
85: ; preds = %79, %78
%86 = load i32, i32* %12
ret i32 %86
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [8 x i8] c"FAILURE\00"
@.str.4 = [6 x i8] c"ERROR\00"
@.str.5 = [23 x i8] c"Error reading '%s': %s\00"
@.str.6 = [24 x i8] c"Failed to open '%s': %s\00"
@errno = global i32 0
@.str.7 = [27 x i8] c"Malformed MD5 digest '%s'!\00"
@.str.8 = [27 x i8] c" %*s^\00"
@.str.9 = [1 x i8] zeroinitializer
define i32 @check_one_file(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = call i32 @string_to_digest(i8* %1, i8* %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %42
10: ; preds = %5
%11 = call i8* @open_file(i8* %0, i32 %2)
%12 = icmp eq i8* %11, null
%13 = icmp eq i32 %3, 0
br i1 %12, label %37, label %14
14: ; preds = %10
br i1 %13, label %15, label %18
15: ; preds = %14
%16 = load i32, i32* @stdout
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %18
18: ; preds = %15, %14
%19 = call i32 @check_md5sum(i8* %11, i8* %7, i32 %4)
%20 = call i32 @close_file(i8* %11)
br i1 %13, label %21, label %34
21: ; preds = %18
%22 = load i32, i32* @stdout
%23 = icmp eq i32 %19, 0
%24 = icmp slt i32 %19, 0
%25 = select i1 %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%26 = select i1 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25
%27 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = icmp sgt i32 %19, 0
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = call i32 @strerror(i32 %19)
%33 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %32)
br label %34
34: ; preds = %21, %31, %18
%35 = icmp ne i32 %19, 0
%36 = zext i1 %35 to i32
br label %46
37: ; preds = %10
br i1 %13, label %38, label %46
38: ; preds = %37
%39 = load i32, i32* @errno
%40 = call i32 @strerror(i32 %39)
%41 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %40)
br label %46
42: ; preds = %5
%43 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%44 = add nsw i32 %8, -1
%45 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %46
46: ; preds = %34, %38, %37, %42
%47 = phi i32 [ 1, %42 ], [ %36, %34 ], [ 1, %38 ], [ 1, %37 ]
ret i32 %47
}