#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 hex(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  printf("This app is to convert from Decimal to Hexadecimal\n");
  int n;
l1:
  printf("\nEnter a Number between 1 - 15: ");
  scanf("%d", &n);
  if (n >= 0 && n < 16) {
    printf("The Hexadecimal form is: %c\n", hex(n));
    goto l2;
  } else
    printf("You Exceeded your limit.\n");
  printf("Try Again.....\n");
  goto l1;
l2:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     119c <main+0x6c>
cmpl   $0x10,-0x8(%rbp)
jge    119c <main+0x6c>
mov    -0x8(%rbp),%edi
call   1050 <hex@plt>
mov    %eax,%esi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x8d>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0x10,%edi
jb     11de <main+0x9e>
lea    0xeec(%rip),%r14
lea    0xefe(%rip),%r15
lea    0xe6a(%rip),%r12
lea    0xe84(%rip),%r13
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0x10,%edi
jae    11b0 <main+0x70>
call   1060 <hex@plt>
lea    0xe3a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"This app is to convert from Decimal to Hexadecimal\0A\00"
@.str.1 = [33 x i8] c"\0AEnter a Number between 1 - 15: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"The Hexadecimal form is: %c\0A\00"
@.str.4 = [26 x i8] c"You Exceeded your limit.\0A\00"
@.str.5 = [16 x i8] c"Try Again.....\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %18, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 @hex(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %20
16: ; preds = %9, %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %4
20: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [33 x i8] c"\0AEnter a Number between 1 - 15: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"The Hexadecimal form is: %c\0A\00"
@str = [51 x i8] c"This app is to convert from Decimal to Hexadecimal\00"
@str.6 = [25 x i8] c"You Exceeded your limit.\00"
@str.7 = [15 x i8] c"Try Again.....\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp ult i32 %6, 16
br i1 %7, label %8, label %12
8: ; preds = %12, %0
%9 = phi i32 [ %6, %0 ], [ %17, %12 ]
%10 = call i32 @hex(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %10)
ret i32 0
12: ; preds = %0, %12
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = icmp ult i32 %17, 16
br i1 %18, label %8, label %12
}