#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 checkmd5sum(int, char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ parsepvd(int, char *, int *, long long *, int *, char *,
                    long long *);
int /*<<< orphan*/ stderr;
int doMediaCheck(int isofd, char *mediasum, char *computedsum,
                 long long *isosize, int *supported, int quiet) {
  int rc;
  int skipsectors;
  long long fragmentcount = 0;
  char fragmentsums[60 + 1];
  if (parsepvd(isofd, mediasum, &skipsectors, isosize, supported, fragmentsums,
               &fragmentcount) < 0) {
    fprintf(stderr, "Unable to read the disc checksum from the "
                    "primary volume descriptor.\nThis probably "
                    "means the disc was created without adding the "
                    "checksum.");
    return -1;
  }
  rc = checkmd5sum(isofd, mediasum, computedsum, quiet);
  return rc;
}


x86 assembly (clang, -O0):
<doMediaCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    -0x80(%rbp),%r9
lea    -0x34(%rbp),%rdx
lea    -0x40(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <parsepvd@plt>
cmp    $0x0,%rax
jge    11a9 <doMediaCheck+0x79>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c5 <doMediaCheck+0x95>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1050 <checkmd5sum@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doMediaCheck>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %r9d,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%ebx
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0x1c(%rsp),%rdx
lea    0x20(%rsp),%r9
call   1030 <parsepvd@plt>
test   %rax,%rax
js     117d <doMediaCheck+0x4d>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1050 <checkmd5sum@plt>
jmp    1197 <doMediaCheck+0x67>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [139 x i8] c"Unable to read the disc checksum from the primary volume descriptor.\0AThis probably means the disc was created without adding the checksum.\00"
define i32 @doMediaCheck(i32 %0, i8* %1, i8* %2, i64* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca [61 x i8]
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i64* %3, i64** %11
store i32* %4, i32** %12
store i32 %5, i32* %13
store i64 0, i64* %16
%18 = load i32, i32* %8
%19 = load i8*, i8** %9
%20 = load i64*, i64** %11
%21 = load i32*, i32** %12
%22 = getelementptr inbounds [61 x i8], [61 x i8]* %17, i64 0, i64 0
%23 = call i64 @parsepvd(i32 %18, i8* %19, i32* %15, i64* %20, i32* %21, i8* %22, i64* %16)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %6
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %7
br label %35
28: ; preds = %6
%29 = load i32, i32* %8
%30 = load i8*, i8** %9
%31 = load i8*, i8** %10
%32 = load i32, i32* %13
%33 = call i32 @checkmd5sum(i32 %29, i8* %30, i8* %31, i32 %32)
store i32 %33, i32* %14
%34 = load i32, i32* %14
store i32 %34, i32* %7
br label %35
35: ; preds = %28, %25
%36 = load i32, i32* %7
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [139 x i8] c"Unable to read the disc checksum from the primary volume descriptor.\0AThis probably means the disc was created without adding the checksum.\00"
define i32 @doMediaCheck(i32 %0, i8* %1, i8* %2, i64* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i64
%9 = alloca [61 x i8]
%10 = bitcast i32* %7 to i8*
%11 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%12 = getelementptr inbounds [61 x i8], [61 x i8]* %9, i64 0, i64 0
%13 = call i64 @parsepvd(i32 %0, i8* %1, i32* %7, i64* %3, i32* %4, i8* %12, i64* %8)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %6
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0))
br label %20
18: ; preds = %6
%19 = call i32 @checkmd5sum(i32 %0, i8* %1, i8* %2, i32 %5)
br label %20
20: ; preds = %18, %15
%21 = phi i32 [ -1, %15 ], [ %19, %18 ]
ret i32 %21
}