#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;
  int error = 0;
  int error1 = 0;
  int error2 = 0;
  while (!(car1 == 'q' && car2 == 'q')) {
    printf("Introduzca dos cifras en hexadecimal:");
    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;
    else
      error1 = 1;
    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
      error2 = 2;
    error = error1 + error2;
    if (error != 0) {
      switch (error) {
      case 1:
        printf("El primer carácter introducido no es váildo\n");
        break;
      case 2:
        printf("El segundo carácter introducido no es válido\n");
        break;
      case 3:
        printf("Los dos carácteres introducidos no son válidos\n");
        break;
      }
    } else {
      valor = 16 * valor1 + valor2;
      printf("El valor decimal de 0x%c%c es %d\n", car1, car2, valor);
    }
    error = error1 = error2 = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x71,%ecx
mov    %al,-0x21(%rbp)
jne    1163 <main+0x43>
movsbl -0x6(%rbp),%eax
cmp    $0x71,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    1175 <main+0x55>
jmp    137c <main+0x25c>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0x6(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     11c0 <main+0xa0>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     11c0 <main+0xa0>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    1229 <main+0x109>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11ec <main+0xcc>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     11ec <main+0xcc>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    1224 <main+0x104>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1218 <main+0xf8>
movsbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     1218 <main+0xf8>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    121f <main+0xff>
movl   $0x1,-0x1c(%rbp)
jmp    1224 <main+0x104>
jmp    1229 <main+0x109>
movsbl -0x6(%rbp),%eax
cmp    $0x30,%eax
jl     1252 <main+0x132>
movsbl -0x6(%rbp),%eax
cmp    $0x39,%eax
jg     1252 <main+0x132>
movsbl -0x6(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    12bb <main+0x19b>
movsbl -0x6(%rbp),%eax
cmp    $0x61,%eax
jl     127e <main+0x15e>
movsbl -0x6(%rbp),%eax
cmp    $0x66,%eax
jg     127e <main+0x15e>
movsbl -0x6(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x10(%rbp)
jmp    12b6 <main+0x196>
movsbl -0x6(%rbp),%eax
cmp    $0x41,%eax
jl     12aa <main+0x18a>
movsbl -0x6(%rbp),%eax
cmp    $0x46,%eax
jg     12aa <main+0x18a>
movsbl -0x6(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x10(%rbp)
jmp    12b1 <main+0x191>
movl   $0x2,-0x20(%rbp)
jmp    12b6 <main+0x196>
jmp    12bb <main+0x19b>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     133d <main+0x21d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     1304 <main+0x1e4>
jmp    12e2 <main+0x1c2>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     1317 <main+0x1f7>
jmp    12f3 <main+0x1d3>
mov    -0x28(%rbp),%eax
sub    $0x3,%eax
je     132a <main+0x20a>
jmp    1338 <main+0x218>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1338 <main+0x218>
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1338 <main+0x218>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1362 <main+0x242>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsbl -0x5(%rbp),%esi
movsbl -0x6(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Introduzca dos cifras en hexadecimal:\00"
@.str.1 = [6 x i8] c"\0A%c%c\00"
@.str.2 = [47 x i8] c"El primer car\C3\A1cter introducido no es v\C3\A1ildo\0A\00"
@.str.3 = [48 x i8] c"El segundo car\C3\A1cter introducido no es v\C3\A1lido\0A\00"
@.str.4 = [50 x i8] c"Los dos car\C3\A1cteres introducidos no son v\C3\A1lidos\0A\00"
@.str.5 = [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
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %131, %0
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 113
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 113
br label %18
18: ; preds = %14, %10
%19 = phi i1 [ false, %10 ], [ %17, %14 ]
%20 = xor i1 %19, true
br i1 %20, label %21, label %132
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3)
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 48
br i1 %26, label %27, label %35
27: ; preds = %21
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 57
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
store i32 %34, i32* %4
br label %64
35: ; preds = %27, %21
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = icmp sge i32 %37, 97
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = load i8, i8* %2
%41 = sext i8 %40 to i32
%42 = icmp sle i32 %41, 102
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load i8, i8* %2
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 97
%47 = add nsw i32 %46, 10
store i32 %47, i32* %4
br label %63
48: ; preds = %39, %35
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = icmp sge i32 %50, 65
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = load i8, i8* %2
%54 = sext i8 %53 to i32
%55 = icmp sle i32 %54, 70
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8, i8* %2
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 65
%60 = add nsw i32 %59, 10
store i32 %60, i32* %4
br label %62
61: ; preds = %52, %48
store i32 1, i32* %8
br label %62
62: ; preds = %61, %56
br label %63
63: ; preds = %62, %43
br label %64
64: ; preds = %63, %31
%65 = load i8, i8* %3
%66 = sext i8 %65 to i32
%67 = icmp sge i32 %66, 48
br i1 %67, label %68, label %76
68: ; preds = %64
%69 = load i8, i8* %3
%70 = sext i8 %69 to i32
%71 = icmp sle i32 %70, 57
br i1 %71, label %72, label %76
72: ; preds = %68
%73 = load i8, i8* %3
%74 = sext i8 %73 to i32
%75 = sub nsw i32 %74, 48
store i32 %75, i32* %5
br label %105
76: ; preds = %68, %64
%77 = load i8, i8* %3
%78 = sext i8 %77 to i32
%79 = icmp sge i32 %78, 97
br i1 %79, label %80, label %89
80: ; preds = %76
%81 = load i8, i8* %3
%82 = sext i8 %81 to i32
%83 = icmp sle i32 %82, 102
br i1 %83, label %84, label %89
84: ; preds = %80
%85 = load i8, i8* %3
%86 = sext i8 %85 to i32
%87 = sub nsw i32 %86, 97
%88 = add nsw i32 %87, 10
store i32 %88, i32* %5
br label %104
89: ; preds = %80, %76
%90 = load i8, i8* %3
%91 = sext i8 %90 to i32
%92 = icmp sge i32 %91, 65
br i1 %92, label %93, label %102
93: ; preds = %89
%94 = load i8, i8* %3
%95 = sext i8 %94 to i32
%96 = icmp sle i32 %95, 70
br i1 %96, label %97, label %102
97: ; preds = %93
%98 = load i8, i8* %3
%99 = sext i8 %98 to i32
%100 = sub nsw i32 %99, 65
%101 = add nsw i32 %100, 10
store i32 %101, i32* %5
br label %103
102: ; preds = %93, %89
store i32 2, i32* %9
br label %103
103: ; preds = %102, %97
br label %104
104: ; preds = %103, %84
br label %105
105: ; preds = %104, %72
%106 = load i32, i32* %8
%107 = load i32, i32* %9
%108 = add nsw i32 %106, %107
store i32 %108, i32* %7
%109 = load i32, i32* %7
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %120
111: ; preds = %105
%112 = load i32, i32* %7
switch i32 %112, label %119 [
i32 1, label %113
i32 2, label %115
i32 3, label %117
]
113: ; preds = %111
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %119
115: ; preds = %111
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
br label %119
117: ; preds = %111
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
br label %119
119: ; preds = %111, %117, %115, %113
br label %131
120: ; preds = %105
%121 = load i32, i32* %4
%122 = mul nsw i32 16, %121
%123 = load i32, i32* %5
%124 = add nsw i32 %122, %123
store i32 %124, i32* %6
%125 = load i8, i8* %2
%126 = sext i8 %125 to i32
%127 = load i8, i8* %3
%128 = sext i8 %127 to i32
%129 = load i32, i32* %6
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %126, i32 %128, i32 %129)
br label %131
131: ; preds = %120, %119
store i32 0, i32* %9
store i32 0, i32* %8
store i32 0, i32* %7
br label %10
132: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}