char charToLettre(char valeur) {
  switch (valeur) {
  case 0:
    return '0';
    break;
  case 1:
    return '1';
    break;
  case 2:
    return '2';
    break;
  case 3:
    return '3';
    break;
  case 4:
    return '4';
    break;
  case 5:
    return '5';
    break;
  case 6:
    return '6';
    break;
  case 7:
    return '7';
    break;
  case 8:
    return '8';
    break;
  case 9:
    return '9';
    break;
  case 10:
    return 'a';
    break;
  case 11:
    return 'b';
    break;
  case 12:
    return 'c';
  case 13:
    return 'd';
    break;
  case 14:
    return 'e';
    break;
  case 15:
    return 'f';
    break;
  }
}


x86 assembly (clang, -O0):
<charToLettre>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xf,%eax
ja     11bc <charToLettre+0xbc>
mov    -0x10(%rbp),%rax
lea    0xed8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x30,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x31,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x32,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x33,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x34,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x35,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x36,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x37,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x38,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x39,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x61,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x62,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x63,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x64,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x65,-0x1(%rbp)
jmp    11bc <charToLettre+0xbc>
movb   $0x66,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<charToLettre>:
movslq %edi,%rcx
add    $0xffffffffffffffff,%rcx
mov    $0x30,%al
cmp    $0xe,%ecx
ja     1118 <charToLettre+0x18>
lea    0xeeb(%rip),%rax
mov    (%rcx,%rax,1),%al
ret

LLVM IR (-O0):
define signext i8 @charToLettre(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
switch i32 %5, label %22 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
i32 8, label %14
i32 9, label %15
i32 10, label %16
i32 11, label %17
i32 12, label %18
i32 13, label %19
i32 14, label %20
i32 15, label %21
]
6: ; preds = %1
store i8 48, i8* %2
br label %22
7: ; preds = %1
store i8 49, i8* %2
br label %22
8: ; preds = %1
store i8 50, i8* %2
br label %22
9: ; preds = %1
store i8 51, i8* %2
br label %22
10: ; preds = %1
store i8 52, i8* %2
br label %22
11: ; preds = %1
store i8 53, i8* %2
br label %22
12: ; preds = %1
store i8 54, i8* %2
br label %22
13: ; preds = %1
store i8 55, i8* %2
br label %22
14: ; preds = %1
store i8 56, i8* %2
br label %22
15: ; preds = %1
store i8 57, i8* %2
br label %22
16: ; preds = %1
store i8 97, i8* %2
br label %22
17: ; preds = %1
store i8 98, i8* %2
br label %22
18: ; preds = %1
store i8 99, i8* %2
br label %22
19: ; preds = %1
store i8 100, i8* %2
br label %22
20: ; preds = %1
store i8 101, i8* %2
br label %22
21: ; preds = %1
store i8 102, i8* %2
br label %22
22: ; preds = %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %1
%23 = load i8, i8* %2
ret i8 %23
}

LLVM IR (-O2):
@switch.table.charToLettre = [15 x i8] c"123456789abcdef"
define signext i8 @charToLettre(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -1
%4 = icmp ult i32 %3, 15
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [15 x i8], [15 x i8]* @switch.table.charToLettre, i64 0, i64 %6
%8 = load i8, i8* %7
br label %9
9: ; preds = %5, %1
%10 = phi i8 [ 48, %1 ], [ %8, %5 ]
ret i8 %10
}