#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*/ base4str;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void hex_to_base4(char *hexstr, char *base4str) {
  int i = 0;
  memset(base4str, 0, sizeof(base4str));
  for (i = 0; i < strlen(hexstr); i++) {
    switch (hexstr[i]) {
    case '0':
      strcat(base4str, "00");
      break;
    case '1':
      strcat(base4str, "01");
      break;
    case '2':
      strcat(base4str, "02");
      break;
    case '3':
      strcat(base4str, "03");
      break;
    case '4':
      strcat(base4str, "10");
      break;
    case '5':
      strcat(base4str, "11");
      break;
    case '6':
      strcat(base4str, "12");
      break;
    case '7':
      strcat(base4str, "13");
      break;
    case '8':
      strcat(base4str, "20");
      break;
    case '9':
      strcat(base4str, "21");
      break;
    case 'a':
      strcat(base4str, "22");
      break;
    case 'b':
      strcat(base4str, "23");
      break;
    case 'c':
      strcat(base4str, "30");
      break;
    case 'd':
      strcat(base4str, "31");
      break;
    case 'e':
      strcat(base4str, "32");
      break;
    case 'f':
      strcat(base4str, "33");
      break;
    default:
      printf("Some wierd number is in the key \n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<hex_to_base4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
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    132b <hex_to_base4+0x1eb>
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     130c <hex_to_base4+0x1cc>
mov    -0x20(%rbp),%rax
lea    0xe4d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xf15(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xf03(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xef1(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xedf(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
mov    -0x10(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1060 <strcat@plt>
jmp    1318 <hex_to_base4+0x1d8>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
jmp    131d <hex_to_base4+0x1dd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <hex_to_base4+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_base4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    12fa <hex_to_base4+0x1ba>
xor    %r12d,%r12d
lea    0xe86(%rip),%r13
lea    0xf85(%rip),%rbp
lea    0xf81(%rip),%r15
jmp    11b7 <hex_to_base4+0x77>
lea    0xf7b(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r12
jge    12fa <hex_to_base4+0x1ba>
movsbl (%rbx,%r12,1),%eax
add    $0xffffffd0,%eax
cmp    $0x36,%eax
ja     118a <hex_to_base4+0x4a>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    %r14,%rdi
lea    0xf04(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xef6(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xee8(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xeda(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xecc(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xebb(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xeaa(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe99(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe88(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe77(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe66(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe55(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe44(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
lea    0xe33(%rip),%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
jmp    11a0 <hex_to_base4+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"02\00"
@.str.3 = [3 x i8] c"03\00"
@.str.4 = [3 x i8] c"10\00"
@.str.5 = [3 x i8] c"11\00"
@.str.6 = [3 x i8] c"12\00"
@.str.7 = [3 x i8] c"13\00"
@.str.8 = [3 x i8] c"20\00"
@.str.9 = [3 x i8] c"21\00"
@.str.10 = [3 x i8] c"22\00"
@.str.11 = [3 x i8] c"23\00"
@.str.12 = [3 x i8] c"30\00"
@.str.13 = [3 x i8] c"31\00"
@.str.14 = [3 x i8] c"32\00"
@.str.15 = [3 x i8] c"33\00"
@.str.16 = [34 x i8] c"Some wierd number is in the key \0A\00"
define void @hex_to_base4(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %4
%7 = call i32 @memset(i8* %6, i32 0, i32 8)
store i32 0, i32* %5
br label %8
8: ; preds = %71, %2
%9 = load i32, i32* %5
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %74
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %68 [
i32 48, label %20
i32 49, label %23
i32 50, label %26
i32 51, label %29
i32 52, label %32
i32 53, label %35
i32 54, label %38
i32 55, label %41
i32 56, label %44
i32 57, label %47
i32 97, label %50
i32 98, label %53
i32 99, label %56
i32 100, label %59
i32 101, label %62
i32 102, label %65
]
20: ; preds = %13
%21 = load i8*, i8** %4
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %70
23: ; preds = %13
%24 = load i8*, i8** %4
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %70
26: ; preds = %13
%27 = load i8*, i8** %4
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %70
29: ; preds = %13
%30 = load i8*, i8** %4
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %70
32: ; preds = %13
%33 = load i8*, i8** %4
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %70
35: ; preds = %13
%36 = load i8*, i8** %4
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %70
38: ; preds = %13
%39 = load i8*, i8** %4
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %70
41: ; preds = %13
%42 = load i8*, i8** %4
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %70
44: ; preds = %13
%45 = load i8*, i8** %4
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %70
47: ; preds = %13
%48 = load i8*, i8** %4
%49 = call i32 @strcat(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %70
50: ; preds = %13
%51 = load i8*, i8** %4
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %70
53: ; preds = %13
%54 = load i8*, i8** %4
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %70
56: ; preds = %13
%57 = load i8*, i8** %4
%58 = call i32 @strcat(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %70
59: ; preds = %13
%60 = load i8*, i8** %4
%61 = call i32 @strcat(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %70
62: ; preds = %13
%63 = load i8*, i8** %4
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %70
65: ; preds = %13
%66 = load i8*, i8** %4
%67 = call i32 @strcat(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
br label %70
68: ; preds = %13
%69 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.16, i64 0, i64 0))
br label %70
70: ; preds = %68, %65, %62, %59, %56, %53, %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20
br label %71
71: ; preds = %70
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
store i32 %73, i32* %5
br label %8
74: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"02\00"
@.str.3 = [3 x i8] c"03\00"
@.str.4 = [3 x i8] c"10\00"
@.str.5 = [3 x i8] c"11\00"
@.str.6 = [3 x i8] c"12\00"
@.str.7 = [3 x i8] c"13\00"
@.str.8 = [3 x i8] c"20\00"
@.str.9 = [3 x i8] c"21\00"
@.str.10 = [3 x i8] c"22\00"
@.str.11 = [3 x i8] c"23\00"
@.str.12 = [3 x i8] c"30\00"
@.str.13 = [3 x i8] c"31\00"
@.str.14 = [3 x i8] c"32\00"
@.str.15 = [3 x i8] c"33\00"
@str = [33 x i8] c"Some wierd number is in the key \00"
define void @hex_to_base4(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* %1, i32 0, i32 8)
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %50
6: ; preds = %2, %45
%7 = phi i64 [ %46, %45 ], [ 0, %2 ]
%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 97, label %31
i32 98, label %33
i32 99, label %35
i32 100, label %37
i32 101, label %39
i32 102, label %41
]
11: ; preds = %6
%12 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %45
13: ; preds = %6
%14 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %45
15: ; preds = %6
%16 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %45
17: ; preds = %6
%18 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %45
19: ; preds = %6
%20 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %45
21: ; preds = %6
%22 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %45
23: ; preds = %6
%24 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %45
25: ; preds = %6
%26 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %45
27: ; preds = %6
%28 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %45
29: ; preds = %6
%30 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %45
31: ; preds = %6
%32 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %45
33: ; preds = %6
%34 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %45
35: ; preds = %6
%36 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %45
37: ; preds = %6
%38 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %45
39: ; preds = %6
%40 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %45
41: ; preds = %6
%42 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
br label %45
43: ; preds = %6
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %11, %13, %15, %17, %19, %21, %23, %25, %27, %29, %31, %33, %35, %37, %39, %41, %43
%46 = add nuw nsw i64 %7, 1
%47 = tail call i32 @strlen(i8* %0)
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %6, label %50
50: ; preds = %45, %2
ret void
}