#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*/ bbm_word_write(void *, int, unsigned char);
int fci_hpi_write(void *handle, unsigned char chip, unsigned char addr,
                  unsigned char alen, unsigned char *data, unsigned char len) {
  int i;
  for (i = 0; i < len; i++, data++)
    bbm_word_write(handle, 0x0f00 | addr, (*data << 8) | *data);
  return 0;
}


x86 assembly (clang, -O0):
<fci_hpi_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %sil,-0x9(%rbp)
mov    %dl,-0xa(%rbp)
mov    %cl,-0xb(%rbp)
mov    %r8,-0x18(%rbp)
mov    %al,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
movzbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
jge    1189 <fci_hpi_write+0x79>
mov    -0x8(%rbp),%rdi
movzbl -0xa(%rbp),%esi
or     $0xf00,%esi
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
or     %ecx,%eax
movzbl %al,%edx
call   1030 <bbm_word_write@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <fci_hpi_write+0x27>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fci_hpi_write>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %r9d,%r9d
je     1158 <fci_hpi_write+0x48>
mov    %r8,%r14
mov    %rdi,%r15
movzbl %dl,%ebp
or     $0xf00,%ebp
movzbl %r9b,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <bbm_word_write@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1140 <fci_hpi_write+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fci_hpi_write(i8* %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* %4, i8 zeroext %5) {
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i32
store i8* %0, i8** %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8* %4, i8** %11
store i8 %5, i8* %12
store i32 0, i32* %13
br label %14
14: ; preds = %34, %6
%15 = load i32, i32* %13
%16 = load i8, i8* %12
%17 = zext i8 %16 to i32
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i8, i8* %9
%22 = zext i8 %21 to i32
%23 = or i32 3840, %22
%24 = load i8*, i8** %11
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl i32 %26, 8
%28 = load i8*, i8** %11
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = or i32 %27, %30
%32 = trunc i32 %31 to i8
%33 = call i32 @bbm_word_write(i8* %20, i32 %23, i8 zeroext %32)
br label %34
34: ; preds = %19
%35 = load i32, i32* %13
%36 = add nsw i32 %35, 1
store i32 %36, i32* %13
%37 = load i8*, i8** %11
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %11
br label %14
39: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
define i32 @fci_hpi_write(i8* %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* nocapture %4, i8 zeroext %5) {
%7 = zext i8 %5 to i32
%8 = icmp eq i8 %5, 0
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = zext i8 %2 to i32
%11 = or i32 %10, 3840
br label %12
12: ; preds = %9, %12
%13 = phi i32 [ 0, %9 ], [ %17, %12 ]
%14 = phi i8* [ %4, %9 ], [ %18, %12 ]
%15 = load i8, i8* %14
%16 = tail call i32 @bbm_word_write(i8* %0, i32 %11, i8 zeroext %15)
%17 = add nuw nsw i32 %13, 1
%18 = getelementptr inbounds i8, i8* %14, i64 1
%19 = icmp eq i32 %17, %7
br i1 %19, label %20, label %12
20: ; preds = %12, %6
ret i32 0
}