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

/* Variables and functions */
unsigned long adfNormalSum(unsigned char *, int /*<<< orphan*/, int);
scalar_t__ adfWriteBlock(struct Volume *, long, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, struct bBitmapBlock *, int);
int /*<<< orphan*/ swLong(unsigned char *, unsigned long);
long adfWriteBitmapBlock(struct Volume *vol, long nSect,
                         struct bBitmapBlock *bitm) {
  unsigned char buf[512];
  unsigned long newSum;
  memcpy(buf, bitm, 512);
  newSum = adfNormalSum(buf, 0, 512);
  swLong(buf, newSum);
  if (adfWriteBlock(vol, nSect, (unsigned char *)buf) != 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<adfWriteBitmapBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x200,%edx
call   1050 <memcpy@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <adfNormalSum@plt>
mov    %rax,-0x228(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x228(%rbp),%rsi
call   1060 <swLong@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x220(%rbp),%rdx
call   1030 <adfWriteBlock@plt>
cmp    $0x0,%rax
je     11c4 <adfWriteBitmapBlock+0x84>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11cc <adfWriteBitmapBlock+0x8c>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adfWriteBitmapBlock>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rdx,%rsi
mov    $0x200,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <adfNormalSum@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <swLong@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <adfWriteBlock@plt>
neg    %rax
sbb    %rax,%rax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.Volume = type { i32 }
%struct.bBitmapBlock = type { i32 }
define i64 @adfWriteBitmapBlock(%struct.Volume* %0, i64 %1, %struct.bBitmapBlock* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32 @memcpy(i8* %5, %struct.bBitmapBlock* %2, i32 512)
%7 = call i64 @adfNormalSum(i8* %5, i32 0, i32 512)
%8 = call i32 @swLong(i8* %5, i64 %7)
%9 = call i64 @adfWriteBlock(%struct.Volume* %0, i64 %1, i8* %5)
%10 = icmp ne i64 %9, 0
%11 = sext i1 %10 to i64
ret i64 %11
}