#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*/ lcd_hex(short, int /*<<< orphan*/, unsigned short);
void lcd_hexdump(short row, short col, unsigned short *data, short num) {
  short idx;
  for (idx = 0; idx < num; idx++) {
    lcd_hex(row, col++, (data[idx] >> 4) & 0x0F);
    lcd_hex(row, col++, (data[idx] >> 0) & 0x0F);
  }
}


x86 assembly (clang, -O0):
<lcd_hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %si,%cx
mov    %di,%si
mov    %si,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    11c0 <lcd_hexdump+0xb0>
mov    -0x2(%rbp),%cx
mov    -0x4(%rbp),%ax
mov    %ax,%dx
add    $0x1,%dx
mov    %dx,-0x4(%rbp)
movswl %ax,%esi
mov    -0x10(%rbp),%rax
movswq -0x14(%rbp),%rdx
movzwl (%rax,%rdx,2),%eax
sar    $0x4,%eax
and    $0xf,%eax
movswl %cx,%edi
movzwl %ax,%edx
call   1030 <lcd_hex@plt>
mov    -0x2(%rbp),%cx
mov    -0x4(%rbp),%ax
mov    %ax,%dx
add    $0x1,%dx
mov    %dx,-0x4(%rbp)
movswl %ax,%esi
mov    -0x10(%rbp),%rax
movswq -0x14(%rbp),%rdx
movzwl (%rax,%rdx,2),%eax
sar    $0x0,%eax
and    $0xf,%eax
movswl %cx,%edi
movzwl %ax,%edx
call   1030 <lcd_hex@plt>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1137 <lcd_hexdump+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %cx,%cx
jle    116a <lcd_hexdump+0x5a>
mov    %rdx,%r14
mov    %esi,%ebx
movzwl %cx,%r15d
xor    %ebp,%ebp
movswl %di,%r12d
nop
lea    0x1(%rbx),%r13d
movswl %bx,%esi
movzwl (%r14,%rbp,2),%edx
shr    $0x4,%edx
and    $0xf,%edx
mov    %r12d,%edi
call   1030 <lcd_hex@plt>
add    $0x2,%ebx
movswl %r13w,%esi
movzwl (%r14,%rbp,2),%edx
and    $0xf,%edx
mov    %r12d,%edi
call   1030 <lcd_hex@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1130 <lcd_hexdump+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lcd_hexdump(i16 signext %0, i16 signext %1, i16* %2, i16 signext %3) {
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16*
%8 = alloca i16
%9 = alloca i16
store i16 %0, i16* %5
store i16 %1, i16* %6
store i16* %2, i16** %7
store i16 %3, i16* %8
store i16 0, i16* %9
br label %10
10: ; preds = %45, %4
%11 = load i16, i16* %9
%12 = sext i16 %11 to i32
%13 = load i16, i16* %8
%14 = sext i16 %13 to i32
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %48
16: ; preds = %10
%17 = load i16, i16* %5
%18 = load i16, i16* %6
%19 = add i16 %18, 1
store i16 %19, i16* %6
%20 = sext i16 %18 to i32
%21 = load i16*, i16** %7
%22 = load i16, i16* %9
%23 = sext i16 %22 to i64
%24 = getelementptr inbounds i16, i16* %21, i64 %23
%25 = load i16, i16* %24
%26 = zext i16 %25 to i32
%27 = ashr i32 %26, 4
%28 = and i32 %27, 15
%29 = trunc i32 %28 to i16
%30 = call i32 @lcd_hex(i16 signext %17, i32 %20, i16 zeroext %29)
%31 = load i16, i16* %5
%32 = load i16, i16* %6
%33 = add i16 %32, 1
store i16 %33, i16* %6
%34 = sext i16 %32 to i32
%35 = load i16*, i16** %7
%36 = load i16, i16* %9
%37 = sext i16 %36 to i64
%38 = getelementptr inbounds i16, i16* %35, i64 %37
%39 = load i16, i16* %38
%40 = zext i16 %39 to i32
%41 = ashr i32 %40, 0
%42 = and i32 %41, 15
%43 = trunc i32 %42 to i16
%44 = call i32 @lcd_hex(i16 signext %31, i32 %34, i16 zeroext %43)
br label %45
45: ; preds = %16
%46 = load i16, i16* %9
%47 = add i16 %46, 1
store i16 %47, i16* %9
br label %10
48: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @lcd_hexdump(i16 signext %0, i16 signext %1, i16* nocapture %2, i16 signext %3) {
%5 = icmp sgt i16 %3, 0
br i1 %5, label %6, label %25
6: ; preds = %4
%7 = zext i16 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %23, %8 ]
%10 = phi i16 [ %1, %6 ], [ %18, %8 ]
%11 = add i16 %10, 1
%12 = sext i16 %10 to i32
%13 = getelementptr inbounds i16, i16* %2, i64 %9
%14 = load i16, i16* %13
%15 = lshr i16 %14, 4
%16 = and i16 %15, 15
%17 = tail call i32 @lcd_hex(i16 signext %0, i32 %12, i16 zeroext %16)
%18 = add i16 %10, 2
%19 = sext i16 %11 to i32
%20 = load i16, i16* %13
%21 = and i16 %20, 15
%22 = tail call i32 @lcd_hex(i16 signext %0, i32 %19, i16 zeroext %21)
%23 = add nuw nsw i64 %9, 1
%24 = icmp eq i64 %23, %7
br i1 %24, label %25, label %8
25: ; preds = %8, %4
ret void
}