#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*/ assert(int);
char nibble2ascii(char nibble) {
  assert((nibble & 0x0f) == nibble);
  if (0x00 <= nibble && nibble <= 0x09) {
    return nibble + '0';
  } else if (0x0a <= nibble && nibble <= 0x0f) {
    return (nibble - 0x0a) + 'a';
  }
  return 0x00;
}


x86 assembly (clang, -O0):
<nibble2ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
and    $0xf,%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsbl -0x2(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jg     1162 <nibble2ascii+0x52>
movsbl -0x2(%rbp),%eax
cmp    $0x9,%eax
jg     1162 <nibble2ascii+0x52>
movsbl -0x2(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x1(%rbp)
jmp    119b <nibble2ascii+0x8b>
movsbl -0x2(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jg     1192 <nibble2ascii+0x82>
movsbl -0x2(%rbp),%eax
cmp    $0xf,%eax
jg     1192 <nibble2ascii+0x82>
movsbl -0x2(%rbp),%eax
sub    $0xa,%eax
add    $0x61,%eax
mov    %al,-0x1(%rbp)
jmp    119b <nibble2ascii+0x8b>
jmp    1197 <nibble2ascii+0x87>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nibble2ascii>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x10,%bl
setb   %dil
call   1030 <assert@plt>
cmp    $0x9,%bl
ja     112b <nibble2ascii+0x1b>
add    $0x30,%bl
jmp    113b <nibble2ascii+0x2b>
lea    -0xa(%rbx),%eax
add    $0x57,%bl
xor    %ecx,%ecx
cmp    $0x6,%al
movzbl %bl,%ebx
cmovae %ecx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define signext i8 @nibble2ascii(i8 signext %0) {
%2 = icmp ult i8 %0, 16
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = icmp ult i8 %0, 10
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = add nuw nsw i8 %0, 48
br label %13
8: ; preds = %1
%9 = add i8 %0, -10
%10 = icmp ult i8 %9, 6
%11 = add i8 %0, 87
%12 = select i1 %10, i8 %11, i8 0
br label %13
13: ; preds = %8, %6
%14 = phi i8 [ %7, %6 ], [ %12, %8 ]
ret i8 %14
}