#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 */
typedef int /*<<< orphan*/ input;

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *hex_to_bin(char *input) {
  char *output = (char *)malloc(sizeof(input) * 4);
  int i;
  for (i = 0; i < strlen(input); i++) {
    switch (input[i]) {
    case '0':
      strcat(output, "0000");
      break;
    case '1':
      strcat(output, "0001");
      break;
    case '2':
      strcat(output, "0010");
      break;
    case '3':
      strcat(output, "0011");
      break;
    case '4':
      strcat(output, "0100");
      break;
    case '5':
      strcat(output, "0101");
      break;
    case '6':
      strcat(output, "0110");
      break;
    case '7':
      strcat(output, "0111");
      break;
    case '8':
      strcat(output, "1000");
      break;
    case '9':
      strcat(output, "1001");
      break;
    case 'A':
    case 'a':
      strcat(output, "1010");
      break;
    case 'B':
    case 'b':
      strcat(output, "1011");
      break;
    case 'C':
    case 'c':
      strcat(output, "1100");
      break;
    case 'D':
    case 'd':
      strcat(output, "1101");
      break;
    case 'E':
    case 'e':
      strcat(output, "1110");
      break;
    case 'F':
    case 'f':
      strcat(output, "1111");
      break;
    default:
      printf("¡ERROR!\n");
      printf("No se pudo completar el proceso, debido a que se ingreso un "
             "caracter no hexadecimal\n");
      break;
    }
  }
  return output;
}


x86 assembly (clang, -O0):
<hex_to_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    132a <hex_to_bin+0x1ea>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x36,%eax
ja     12ff <hex_to_bin+0x1bf>
mov    -0x20(%rbp),%rax
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xf22(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xf12(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xf02(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xef2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xee2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1060 <strcat@plt>
jmp    1317 <hex_to_bin+0x1d7>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
jmp    131c <hex_to_bin+0x1dc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <hex_to_bin+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    12a8 <hex_to_bin+0x168>
xor    %r13d,%r13d
lea    0xe8b(%rip),%rbp
lea    0xfa6(%rip),%r15
lea    0xfa4(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx,%r13,1),%eax
add    $0xffffffd0,%eax
cmp    $0x36,%eax
ja     128e <hex_to_bin+0x14e>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r14,%rdi
lea    0xf59(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xf4f(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xf45(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xf3b(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
mov    %r15,%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
mov    %r12,%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xed8(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xed1(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xeca(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xec3(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xebc(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xeb5(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xeae(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xea7(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xea0(%rip),%rsi
jmp    1270 <hex_to_bin+0x130>
mov    %r14,%rdi
lea    0xe99(%rip),%rsi
call   1060 <strcat@plt>
add    $0x1,%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r13
jl     1190 <hex_to_bin+0x50>
jmp    12a8 <hex_to_bin+0x168>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
jmp    1275 <hex_to_bin+0x135>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@.str.16 = [10 x i8] c"\C2\A1ERROR!\0A\00"
@.str.17 = [85 x i8] c"No se pudo completar el proceso, debido a que se ingreso un caracter no hexadecimal\0A\00"
define i8* @hex_to_bin(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i64 @malloc(i32 32)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
store i32 0, i32* %4
br label %7
7: ; preds = %71, %1
%8 = load i32, i32* %4
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %74
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %67 [
i32 48, label %19
i32 49, label %22
i32 50, label %25
i32 51, label %28
i32 52, label %31
i32 53, label %34
i32 54, label %37
i32 55, label %40
i32 56, label %43
i32 57, label %46
i32 65, label %49
i32 97, label %49
i32 66, label %52
i32 98, label %52
i32 67, label %55
i32 99, label %55
i32 68, label %58
i32 100, label %58
i32 69, label %61
i32 101, label %61
i32 70, label %64
i32 102, label %64
]
19: ; preds = %12
%20 = load i8*, i8** %3
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %70
22: ; preds = %12
%23 = load i8*, i8** %3
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %70
25: ; preds = %12
%26 = load i8*, i8** %3
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %70
28: ; preds = %12
%29 = load i8*, i8** %3
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %70
31: ; preds = %12
%32 = load i8*, i8** %3
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %70
34: ; preds = %12
%35 = load i8*, i8** %3
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %70
37: ; preds = %12
%38 = load i8*, i8** %3
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %70
40: ; preds = %12
%41 = load i8*, i8** %3
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %70
43: ; preds = %12
%44 = load i8*, i8** %3
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %70
46: ; preds = %12
%47 = load i8*, i8** %3
%48 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %70
49: ; preds = %12, %12
%50 = load i8*, i8** %3
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %70
52: ; preds = %12, %12
%53 = load i8*, i8** %3
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %70
55: ; preds = %12, %12
%56 = load i8*, i8** %3
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %70
58: ; preds = %12, %12
%59 = load i8*, i8** %3
%60 = call i32 @strcat(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %70
61: ; preds = %12, %12
%62 = load i8*, i8** %3
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %70
64: ; preds = %12, %12
%65 = load i8*, i8** %3
%66 = call i32 @strcat(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
br label %70
67: ; preds = %12
%68 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%69 = call i32 @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.17, i64 0, i64 0))
br label %70
70: ; preds = %67, %64, %61, %58, %55, %52, %49, %46, %43, %40, %37, %34, %31, %28, %25, %22, %19
br label %71
71: ; preds = %70
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %7
74: ; preds = %7
%75 = load i8*, i8** %3
ret i8* %75
}

LLVM IR (-O2):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@str = [9 x i8] c"\C2\A1ERROR!\00"
@str.18 = [84 x i8] c"No se pudo completar el proceso, debido a que se ingreso un caracter no hexadecimal\00"
define i8* @hex_to_bin(i8* %0) {
%2 = tail call i64 @malloc(i32 32)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %51
6: ; preds = %1, %46
%7 = phi i64 [ %47, %46 ], [ 0, %1 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %43 [
i32 48, label %11
i32 49, label %13
i32 50, label %15
i32 51, label %17
i32 52, label %19
i32 53, label %21
i32 54, label %23
i32 55, label %25
i32 56, label %27
i32 57, label %29
i32 65, label %31
i32 97, label %31
i32 66, label %33
i32 98, label %33
i32 67, label %35
i32 99, label %35
i32 68, label %37
i32 100, label %37
i32 69, label %39
i32 101, label %39
i32 70, label %41
i32 102, label %41
]
11: ; preds = %6
%12 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %46
13: ; preds = %6
%14 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %46
15: ; preds = %6
%16 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %46
17: ; preds = %6
%18 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %46
19: ; preds = %6
%20 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %46
21: ; preds = %6
%22 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %46
23: ; preds = %6
%24 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %46
25: ; preds = %6
%26 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %46
27: ; preds = %6
%28 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %46
29: ; preds = %6
%30 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %46
31: ; preds = %6, %6
%32 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %46
33: ; preds = %6, %6
%34 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %46
35: ; preds = %6, %6
%36 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %46
37: ; preds = %6, %6
%38 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %46
39: ; preds = %6, %6
%40 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %46
41: ; preds = %6, %6
%42 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
br label %46
43: ; preds = %6
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str.18, i64 0, i64 0))
br label %46
46: ; preds = %11, %13, %15, %17, %19, %21, %23, %25, %27, %29, %31, %33, %35, %37, %39, %41, %43
%47 = add nuw nsw i64 %7, 1
%48 = tail call i32 @strlen(i8* %0)
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %6, label %51
51: ; preds = %46, %1
ret i8* %3
}