#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 */
char num_to_char(int);
char choose_hex_number(int num) {
  if (num < 10) {
    return num_to_char(num);
  } else if (num == 10) {
    return 'A';
  } else if (num == 11) {
    return 'B';
  } else if (num == 12) {
    return 'C';
  } else if (num == 13) {
    return 'D';
  } else if (num == 14) {
    return 'E';
  } else {
    return 'F';
  }
}


x86 assembly (clang, -O0):
<choose_hex_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1135 <choose_hex_number+0x25>
mov    -0x8(%rbp),%edi
call   1030 <num_to_char@plt>
mov    %al,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
cmpl   $0xa,-0x8(%rbp)
jne    1148 <choose_hex_number+0x38>
movb   $0x41,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
cmpl   $0xb,-0x8(%rbp)
jne    115b <choose_hex_number+0x4b>
movb   $0x42,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
cmpl   $0xc,-0x8(%rbp)
jne    116e <choose_hex_number+0x5e>
movb   $0x43,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
cmpl   $0xd,-0x8(%rbp)
jne    1181 <choose_hex_number+0x71>
movb   $0x44,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
cmpl   $0xe,-0x8(%rbp)
jne    1194 <choose_hex_number+0x84>
movb   $0x45,-0x1(%rbp)
jmp    1198 <choose_hex_number+0x88>
movb   $0x46,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_hex_number>:
cmp    $0x9,%edi
jg     111a <choose_hex_number+0xa>
jmp    1030 <num_to_char@plt>
add    $0xfffffff6,%edi
mov    $0x46,%al
cmp    $0x4,%edi
ja     112a <choose_hex_number+0x1a>
add    $0x41,%dil
mov    %edi,%eax
ret

LLVM IR (-O0):
define signext i8 @choose_hex_number(i32 %0) {
%2 = alloca i8
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call signext i8 @num_to_char(i32 %7)
store i8 %8, i8* %2
br label %30
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %9
store i8 65, i8* %2
br label %30
13: ; preds = %9
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 11
br i1 %15, label %16, label %17
16: ; preds = %13
store i8 66, i8* %2
br label %30
17: ; preds = %13
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 12
br i1 %19, label %20, label %21
20: ; preds = %17
store i8 67, i8* %2
br label %30
21: ; preds = %17
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 13
br i1 %23, label %24, label %25
24: ; preds = %21
store i8 68, i8* %2
br label %30
25: ; preds = %21
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 14
br i1 %27, label %28, label %29
28: ; preds = %25
store i8 69, i8* %2
br label %30
29: ; preds = %25
store i8 70, i8* %2
br label %30
30: ; preds = %29, %28, %24, %20, %16, %12, %6
%31 = load i8, i8* %2
ret i8 %31
}

LLVM IR (-O2):
define signext i8 @choose_hex_number(i32 %0) {
%2 = icmp slt i32 %0, 10
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call signext i8 @num_to_char(i32 %0)
br label %11
5: ; preds = %1
%6 = add i32 %0, -10
%7 = icmp ult i32 %6, 5
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = trunc i32 %6 to i8
%10 = add i8 %9, 65
br label %11
11: ; preds = %5, %8, %3
%12 = phi i8 [ %4, %3 ], [ %10, %8 ], [ 70, %5 ]
ret i8 %12
}