#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void put8bitval_inhex(FILE *outputfile_handle, uint8_t value) {
  uint8_t lval;
  char c;
  lval = (value >> 4);
  if (lval >= 10)
    c = lval + 55;
  else
    c = lval + 48;
  fputc(c, outputfile_handle);
  lval = value & 0x0F;
  if (lval >= 10)
    c = lval + 55;
  else
    c = lval + 48;
  fputc(c, outputfile_handle);
}


x86 assembly (clang, -O0):
<put8bitval_inhex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jl     1140 <put8bitval_inhex+0x30>
mov    -0x10(%rbp),%eax
add    $0x37,%eax
mov    %al,-0x11(%rbp)
jmp    1149 <put8bitval_inhex+0x39>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jl     1179 <put8bitval_inhex+0x69>
mov    -0x10(%rbp),%eax
add    $0x37,%eax
mov    %al,-0x11(%rbp)
jmp    1182 <put8bitval_inhex+0x72>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put8bitval_inhex>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%eax
shr    $0x4,%eax
cmp    $0xa0,%esi
mov    $0x37,%ecx
mov    $0x30,%edx
cmovge %ecx,%edx
add    %al,%dl
movsbl %dl,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
and    $0xf,%ebx
lea    0x37(%rbx),%eax
lea    0x30(%rbx),%ecx
cmp    $0xa,%ebx
movzbl %al,%eax
movzbl %cl,%ecx
cmovae %eax,%ecx
movzbl %cl,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fputc@plt>

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

LLVM IR (-O2):
define void @put8bitval_inhex(i32* nocapture %0, i32 %1) {
%3 = lshr i32 %1, 4
%4 = icmp sgt i32 %1, 159
%5 = trunc i32 %3 to i8
%6 = select i1 %4, i8 55, i8 48
%7 = add i8 %6, %5
%8 = tail call i32 @fputc(i8 signext %7, i32* %0)
%9 = and i32 %1, 15
%10 = icmp ugt i32 %9, 9
%11 = trunc i32 %9 to i8
%12 = add nuw nsw i8 %11, 55
%13 = or i8 %11, 48
%14 = select i1 %10, i8 %12, i8 %13
%15 = tail call i32 @fputc(i8 signext %14, i32* %0)
ret void
}