#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_putch(char);
void lcd_disp_hex(unsigned char i) {
  unsigned char hi, lo;
  hi = i & 0xF0;
  hi = hi >> 4;
  hi = hi + '0';
  if (hi > '9') {
    hi = hi + 7;
  }
  lo = (i & 0x0F) + '0';
  if (lo > '9') {
    lo = lo + 7;
  }
  lcd_putch((char)hi);
  lcd_putch((char)lo);
}


x86 assembly (clang, -O0):
<lcd_disp_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0xf0,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
sar    $0x4,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x39,%eax
jle    1155 <lcd_disp_hex+0x45>
movzbl -0x2(%rbp),%eax
add    $0x7,%eax
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
and    $0xf,%eax
add    $0x30,%eax
mov    %al,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
cmp    $0x39,%eax
jle    1179 <lcd_disp_hex+0x69>
movzbl -0x3(%rbp),%eax
add    $0x7,%eax
mov    %al,-0x3(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <lcd_putch@plt>
movsbl -0x3(%rbp),%edi
call   1030 <lcd_putch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_disp_hex>:
push   %rbx
mov    %edi,%eax
shr    $0x4,%al
lea    0x30(%rax),%ecx
add    $0x37,%al
cmp    $0x3a,%cl
movzbl %al,%eax
movzbl %cl,%ecx
cmovae %eax,%ecx
and    $0xf,%dil
lea    0x30(%rdi),%eax
add    $0x37,%dil
cmp    $0x3a,%al
movzbl %dil,%edx
movzbl %al,%ebx
cmovae %edx,%ebx
movzbl %cl,%edi
call   1030 <lcd_putch@plt>
movzbl %bl,%edi
pop    %rbx
jmp    1030 <lcd_putch@plt>

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

LLVM IR (-O2):
define void @lcd_disp_hex(i8 zeroext %0) {
%2 = lshr i8 %0, 4
%3 = or i8 %2, 48
%4 = icmp ugt i8 %3, 57
%5 = add nuw nsw i8 %2, 55
%6 = select i1 %4, i8 %5, i8 %3
%7 = and i8 %0, 15
%8 = or i8 %7, 48
%9 = icmp ugt i8 %8, 57
%10 = add nuw nsw i8 %7, 55
%11 = select i1 %9, i8 %10, i8 %8
%12 = tail call i32 @lcd_putch(i8 signext %6)
%13 = tail call i32 @lcd_putch(i8 signext %11)
ret void
}