#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 */
struct bBitmapExtBlock {
  int dummy;
};
struct Volume {
  int dummy;
};

/* Variables and functions */
scalar_t__ adfReadBlock(struct Volume *, long, unsigned char *);
int /*<<< orphan*/ memcpy(struct bBitmapExtBlock *, unsigned char *, int);
long adfReadBitmapExtBlock(struct Volume *vol, long nSect,
                           struct bBitmapExtBlock *bitme) {
  unsigned char buf[512];
  if (adfReadBlock(vol, nSect, buf) != 0)
    return -1;
  memcpy(bitme, buf, 512);
  return 0;
}


x86 assembly (clang, -O0):
<adfReadBitmapExtBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x220(%rbp),%rdx
call   1040 <adfReadBlock@plt>
cmp    $0x0,%rax
je     1162 <adfReadBitmapExtBlock+0x42>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    117f <adfReadBitmapExtBlock+0x5f>
mov    -0x20(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    $0x200,%edx
call   1030 <memcpy@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adfReadBitmapExtBlock>:
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%rbx
mov    %rsp,%rdx
call   1040 <adfReadBlock@plt>
mov    %rax,%rcx
mov    $0xffffffffffffffff,%rax
test   %rcx,%rcx
jne    1154 <adfReadBitmapExtBlock+0x34>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x200,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.Volume = type { i32 }
%struct.bBitmapExtBlock = type { i32 }
define i64 @adfReadBitmapExtBlock(%struct.Volume* %0, i64 %1, %struct.bBitmapExtBlock* %2) {
%4 = alloca i64
%5 = alloca %struct.Volume*
%6 = alloca i64
%7 = alloca %struct.bBitmapExtBlock*
%8 = alloca [512 x i8]
store %struct.Volume* %0, %struct.Volume** %5
store i64 %1, i64* %6
store %struct.bBitmapExtBlock* %2, %struct.bBitmapExtBlock** %7
%9 = load %struct.Volume*, %struct.Volume** %5
%10 = load i64, i64* %6
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%12 = call i64 @adfReadBlock(%struct.Volume* %9, i64 %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i64 -1, i64* %4
br label %19
15: ; preds = %3
%16 = load %struct.bBitmapExtBlock*, %struct.bBitmapExtBlock** %7
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%18 = call i32 @memcpy(%struct.bBitmapExtBlock* %16, i8* %17, i32 512)
store i64 0, i64* %4
br label %19
19: ; preds = %15, %14
%20 = load i64, i64* %4
ret i64 %20
}

LLVM IR (-O2):
%struct.Volume = type { i32 }
%struct.bBitmapExtBlock = type { i32 }
define i64 @adfReadBitmapExtBlock(%struct.Volume* %0, i64 %1, %struct.bBitmapExtBlock* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i64 @adfReadBlock(%struct.Volume* %0, i64 %1, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @memcpy(%struct.bBitmapExtBlock* %2, i8* %5, i32 512)
br label %10
10: ; preds = %3, %8
%11 = phi i64 [ 0, %8 ], [ -1, %3 ]
ret i64 %11
}