#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*/ LCDputc(char);
void LCDprintHex(unsigned int iout, unsigned char ucdigit) {
  char buf;
  int i;
  for (i = 3; i >= 0; i--) {
    buf = (iout >> (i * 4)) & 0x000f;
    if (buf < 10)
      buf += 0x30;
    else
      buf += 0x37;
    if (i < ucdigit)
      LCDputc(buf);
  }
}


x86 assembly (clang, -O0):
<LCDprintHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x3,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1194 <LCDprintHex+0x84>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0xa,%eax
jge    115f <LCDprintHex+0x4f>
movsbl -0x6(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x6(%rbp)
jmp    1169 <LCDprintHex+0x59>
movsbl -0x6(%rbp),%eax
add    $0x37,%eax
mov    %al,-0x6(%rbp)
mov    -0xc(%rbp),%eax
movzbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jge    1181 <LCDprintHex+0x71>
movsbl -0x6(%rbp),%edi
call   1030 <LCDputc@plt>
jmp    1186 <LCDprintHex+0x76>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <LCDprintHex+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCDprintHex>:
push   %rbx
mov    %edi,%ebx
cmp    $0x4,%sil
jb     113d <LCDprintHex+0x2d>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%edx
cmp    $0xa,%eax
movzbl %cl,%eax
movzbl %dl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%edi
call   1030 <LCDputc@plt>
jmp    1143 <LCDprintHex+0x33>
cmp    $0x3,%sil
jne    11a5 <LCDprintHex+0x95>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%edx
cmp    $0xa,%eax
movzbl %cl,%eax
movzbl %dl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%edi
call   1030 <LCDputc@plt>
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%edx
cmp    $0xa,%eax
movzbl %cl,%eax
movzbl %dl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%edi
call   1030 <LCDputc@plt>
and    $0xf,%ebx
lea    0x30(%rbx),%eax
lea    0x37(%rbx),%ecx
cmp    $0xa,%ebx
movzbl %al,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%edi
pop    %rbx
jmp    1030 <LCDputc@plt>
cmp    $0x2,%sil
jae    1165 <LCDprintHex+0x55>
test   %sil,%sil
jne    1187 <LCDprintHex+0x77>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @LCDprintHex(i32 %0, i8 zeroext %1) {
%3 = lshr i32 %0, 12
%4 = and i32 %3, 15
%5 = trunc i32 %4 to i8
%6 = icmp ugt i8 %1, 3
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = icmp ult i32 %4, 10
%9 = or i8 %5, 48
%10 = add nuw nsw i8 %5, 55
%11 = select i1 %8, i8 %9, i8 %10
%12 = tail call i32 @LCDputc(i8 signext %11)
br label %15
13: ; preds = %2
%14 = icmp eq i8 %1, 3
br i1 %14, label %15, label %24
15: ; preds = %13, %7
%16 = lshr i32 %0, 8
%17 = and i32 %16, 15
%18 = trunc i32 %17 to i8
%19 = icmp ult i32 %17, 10
%20 = or i8 %18, 48
%21 = add nuw nsw i8 %18, 55
%22 = select i1 %19, i8 %20, i8 %21
%23 = tail call i32 @LCDputc(i8 signext %22)
br label %26
24: ; preds = %13
%25 = icmp ugt i8 %1, 1
br i1 %25, label %26, label %35
26: ; preds = %24, %15
%27 = lshr i32 %0, 4
%28 = and i32 %27, 15
%29 = trunc i32 %28 to i8
%30 = icmp ult i32 %28, 10
%31 = or i8 %29, 48
%32 = add nuw nsw i8 %29, 55
%33 = select i1 %30, i8 %31, i8 %32
%34 = tail call i32 @LCDputc(i8 signext %33)
br label %37
35: ; preds = %24
%36 = icmp eq i8 %1, 0
br i1 %36, label %45, label %37
37: ; preds = %26, %35
%38 = and i32 %0, 15
%39 = trunc i32 %38 to i8
%40 = icmp ult i32 %38, 10
%41 = or i8 %39, 48
%42 = add nuw nsw i8 %39, 55
%43 = select i1 %40, i8 %41, i8 %42
%44 = tail call i32 @LCDputc(i8 signext %43)
br label %45
45: ; preds = %37, %35
ret void
}