#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ showNum(char, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char segs[] = {0x00, 0x03, 0x79, 0x73, 0x2B, 0x7A, 0x6D, 0x13, 0x7F, 0x3B};
  char val;
  printf("Insert the number to convert: ");
  scanf("%c", &val);
  printf("Converted value: %x\n", segs[(val & 0x0f)]);
  showNum(segs[(val & 0x0f)], 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x1b(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x1b(%rbp),%eax
and    $0xf,%eax
cltq
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x1b(%rbp),%eax
and    $0xf,%eax
cltq
xor    %esi,%esi
movsbl -0x1a(%rbp,%rax,1),%edi
call   1040 <showNum@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xf,%eax
lea    0xe9d(%rip),%rbx
movsbl (%rax,%rbx,1),%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0xf(%rsp),%eax
and    $0xf,%eax
movsbl (%rax,%rbx,1),%edi
xor    %esi,%esi
call   1040 <showNum@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.segs = [10 x i8] c"\00\03ys+zm\13\7F;"
@.str = [31 x i8] c"Insert the number to convert: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Converted value: %x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [10 x i8]
%6 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = bitcast [10 x i8]* %5 to i8*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = load i8, i8* %6
%11 = sext i8 %10 to i32
%12 = and i32 %11, 15
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = and i32 %19, 15
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @showNum(i8 signext %23, i32 0)
ret i32 0
}

LLVM IR (-O2):
@__const.main.segs = [10 x i8] c"\00\03ys+zm\13\7F;"
@.str = [31 x i8] c"Insert the number to convert: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Converted value: %x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = load i8, i8* %3
%7 = and i8 %6, 15
%8 = zext i8 %7 to i64
%9 = getelementptr inbounds [10 x i8], [10 x i8]* @__const.main.segs, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i8, i8* %3
%14 = and i8 %13, 15
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [10 x i8], [10 x i8]* @__const.main.segs, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @showNum(i8 signext %17, i32 0)
ret i32 0
}