#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
scalar_t__ parsepvd(int, char *, int *, long long *, int *, char *,
                    long long *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
void printMD5SUM(char *file) {
  int isofd;
  char mediasum[64];
  long long isosize;
  char fragmentsums[60 + 1];
  long long fragmentcount = 0;
  int supported;
  int skipsectors;
  isofd = open(file, O_RDONLY);
  if (isofd < 0) {
    fprintf(stderr, "%s: Unable to find install image.\n", file);
    exit(1);
  }
  if (parsepvd(isofd, mediasum, &skipsectors, &isosize, &supported,
               fragmentsums, &fragmentcount) < 0) {
    fprintf(stderr, "%s: Could not get pvd data", file);
    fprintf(stderr, "\nUnable to read the disc checksum from the "
                    "primary volume descriptor.\nThis probably "
                    "means the disc was created without adding the "
                    "checksum.");
    exit(1);
  }
  close(isofd);
  printf("%s:   %s\n", file, mediasum);
  if ((strlen(fragmentsums) > 0) && (fragmentcount > 0)) {
    printf("Fragment sums: %s\n", fragmentsums);
    printf("Fragment count: %lld\n", fragmentcount);
  }
}


x86 assembly (clang, -O0):
<printMD5SUM>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0xa8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ce <printMD5SUM+0x5e>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0xa0(%rbp),%r9
lea    -0xb0(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0xac(%rbp),%r8
lea    -0xa8(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <parsepvd@plt>
cmp    $0x0,%rax
jge    1244 <printMD5SUM+0xd4>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    12b0 <printMD5SUM+0x140>
cmpq   $0x0,-0xa8(%rbp)
jle    12b0 <printMD5SUM+0x140>
lea    -0xa0(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xa8(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMD5SUM>:
push   %rbp
push   %rbx
sub    $0xa8,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     1233 <printMD5SUM+0xc3>
mov    %eax,%ebp
lea    0x8(%rsp),%rax
mov    %rax,(%rsp)
lea    0x60(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %ebp,%edi
call   1040 <parsepvd@plt>
test   %rax,%rax
js     1257 <printMD5SUM+0xe7>
mov    %ebp,%edi
call   1060 <close@plt>
lea    0xeed(%rip),%rdi
lea    0x60(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    1229 <printMD5SUM+0xb9>
cmpq   $0x0,0x8(%rsp)
jle    1229 <printMD5SUM+0xb9>
lea    0xeca(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d7a(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xdbb(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdc2(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"%s: Unable to find install image.\0A\00"
@.str.1 = [27 x i8] c"%s: Could not get pvd data\00"
@.str.2 = [140 x i8] c"\0AUnable to read the disc checksum from the primary volume descriptor.\0AThis probably means the disc was created without adding the checksum.\00"
@.str.3 = [10 x i8] c"%s: %s\0A\00"
@.str.4 = [19 x i8] c"Fragment sums: %s\0A\00"
@.str.5 = [22 x i8] c"Fragment count: %lld\0A\00"
define void @printMD5SUM(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = alloca i64
%6 = alloca [61 x i8]
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %2
store i64 0, i64* %7
%10 = load i8*, i8** %2
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %1
%21 = load i32, i32* %3
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [61 x i8], [61 x i8]* %6, i64 0, i64 0
%24 = call i64 @parsepvd(i32 %21, i8* %22, i32* %9, i64* %5, i32* %8, i8* %23, i64* %7)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %2
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %20
%34 = load i32, i32* %3
%35 = call i32 @close(i32 %34)
%36 = load i8*, i8** %2
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %36, i8* %37)
%39 = getelementptr inbounds [61 x i8], [61 x i8]* %6, i64 0, i64 0
%40 = call i64 @strlen(i8* %39)
%41 = icmp sgt i64 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %33
%43 = load i64, i64* %7
%44 = icmp sgt i64 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = getelementptr inbounds [61 x i8], [61 x i8]* %6, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %46)
%48 = load i64, i64* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %48)
br label %50
50: ; preds = %45, %42, %33
ret void
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"%s: Unable to find install image.\0A\00"
@.str.1 = [27 x i8] c"%s: Could not get pvd data\00"
@.str.2 = [140 x i8] c"\0AUnable to read the disc checksum from the primary volume descriptor.\0AThis probably means the disc was created without adding the checksum.\00"
@.str.3 = [10 x i8] c"%s: %s\0A\00"
@.str.4 = [19 x i8] c"Fragment sums: %s\0A\00"
@.str.5 = [22 x i8] c"Fragment count: %lld\0A\00"
define void @printMD5SUM(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca i64
%4 = alloca [61 x i8]
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%9 = bitcast i64* %3 to i8*
%10 = getelementptr inbounds [61 x i8], [61 x i8]* %4, i64 0, i64 0
%11 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 @open(i8* %0, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %1
%22 = call i64 @parsepvd(i32 %15, i8* %8, i32* %7, i64* %3, i32* %6, i8* %10, i64* %5)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21
%31 = call i32 @close(i32 %15)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %8)
%33 = call i64 @strlen(i8* %10)
%34 = icmp sgt i64 %33, 0
%35 = load i64, i64* %5
%36 = icmp sgt i64 %35, 0
%37 = select i1 %34, i1 %36, i1 false
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%40 = load i64, i64* %5
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 %40)
br label %42
42: ; preds = %38, %30
ret void
}