#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*/ SEEK_SET;
int lseek(int, int, int /*<<< orphan*/);
int read(int, unsigned char *, long);
int parsepvd(int isofd, unsigned char *mediasum, long long *isosize) {
  unsigned char buf[2048];
  long long offset;
  unsigned char *p __attribute__((unused));
  if (lseek(isofd, 16 * 2048, SEEK_SET) == -1)
    return ((long long)-1);
  offset = (16 * 2048);
  for (; 1;) {
    if (read(isofd, buf, 2048L) == -1)
      return ((long long)-1);
    if (buf[0] == 1)
      break;
    else if (buf[0] == 255)
      return ((long long)-1);
    offset += 2048L;
  }
  *isosize = (buf[84] * 0x1000000 + buf[84 + 1] * 0x10000 +
              buf[84 + 2] * 0x100 + buf[84 + 3]) *
             2048LL;
  return offset;
}


x86 assembly (clang, -O0):
<parsepvd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    $0x8000,%esi
call   1030 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1161 <parsepvd+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <parsepvd+0x118>
movq   $0x8000,-0x828(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    117b <parsepvd+0x5b>
jmp    11f5 <parsepvd+0xd5>
mov    -0x8(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
jne    11a4 <parsepvd+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <parsepvd+0x118>
movzbl -0x820(%rbp),%eax
cmp    $0x1,%eax
jne    11b9 <parsepvd+0x99>
jmp    11f5 <parsepvd+0xd5>
movzbl -0x820(%rbp),%eax
cmp    $0xff,%eax
jne    11d7 <parsepvd+0xb7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <parsepvd+0x118>
jmp    11dc <parsepvd+0xbc>
mov    -0x828(%rbp),%rax
add    $0x800,%rax
mov    %rax,-0x828(%rbp)
jmp    116c <parsepvd+0x4c>
movzbl -0x7cc(%rbp),%eax
shl    $0x18,%eax
movzbl -0x7cb(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
movzbl -0x7ca(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
movzbl -0x7c9(%rbp),%ecx
add    %ecx,%eax
movslq %eax,%rcx
shl    $0xb,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x828(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsepvd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdx,%r14
mov    %edi,%ebp
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
mov    $0x8000,%esi
call   1030 <lseek@plt>
cmp    $0xffffffff,%eax
je     1196 <parsepvd+0x76>
mov    %rsp,%rsi
mov    $0x800,%edx
mov    %ebp,%edi
call   1040 <read@plt>
cmp    $0xffffffff,%eax
je     1196 <parsepvd+0x76>
mov    $0x8000,%ebx
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp),%eax
cmp    $0xff,%al
je     1196 <parsepvd+0x76>
cmp    $0x1,%al
je     11ab <parsepvd+0x8b>
mov    $0x800,%edx
mov    %ebp,%edi
mov    %r15,%rsi
call   1040 <read@plt>
add    $0x800,%ebx
cmp    $0xffffffff,%eax
jne    1170 <parsepvd+0x50>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x54(%rsp),%eax
shl    $0x20,%rax
bswap  %rax
shl    $0xb,%rax
mov    %rax,(%r14)
jmp    119b <parsepvd+0x7b>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @parsepvd(i32 %0, i8* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca [2048 x i8]
%9 = alloca i64
%10 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64* %2, i64** %7
%11 = load i32, i32* %5
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @lseek(i32 %11, i32 32768, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 -1, i32* %4
br label %64
16: ; preds = %3
store i64 32768, i64* %9
br label %17
17: ; preds = %37, %16
br i1 true, label %18, label %40
18: ; preds = %17
%19 = load i32, i32* %5
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i64 2048)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %4
br label %64
24: ; preds = %18
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %24
br label %40
30: ; preds = %24
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = icmp eq i32 %33, 255
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 -1, i32* %4
br label %64
36: ; preds = %30
br label %37
37: ; preds = %36
%38 = load i64, i64* %9
%39 = add nsw i64 %38, 2048
store i64 %39, i64* %9
br label %17
40: ; preds = %29, %17
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 84
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = mul nsw i32 %43, 16777216
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 85
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = mul nsw i32 %47, 65536
%49 = add nsw i32 %44, %48
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 86
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = mul nsw i32 %52, 256
%54 = add nsw i32 %49, %53
%55 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 87
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = add nsw i32 %54, %57
%59 = sext i32 %58 to i64
%60 = mul nsw i64 %59, 2048
%61 = load i64*, i64** %7
store i64 %60, i64* %61
%62 = load i64, i64* %9
%63 = trunc i64 %62 to i32
store i32 %63, i32* %4
br label %64
64: ; preds = %40, %35, %23, %15
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @parsepvd(i32 %0, i8* nocapture readnone %1, i64* nocapture writeonly %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @lseek(i32 %0, i32 32768, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %40, label %9
9: ; preds = %3
%10 = call i32 @read(i32 %0, i8* %5, i64 2048)
%11 = icmp eq i32 %10, -1
br i1 %11, label %40, label %12
12: ; preds = %9, %15
%13 = phi i64 [ %16, %15 ], [ 32768, %9 ]
%14 = load i8, i8* %5
switch i8 %14, label %15 [
i8 1, label %19
i8 -1, label %40
]
15: ; preds = %12
%16 = add nuw nsw i64 %13, 2048
%17 = call i32 @read(i32 %0, i8* %5, i64 2048)
%18 = icmp eq i32 %17, -1
br i1 %18, label %40, label %12
19: ; preds = %12
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 84
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = shl nuw nsw i64 %22, 24
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 85
%25 = load i8, i8* %24
%26 = zext i8 %25 to i64
%27 = shl nuw nsw i64 %26, 16
%28 = or i64 %27, %23
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 86
%30 = load i8, i8* %29
%31 = zext i8 %30 to i64
%32 = shl nuw nsw i64 %31, 8
%33 = or i64 %28, %32
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 87
%35 = load i8, i8* %34
%36 = zext i8 %35 to i64
%37 = or i64 %33, %36
%38 = shl nuw nsw i64 %37, 11
store i64 %38, i64* %2
%39 = trunc i64 %13 to i32
br label %40
40: ; preds = %15, %12, %9, %3, %19
%41 = phi i32 [ %39, %19 ], [ -1, %3 ], [ -1, %9 ], [ -1, %12 ], [ -1, %15 ]
ret i32 %41
}