#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 *, char *);
int main() {
  char car1;
  char car2;
  int valor1;
  int valor2;
  int valor;
  printf("Introduzca dos cifras en hexadecimal válidas:");
  scanf("\n%c%c", &car1, &car2);
  if (car1 >= '0' && car1 <= '9')
    valor1 = car1 - '0';
  else if (car1 >= 'a' && car1 <= 'f')
    valor1 = car1 - 'a' + 10;
  else if (car1 >= 'A' && car1 <= 'F')
    valor1 = car1 - 'A' + 10;
  if (car2 >= '0' && car2 <= '9')
    valor2 = car2 - '0';
  else if (car2 >= 'a' && car2 <= 'f')
    valor2 = car2 - 'a' + 10;
  else if (car2 >= 'A' && car2 <= 'F')
    valor2 = car2 - 'A' + 10;
  else
    valor = 16 * valor1 + valor2;
  printf("El valor decimal de 0x%c%c es %d\n", car1, car2, valor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0x6(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     117a <main+0x5a>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     117a <main+0x5a>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    11d7 <main+0xb7>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11a6 <main+0x86>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     11a6 <main+0x86>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    11d2 <main+0xb2>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     11cd <main+0xad>
movsbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     11cd <main+0xad>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    11d2 <main+0xb2>
jmp    11d7 <main+0xb7>
movsbl -0x6(%rbp),%eax
cmp    $0x30,%eax
jl     1200 <main+0xe0>
movsbl -0x6(%rbp),%eax
cmp    $0x39,%eax
jg     1200 <main+0xe0>
movsbl -0x6(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    126e <main+0x14e>
movsbl -0x6(%rbp),%eax
cmp    $0x61,%eax
jl     122c <main+0x10c>
movsbl -0x6(%rbp),%eax
cmp    $0x66,%eax
jg     122c <main+0x10c>
movsbl -0x6(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x10(%rbp)
jmp    1269 <main+0x149>
movsbl -0x6(%rbp),%eax
cmp    $0x41,%eax
jl     1258 <main+0x138>
movsbl -0x6(%rbp),%eax
cmp    $0x46,%eax
jg     1258 <main+0x138>
movsbl -0x6(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x10(%rbp)
jmp    1264 <main+0x144>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1269 <main+0x149>
jmp    126e <main+0x14e>
movsbl -0x5(%rbp),%esi
movsbl -0x6(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    0x7(%rsp),%rsi
lea    0x6(%rsp),%rdx
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%esi
movsbl 0x6(%rsp),%edx
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Introduzca dos cifras en hexadecimal v\C3\A1lidas:\00"
@.str.1 = [6 x i8] c"\0A%c%c\00"
@.str.2 = [34 x i8] c"El valor decimal de 0x%c%c es %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp sge i32 %10, 48
br i1 %11, label %12, label %20
12: ; preds = %0
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp sle i32 %14, 57
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = sub nsw i32 %18, 48
store i32 %19, i32* %4
br label %48
20: ; preds = %12, %0
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp sge i32 %22, 97
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
%27 = icmp sle i32 %26, 102
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 97
%32 = add nsw i32 %31, 10
store i32 %32, i32* %4
br label %47
33: ; preds = %24, %20
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 65
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
%40 = icmp sle i32 %39, 70
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = sub nsw i32 %43, 65
%45 = add nsw i32 %44, 10
store i32 %45, i32* %4
br label %46
46: ; preds = %41, %37, %33
br label %47
47: ; preds = %46, %28
br label %48
48: ; preds = %47, %16
%49 = load i8, i8* %3
%50 = sext i8 %49 to i32
%51 = icmp sge i32 %50, 48
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8, i8* %3
%54 = sext i8 %53 to i32
%55 = icmp sle i32 %54, 57
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = load i8, i8* %3
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 48
store i32 %59, i32* %5
br label %93
60: ; preds = %52, %48
%61 = load i8, i8* %3
%62 = sext i8 %61 to i32
%63 = icmp sge i32 %62, 97
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i8, i8* %3
%66 = sext i8 %65 to i32
%67 = icmp sle i32 %66, 102
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = load i8, i8* %3
%70 = sext i8 %69 to i32
%71 = sub nsw i32 %70, 97
%72 = add nsw i32 %71, 10
store i32 %72, i32* %5
br label %92
73: ; preds = %64, %60
%74 = load i8, i8* %3
%75 = sext i8 %74 to i32
%76 = icmp sge i32 %75, 65
br i1 %76, label %77, label %86
77: ; preds = %73
%78 = load i8, i8* %3
%79 = sext i8 %78 to i32
%80 = icmp sle i32 %79, 70
br i1 %80, label %81, label %86
81: ; preds = %77
%82 = load i8, i8* %3
%83 = sext i8 %82 to i32
%84 = sub nsw i32 %83, 65
%85 = add nsw i32 %84, 10
store i32 %85, i32* %5
br label %91
86: ; preds = %77, %73
%87 = load i32, i32* %4
%88 = mul nsw i32 16, %87
%89 = load i32, i32* %5
%90 = add nsw i32 %88, %89
store i32 %90, i32* %6
br label %91
91: ; preds = %86, %81
br label %92
92: ; preds = %91, %68
br label %93
93: ; preds = %92, %56
%94 = load i8, i8* %2
%95 = sext i8 %94 to i32
%96 = load i8, i8* %3
%97 = sext i8 %96 to i32
%98 = load i32, i32* %6
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %95, i32 %97, i32 %98)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Introduzca dos cifras en hexadecimal v\C3\A1lidas:\00"
@.str.1 = [6 x i8] c"\0A%c%c\00"
@.str.2 = [34 x i8] c"El valor decimal de 0x%c%c es %d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
%5 = load i8, i8* %1
%6 = load i8, i8* %2
%7 = sext i8 %5 to i32
%8 = sext i8 %6 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8, i32 undef)
ret i32 0
}