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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
const char *pn_cast_get_name(uint32_t op) {
  const char *names[] = {"trunc",  "zext",   "sext",   "fptoui",
                         "fptosi", "uitofp", "sitofp", "fptrunc",
                         "fpext",  NULL,     NULL,     "bitcast"};
  if (op >= (sizeof(names) / sizeof((names)[0]))) {
    do {
      fprintf(stderr, "Invalid op: %u\n", op);
      exit(1);
    } while (0);
  }
  return names[op];
}


x86 assembly (clang, -O0):
<pn_cast_get_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c6a(%rip),%rsi
mov    $0x60,%edx
call   1040 <memcpy@plt>
movslq -0x4(%rbp),%rax
cmp    $0xc,%rax
jb     1185 <pn_cast_get_name+0x55>
jmp    1163 <pn_cast_get_name+0x33>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xec6(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movslq -0x4(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pn_cast_get_name>:
push   %rax
mov    %edi,%edx
cmp    $0xc,%edi
jae    1137 <pn_cast_get_name+0x17>
mov    %edx,%eax
lea    0x2c7f(%rip),%rcx
mov    (%rcx,%rax,8),%rax
pop    %rcx
ret
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xef5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"trunc\00"
@.str.1 = [5 x i8] c"zext\00"
@.str.2 = [5 x i8] c"sext\00"
@.str.3 = [7 x i8] c"fptoui\00"
@.str.4 = [7 x i8] c"fptosi\00"
@.str.5 = [7 x i8] c"uitofp\00"
@.str.6 = [7 x i8] c"sitofp\00"
@.str.7 = [8 x i8] c"fptrunc\00"
@.str.8 = [6 x i8] c"fpext\00"
@.str.9 = [8 x i8] c"bitcast\00"
@__const.pn_cast_get_name.names = [12 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* null, i8* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0)]
@stderr = global i32 0
@.str.10 = [16 x i8] c"Invalid op: %u\0A\00"
define i8* @pn_cast_get_name(i32 %0) {
%2 = alloca i32
%3 = alloca [12 x i8*]
store i32 %0, i32* %2
%4 = bitcast [12 x i8*]* %3 to i8*
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = icmp uge i64 %6, 12
br i1 %7, label %8, label %15
8: ; preds = %1
br label %9
9: ; preds = %8
%10 = load i32, i32* @stderr
%11 = load i32, i32* %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; No predecessors!
br label %15
15: ; preds = %14, %1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [12 x i8*], [12 x i8*]* %3, i64 0, i64 %17
%19 = load i8*, i8** %18
ret i8* %19
}

LLVM IR (-O2):
@.str = [6 x i8] c"trunc\00"
@.str.1 = [5 x i8] c"zext\00"
@.str.2 = [5 x i8] c"sext\00"
@.str.3 = [7 x i8] c"fptoui\00"
@.str.4 = [7 x i8] c"fptosi\00"
@.str.5 = [7 x i8] c"uitofp\00"
@.str.6 = [7 x i8] c"sitofp\00"
@.str.7 = [8 x i8] c"fptrunc\00"
@.str.8 = [6 x i8] c"fpext\00"
@.str.9 = [8 x i8] c"bitcast\00"
@__const.pn_cast_get_name.names = [12 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* null, i8* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0)]
@stderr = global i32 0
@.str.10 = [16 x i8] c"Invalid op: %u\0A\00"
define i8* @pn_cast_get_name(i32 %0) {
%2 = icmp ugt i32 %0, 11
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %0)
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = zext i32 %0 to i64
%9 = getelementptr inbounds [12 x i8*], [12 x i8*]* @__const.pn_cast_get_name.names, i64 0, i64 %8
%10 = load i8*, i8** %9
ret i8* %10
}