void led_putnum(num) char num;
{
  static unsigned char *leds = (unsigned char *)0xd00003;
  static unsigned char num_bits[18] = {0xff, 0xc0, 0xf9, 0xa4, 0xb0, 0x99,
                                       0x92, 0x82, 0xf8, 0x80, 0x98, 0x98,
                                       0x20, 0x3,  0x27, 0x21, 0x4,  0xe};
  if (num >= '0' && num <= '9')
    num = (num - '0') + 1;
  if (num >= 'a' && num <= 'f')
    num = (num - 'a') + 12;
  if (num == ' ')
    num = 0;
  *leds = num_bits[num];
}


x86 assembly (clang, -O0):
<led_putnum>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1131 <led_putnum+0x31>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     1131 <led_putnum+0x31>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
add    $0x1,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jl     1158 <led_putnum+0x58>
movsbl -0x1(%rbp),%eax
cmp    $0x66,%eax
jg     1158 <led_putnum+0x58>
movsbl -0x1(%rbp),%eax
sub    $0x61,%eax
add    $0xc,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x20,%eax
jne    1169 <led_putnum+0x69>
movb   $0x0,-0x1(%rbp)
movsbq -0x1(%rbp),%rcx
lea    0x2ecb(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    0x2eb1(%rip),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_putnum>:
mov    %edi,%eax
shl    $0x18,%eax
add    $0xd0ffffff,%eax
movsbl %dil,%ecx
add    $0xffffffd1,%ecx
cmp    $0xaffffff,%eax
cmovae %edi,%ecx
mov    %ecx,%eax
shl    $0x18,%eax
add    $0x9fffffff,%eax
movsbl %cl,%edx
add    $0xffffffab,%edx
cmp    $0x6ffffff,%eax
cmovae %ecx,%edx
xor    %eax,%eax
cmp    $0x20,%dl
movsbq %dl,%rcx
cmovne %rcx,%rax
lea    0xebb(%rip),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,0xd00003
ret

LLVM IR (-O0):
@led_putnum.leds = internal global i8* inttoptr (i64 13631491 to i8*)
@led_putnum.num_bits = internal global [18 x i8] c"\FF\C0\F9\A4\B0\99\92\82\F8\80\98\98 \03'!\04\0E"
define void @led_putnum(i32 %0) {
%2 = alloca i8
%3 = trunc i32 %0 to i8
store i8 %3, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 48
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 57
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
%15 = add nsw i32 %14, 1
%16 = trunc i32 %15 to i8
store i8 %16, i8* %2
br label %17
17: ; preds = %11, %7, %1
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %19, 97
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 102
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 97
%29 = add nsw i32 %28, 12
%30 = trunc i32 %29 to i8
store i8 %30, i8* %2
br label %31
31: ; preds = %25, %21, %17
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 32
br i1 %34, label %35, label %36
35: ; preds = %31
store i8 0, i8* %2
br label %36
36: ; preds = %35, %31
%37 = load i8, i8* %2
%38 = sext i8 %37 to i64
%39 = getelementptr inbounds [18 x i8], [18 x i8]* @led_putnum.num_bits, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** @led_putnum.leds
store i8 %40, i8* %41
ret void
}

LLVM IR (-O2):
@led_putnum.num_bits = internal unnamed_addr constant [18 x i8] c"\FF\C0\F9\A4\B0\99\92\82\F8\80\98\98 \03'!\04\0E"
define void @led_putnum(i32 %0) {
%2 = shl i32 %0, 24
%3 = add i32 %2, -788529153
%4 = icmp ult i32 %3, 184549375
%5 = ashr exact i32 %2, 24
%6 = add nsw i32 %5, -47
%7 = select i1 %4, i32 %6, i32 %0
%8 = shl i32 %7, 24
%9 = add i32 %8, -1610612737
%10 = icmp ult i32 %9, 117440511
%11 = ashr exact i32 %8, 24
%12 = add nsw i32 %11, -85
%13 = select i1 %10, i32 %12, i32 %7
%14 = zext i32 %13 to i64
%15 = and i32 %13, 255
%16 = icmp eq i32 %15, 32
%17 = shl i64 %14, 56
%18 = ashr exact i64 %17, 56
%19 = select i1 %16, i64 0, i64 %18
%20 = getelementptr inbounds [18 x i8], [18 x i8]* @led_putnum.num_bits, i64 0, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* inttoptr (i64 13631491 to i8*)
ret void
}