#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 */
char const *dtag2str(int);
const char *tag2str(int tag, int num) {
  switch (tag) {
  case 1:
    return "TAG";
  case 2:
    return dtag2str(num);
  case 3:
    return "ATTR";
  case 4:
    return "DATTR";
  case 5:
    return "BLOB";
  case 6:
    return "UDATA";
  }
  return "?";
}


x86 assembly (clang, -O0):
<tag2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11a8 <tag2str+0x98>
mov    -0x18(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
mov    -0x10(%rbp),%edi
call   1030 <dtag2str@plt>
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
lea    0xe93(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <tag2str+0xa3>
lea    0xe7e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag2str>:
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     1136 <tag2str+0x26>
lea    0xef9(%rip),%rax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    %esi,%edi
jmp    1030 <dtag2str@plt>
lea    0xef0(%rip),%rax
ret
lea    0xed8(%rip),%rax
ret
lea    0xecf(%rip),%rax
ret
lea    0xecd(%rip),%rax
ret
lea    0xeca(%rip),%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"TAG\00"
@.str.1 = [5 x i8] c"ATTR\00"
@.str.2 = [6 x i8] c"DATTR\00"
@.str.3 = [5 x i8] c"BLOB\00"
@.str.4 = [6 x i8] c"UDATA\00"
@.str.5 = [2 x i8] c"?\00"
define i8* @tag2str(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %15 [
i32 1, label %7
i32 2, label %8
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
]
7: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %16
8: ; preds = %2
%9 = load i32, i32* %5
%10 = call i8* @dtag2str(i32 %9)
store i8* %10, i8** %3
br label %16
11: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %16
12: ; preds = %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %16
13: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %16
14: ; preds = %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %16
15: ; preds = %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %16
16: ; preds = %15, %14, %13, %12, %11, %8, %7
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
@.str = [4 x i8] c"TAG\00"
@.str.1 = [5 x i8] c"ATTR\00"
@.str.2 = [6 x i8] c"DATTR\00"
@.str.3 = [5 x i8] c"BLOB\00"
@.str.4 = [6 x i8] c"UDATA\00"
@.str.5 = [2 x i8] c"?\00"
define i8* @tag2str(i32 %0, i32 %1) {
switch i32 %0, label %9 [
i32 1, label %10
i32 2, label %3
i32 3, label %5
i32 4, label %6
i32 5, label %7
i32 6, label %8
]
3: ; preds = %2
%4 = tail call i8* @dtag2str(i32 %1)
br label %10
5: ; preds = %2
br label %10
6: ; preds = %2
br label %10
7: ; preds = %2
br label %10
8: ; preds = %2
br label %10
9: ; preds = %2
br label %10
10: ; preds = %2, %9, %8, %7, %6, %5, %3
%11 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %5 ], [ %4, %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %11
}