#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*/ putcc(unsigned char volatile);
int puthex(volatile unsigned char a) {
  volatile unsigned char cTmp;
  cTmp = a >> 4;
  if (cTmp < 10) {
    cTmp += '0';
  } else {
    cTmp += 'A' - 10;
  }
  putcc(cTmp);
  cTmp = a & 0x0f;
  if (cTmp < 10) {
    cTmp += '0';
  } else {
    cTmp += 'A' - 10;
  }
  putcc(cTmp);
  return 0;
}


x86 assembly (clang, -O0):
<puthex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
movzbl %al,%eax
sar    $0x4,%eax
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
movzbl %al,%eax
cmp    $0xa,%eax
jge    114a <puthex+0x3a>
mov    -0x2(%rbp),%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,-0x2(%rbp)
jmp    1156 <puthex+0x46>
mov    -0x2(%rbp),%al
movzbl %al,%eax
add    $0x37,%eax
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
movzbl %al,%edi
call   1030 <putcc@plt>
mov    -0x1(%rbp),%al
movzbl %al,%eax
and    $0xf,%eax
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
movzbl %al,%eax
cmp    $0xa,%eax
jge    118d <puthex+0x7d>
mov    -0x2(%rbp),%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,-0x2(%rbp)
jmp    1199 <puthex+0x89>
mov    -0x2(%rbp),%al
movzbl %al,%eax
add    $0x37,%eax
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
movzbl %al,%edi
call   1030 <putcc@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puthex>:
push   %rax
mov    %dil,0x7(%rsp)
mov    0x7(%rsp),%al
shr    $0x4,%al
mov    %al,0x6(%rsp)
mov    0x6(%rsp),%cl
mov    0x6(%rsp),%al
cmp    $0x9,%cl
ja     1132 <puthex+0x22>
add    $0x30,%al
jmp    1134 <puthex+0x24>
add    $0x37,%al
mov    %al,0x6(%rsp)
movzbl 0x6(%rsp),%edi
call   1030 <putcc@plt>
mov    0x7(%rsp),%al
and    $0xf,%al
mov    %al,0x6(%rsp)
mov    0x6(%rsp),%cl
mov    0x6(%rsp),%al
cmp    $0x9,%cl
ja     115d <puthex+0x4d>
add    $0x30,%al
jmp    115f <puthex+0x4f>
add    $0x37,%al
mov    %al,0x6(%rsp)
movzbl 0x6(%rsp),%edi
call   1030 <putcc@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @puthex(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store volatile i8 %0, i8* %2
%4 = load volatile i8, i8* %2
%5 = lshr i8 %4, 4
store volatile i8 %5, i8* %3
%6 = load volatile i8, i8* %3
%7 = icmp ult i8 %6, 10
%8 = load volatile i8, i8* %3
br i1 %7, label %9, label %11
9: ; preds = %1
%10 = add i8 %8, 48
store volatile i8 %10, i8* %3
br label %13
11: ; preds = %1
%12 = add i8 %8, 55
store volatile i8 %12, i8* %3
br label %13
13: ; preds = %11, %9
%14 = load volatile i8, i8* %3
%15 = tail call i32 @putcc(i8 zeroext %14)
%16 = load volatile i8, i8* %2
%17 = and i8 %16, 15
store volatile i8 %17, i8* %3
%18 = load volatile i8, i8* %3
%19 = icmp ult i8 %18, 10
%20 = load volatile i8, i8* %3
br i1 %19, label %21, label %23
21: ; preds = %13
%22 = add i8 %20, 48
store volatile i8 %22, i8* %3
br label %25
23: ; preds = %13
%24 = add i8 %20, 55
store volatile i8 %24, i8* %3
br label %25
25: ; preds = %23, %21
%26 = load volatile i8, i8* %3
%27 = tail call i32 @putcc(i8 zeroext %26)
ret i32 0
}