#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*/ early_debug_putc(unsigned char);
void early_debug_put_hex_char(unsigned char x) {
  unsigned char temp;
  temp = ((x >> 4) & 0xf);
  if (temp < 10)
    temp += '0';
  else
    temp += ('A' - 10);
  early_debug_putc(temp);
  temp = (x & 0xf);
  if (temp < 10)
    temp += '0';
  else
    temp += ('A' - 10);
  early_debug_putc(temp);
}


x86 assembly (clang, -O0):
<early_debug_put_hex_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0xa,%eax
jge    1147 <early_debug_put_hex_char+0x37>
movzbl -0x2(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x2(%rbp)
jmp    1151 <early_debug_put_hex_char+0x41>
movzbl -0x2(%rbp),%eax
add    $0x37,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%edi
call   1030 <early_debug_putc@plt>
movzbl -0x1(%rbp),%eax
and    $0xf,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0xa,%eax
jge    1180 <early_debug_put_hex_char+0x70>
movzbl -0x2(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x2(%rbp)
jmp    118a <early_debug_put_hex_char+0x7a>
movzbl -0x2(%rbp),%eax
add    $0x37,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%edi
call   1030 <early_debug_putc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<early_debug_put_hex_char>:
push   %rbx
mov    %edi,%ebx
mov    %ebx,%eax
shr    $0x4,%al
lea    0x30(%rax),%ecx
add    $0x37,%al
cmp    $0xa0,%bl
movzbl %cl,%ecx
movzbl %al,%eax
cmovb  %ecx,%eax
movzbl %al,%edi
call   1030 <early_debug_putc@plt>
and    $0xf,%bl
lea    0x30(%rbx),%eax
lea    0x37(%rbx),%ecx
cmp    $0xa,%bl
movzbl %al,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%edi
pop    %rbx
jmp    1030 <early_debug_putc@plt>

LLVM IR (-O0):
define void @early_debug_put_hex_char(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
%6 = ashr i32 %5, 4
%7 = and i32 %6, 15
%8 = trunc i32 %7 to i8
store i8 %8, i8* %3
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %17
12: ; preds = %1
%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
br label %22
17: ; preds = %1
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = add nsw i32 %19, 55
%21 = trunc i32 %20 to i8
store i8 %21, i8* %3
br label %22
22: ; preds = %17, %12
%23 = load i8, i8* %3
%24 = call i32 @early_debug_putc(i8 zeroext %23)
%25 = load i8, i8* %2
%26 = zext i8 %25 to i32
%27 = and i32 %26, 15
%28 = trunc i32 %27 to i8
store i8 %28, i8* %3
%29 = load i8, i8* %3
%30 = zext i8 %29 to i32
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %37
32: ; preds = %22
%33 = load i8, i8* %3
%34 = zext i8 %33 to i32
%35 = add nsw i32 %34, 48
%36 = trunc i32 %35 to i8
store i8 %36, i8* %3
br label %42
37: ; preds = %22
%38 = load i8, i8* %3
%39 = zext i8 %38 to i32
%40 = add nsw i32 %39, 55
%41 = trunc i32 %40 to i8
store i8 %41, i8* %3
br label %42
42: ; preds = %37, %32
%43 = load i8, i8* %3
%44 = call i32 @early_debug_putc(i8 zeroext %43)
ret void
}

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