#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*/ outw(unsigned short, unsigned short *);
void lcd_hpi_write_words(unsigned short chip_addr, unsigned short *data,
                         int num_words) {
  int i;
  outw(chip_addr, (unsigned short *)((0x0002 << 1) + 0xfff24000));
  for (i = 0; i < num_words; i++) {
    outw(*data++, (unsigned short *)((0x0000 << 1) + 0xfff24000));
  }
}


x86 assembly (clang, -O0):
<lcd_hpi_write_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0xfff24004,%esi
movzwl -0x2(%rbp),%edi
call   1030 <outw@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1171 <lcd_hpi_write_words+0x61>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x10(%rbp)
mov    $0xfff24000,%esi
movzwl (%rax),%edi
call   1030 <outw@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <lcd_hpi_write_words+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_hpi_write_words>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    $0xfff24000,%eax
lea    0x4(%rax),%rsi
call   1030 <outw@plt>
test   %ebp,%ebp
jle    1147 <lcd_hpi_write_words+0x37>
mov    %ebp,%ebp
xor    %ebx,%ebx
nop
movzwl (%r14,%rbx,2),%edi
mov    $0xfff24000,%esi
call   1030 <outw@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1130 <lcd_hpi_write_words+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @lcd_hpi_write_words(i16 zeroext %0, i16* %1, i32 %2) {
%4 = alloca i16
%5 = alloca i16*
%6 = alloca i32
%7 = alloca i32
store i16 %0, i16* %4
store i16* %1, i16** %5
store i32 %2, i32* %6
%8 = load i16, i16* %4
%9 = call i32 @outw(i16 zeroext %8, i16* inttoptr (i64 4294066180 to i16*))
store i32 0, i32* %7
br label %10
10: ; preds = %19, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i16*, i16** %5
%16 = getelementptr inbounds i16, i16* %15, i32 1
store i16* %16, i16** %5
%17 = load i16, i16* %15
%18 = call i32 @outw(i16 zeroext %17, i16* inttoptr (i64 4294066176 to i16*))
br label %19
19: ; preds = %14
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %10
22: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @lcd_hpi_write_words(i16 zeroext %0, i16* nocapture %1, i32 %2) {
%4 = tail call i32 @outw(i16 zeroext %0, i16* inttoptr (i64 4294066180 to i16*))
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %14
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ 0, %3 ]
%8 = phi i16* [ %9, %6 ], [ %1, %3 ]
%9 = getelementptr inbounds i16, i16* %8, i64 1
%10 = load i16, i16* %8
%11 = tail call i32 @outw(i16 zeroext %10, i16* inttoptr (i64 4294066176 to i16*))
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %6
14: ; preds = %6, %3
ret void
}