#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 strtol(char *, int /*<<< orphan*/ *, int);
char *get_rr(char *type) {
  switch (strtol(type, NULL, 16)) {
  case 1:
    return "A";
    break;
  case 2:
    return "NS";
    break;
  case 5:
    return "CNAME";
    break;
  case 6:
    return "SOA";
    break;
  case 12:
    return "PTR";
    break;
  case 13:
    return "HINFO";
    break;
  case 15:
    return "MX";
    break;
  case 16:
    return "TXT";
    break;
  case 17:
    return "RP";
    break;
  case 24:
    return "SIG";
    break;
  case 25:
    return "KEY";
    break;
  case 28:
    return "AAAA";
    break;
  case 252:
    return "AXFR";
    break;
  case 255:
    return "ANY";
    break;
  default:
    return type;
    break;
  }
}


x86 assembly (clang, -O0):
<get_rr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0x1,%eax
je     1222 <get_rr+0x112>
jmp    1141 <get_rr+0x31>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1232 <get_rr+0x122>
jmp    1152 <get_rr+0x42>
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
je     1242 <get_rr+0x132>
jmp    1163 <get_rr+0x53>
mov    -0x14(%rbp),%eax
sub    $0x6,%eax
je     1252 <get_rr+0x142>
jmp    1174 <get_rr+0x64>
mov    -0x14(%rbp),%eax
sub    $0xc,%eax
je     1262 <get_rr+0x152>
jmp    1185 <get_rr+0x75>
mov    -0x14(%rbp),%eax
sub    $0xd,%eax
je     1272 <get_rr+0x162>
jmp    1196 <get_rr+0x86>
mov    -0x14(%rbp),%eax
sub    $0xf,%eax
je     1282 <get_rr+0x172>
jmp    11a7 <get_rr+0x97>
mov    -0x14(%rbp),%eax
sub    $0x10,%eax
je     1292 <get_rr+0x182>
jmp    11b8 <get_rr+0xa8>
mov    -0x14(%rbp),%eax
sub    $0x11,%eax
je     12a2 <get_rr+0x192>
jmp    11c9 <get_rr+0xb9>
mov    -0x14(%rbp),%eax
sub    $0x18,%eax
je     12b2 <get_rr+0x1a2>
jmp    11da <get_rr+0xca>
mov    -0x14(%rbp),%eax
sub    $0x19,%eax
je     12c2 <get_rr+0x1b2>
jmp    11eb <get_rr+0xdb>
mov    -0x14(%rbp),%eax
sub    $0x1c,%eax
je     12d2 <get_rr+0x1c2>
jmp    11fc <get_rr+0xec>
mov    -0x14(%rbp),%eax
sub    $0xfc,%eax
je     12e2 <get_rr+0x1d2>
jmp    120f <get_rr+0xff>
mov    -0x14(%rbp),%eax
sub    $0xff,%eax
je     12f2 <get_rr+0x1e2>
jmp    1302 <get_rr+0x1f2>
lea    0xe03(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xdc7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xdba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xdb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xda4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd8e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd68(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd5c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd50(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
lea    0xd3a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130a <get_rr+0x1fa>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rr>:
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
lea    -0x1(%rax),%ecx
cmp    $0x1b,%ecx
ja     1148 <get_rr+0x38>
lea    0xf6d(%rip),%rax
lea    0xeca(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf2a(%rip),%rax
pop    %rbx
ret
cmp    $0xfc,%eax
je     11be <get_rr+0xae>
cmp    $0xff,%eax
jne    115f <get_rr+0x4f>
lea    0xf46(%rip),%rax
pop    %rbx
ret
mov    %rbx,%rax
pop    %rbx
ret
lea    0xf08(%rip),%rax
pop    %rbx
ret
lea    0xf05(%rip),%rax
pop    %rbx
ret
lea    0xf00(%rip),%rax
pop    %rbx
ret
lea    0xefb(%rip),%rax
pop    %rbx
ret
lea    0xef8(%rip),%rax
pop    %rbx
ret
lea    0xef2(%rip),%rax
pop    %rbx
ret
lea    0xeed(%rip),%rax
pop    %rbx
ret
lea    0xee7(%rip),%rax
pop    %rbx
ret
lea    0xee2(%rip),%rax
pop    %rbx
ret
lea    0xedd(%rip),%rax
pop    %rbx
ret
lea    0xed9(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"NS\00"
@.str.2 = [6 x i8] c"CNAME\00"
@.str.3 = [4 x i8] c"SOA\00"
@.str.4 = [4 x i8] c"PTR\00"
@.str.5 = [6 x i8] c"HINFO\00"
@.str.6 = [3 x i8] c"MX\00"
@.str.7 = [4 x i8] c"TXT\00"
@.str.8 = [3 x i8] c"RP\00"
@.str.9 = [4 x i8] c"SIG\00"
@.str.10 = [4 x i8] c"KEY\00"
@.str.11 = [5 x i8] c"AAAA\00"
@.str.12 = [5 x i8] c"AXFR\00"
@.str.13 = [4 x i8] c"ANY\00"
define i8* @get_rr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strtol(i8* %4, i32* null, i32 16)
switch i32 %5, label %20 [
i32 1, label %6
i32 2, label %7
i32 5, label %8
i32 6, label %9
i32 12, label %10
i32 13, label %11
i32 15, label %12
i32 16, label %13
i32 17, label %14
i32 24, label %15
i32 25, label %16
i32 28, label %17
i32 252, label %18
i32 255, label %19
]
6: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
7: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %22
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %22
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %22
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %22
11: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %22
12: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %22
13: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %22
14: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %22
15: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %22
16: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %22
17: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %22
18: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %22
19: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %22
20: ; preds = %1
%21 = load i8*, i8** %3
store i8* %21, i8** %2
br label %22
22: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"NS\00"
@.str.2 = [6 x i8] c"CNAME\00"
@.str.3 = [4 x i8] c"SOA\00"
@.str.4 = [4 x i8] c"PTR\00"
@.str.5 = [6 x i8] c"HINFO\00"
@.str.6 = [3 x i8] c"MX\00"
@.str.7 = [4 x i8] c"TXT\00"
@.str.8 = [3 x i8] c"RP\00"
@.str.9 = [4 x i8] c"SIG\00"
@.str.10 = [4 x i8] c"KEY\00"
@.str.11 = [5 x i8] c"AAAA\00"
@.str.12 = [5 x i8] c"AXFR\00"
@.str.13 = [4 x i8] c"ANY\00"
define i8* @get_rr(i8* %0) {
%2 = tail call i32 @strtol(i8* nocapture %0, i32* null, i32 16)
switch i32 %2, label %16 [
i32 1, label %17
i32 2, label %3
i32 5, label %4
i32 6, label %5
i32 12, label %6
i32 13, label %7
i32 15, label %8
i32 16, label %9
i32 17, label %10
i32 24, label %11
i32 25, label %12
i32 28, label %13
i32 252, label %14
i32 255, label %15
]
3: ; preds = %1
br label %17
4: ; preds = %1
br label %17
5: ; preds = %1
br label %17
6: ; preds = %1
br label %17
7: ; preds = %1
br label %17
8: ; preds = %1
br label %17
9: ; preds = %1
br label %17
10: ; preds = %1
br label %17
11: ; preds = %1
br label %17
12: ; preds = %1
br label %17
13: ; preds = %1
br label %17
14: ; preds = %1
br label %17
15: ; preds = %1
br label %17
16: ; preds = %1
br label %17
17: ; preds = %1, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%18 = phi i8* [ %0, %16 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %18
}