#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*/ NiashWriteBulk(int, unsigned char *, int);
int /*<<< orphan*/ NiashWriteReg(int, int, int);
void Hp3400cWriteFW(int iXferHandle, unsigned char *pabData, int iLen,
                    int iAddr) {
  iAddr--;
  NiashWriteReg(iXferHandle, 0x21, iAddr & 0xFF);
  NiashWriteReg(iXferHandle, 0x22, (iAddr >> 8) & 0xFF);
  NiashWriteReg(iXferHandle, 0x23, (iAddr >> 16) & 0xFF);
  NiashWriteBulk(iXferHandle, pabData, iLen);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%edx
and    $0xff,%edx
mov    $0x21,%esi
call   1040 <NiashWriteReg@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%edx
sar    $0x8,%edx
and    $0xff,%edx
mov    $0x22,%esi
call   1040 <NiashWriteReg@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%edx
sar    $0x10,%edx
and    $0xff,%edx
mov    $0x23,%esi
call   1040 <NiashWriteReg@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <NiashWriteBulk@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
add    $0xffffffff,%ebx
movzbl %bl,%edx
mov    $0x21,%esi
call   1040 <NiashWriteReg@plt>
movzbl %bh,%edx
mov    %ebp,%edi
mov    $0x22,%esi
call   1040 <NiashWriteReg@plt>
shr    $0x10,%ebx
movzbl %bl,%edx
mov    %ebp,%edi
mov    $0x23,%esi
call   1040 <NiashWriteReg@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <NiashWriteBulk@plt>

LLVM IR (-O0):
define void @Hp3400cWriteFW(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = add nsw i32 %9, -1
store i32 %10, i32* %8
%11 = load i32, i32* %5
%12 = load i32, i32* %8
%13 = and i32 %12, 255
%14 = call i32 @NiashWriteReg(i32 %11, i32 33, i32 %13)
%15 = load i32, i32* %5
%16 = load i32, i32* %8
%17 = ashr i32 %16, 8
%18 = and i32 %17, 255
%19 = call i32 @NiashWriteReg(i32 %15, i32 34, i32 %18)
%20 = load i32, i32* %5
%21 = load i32, i32* %8
%22 = ashr i32 %21, 16
%23 = and i32 %22, 255
%24 = call i32 @NiashWriteReg(i32 %20, i32 35, i32 %23)
%25 = load i32, i32* %5
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = call i32 @NiashWriteBulk(i32 %25, i8* %26, i32 %27)
ret void
}

LLVM IR (-O2):
define void @Hp3400cWriteFW(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = add nsw i32 %3, -1
%6 = and i32 %5, 255
%7 = tail call i32 @NiashWriteReg(i32 %0, i32 33, i32 %6)
%8 = lshr i32 %5, 8
%9 = and i32 %8, 255
%10 = tail call i32 @NiashWriteReg(i32 %0, i32 34, i32 %9)
%11 = lshr i32 %5, 16
%12 = and i32 %11, 255
%13 = tail call i32 @NiashWriteReg(i32 %0, i32 35, i32 %12)
%14 = tail call i32 @NiashWriteBulk(i32 %0, i8* %1, i32 %2)
ret void
}