#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 EXIT_SUCCESS;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
long long hexToDecimal(char *);
int /*<<< orphan*/ printf(char *, ...);
int removeNewLine(char *);
int /*<<< orphan*/ stdin;
int main() {
  char hexadecimal[15];
  int lineLenght;
  long long decimal;
  printf("Enter hexadecimal integer number: ");
  fgets(hexadecimal, 15, stdin);
  lineLenght = removeNewLine(hexadecimal);
  decimal = hexToDecimal(hexadecimal);
  printf("Decimal = %lld", decimal);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x13(%rbp),%rdi
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
mov    $0xf,%esi
call   1050 <fgets@plt>
lea    -0x13(%rbp),%rdi
call   1060 <removeNewLine@plt>
mov    %eax,-0x18(%rbp)
lea    -0x13(%rbp),%rdi
call   1030 <hexToDecimal@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
lea    0x1(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xf,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <removeNewLine@plt>
mov    %rbx,%rdi
call   1030 <hexToDecimal@plt>
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter hexadecimal integer number: \00"
@stdin = global i32 0
@.str.1 = [15 x i8] c"Decimal = %lld\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 15, i32 %7)
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%10 = call i32 @removeNewLine(i8* %9)
store i32 %10, i32* %3
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%12 = call i64 @hexToDecimal(i8* %11)
store i64 %12, i64* %4
%13 = load i64, i64* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter hexadecimal integer number: \00"
@stdin = global i32 0
@.str.1 = [15 x i8] c"Decimal = %lld\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 15, i32 %4)
%6 = call i32 @removeNewLine(i8* %2)
%7 = call i64 @hexToDecimal(i8* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}