#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 /*<<< orphan*/ strcpy(char *, char *);
int get_test_type_name(int test_type, char *str) {
  if (str == NULL)
    return -1;
  switch (test_type) {
  case 1:
    strcpy(str, "one_to_one");
    break;
  case 3:
    strcpy(str, "async_one_to_one");
    break;
  case 2:
    strcpy(str, "all_to_all");
    break;
  case 4:
    strcpy(str, "send_recv_end_recv_send");
    break;
  case 5:
    strcpy(str, "noise");
    break;
  case 6:
    strcpy(str, "noise_blocking");
    break;
  case 7:
    strcpy(str, "bcast");
    break;
  case 9:
    strcpy(str, "get");
    break;
  case 8:
    strcpy(str, "put");
    break;
  default:
    strcpy(str, "unknown");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_test_type_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1136 <get_test_type_name+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    1233 <get_test_type_name+0x123>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x8,%eax
ja     121c <get_test_type_name+0x10c>
mov    -0x18(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122c <get_test_type_name+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_test_type_name>:
test   %rsi,%rsi
je     1131 <get_test_type_name+0x21>
push   %rax
add    $0xffffffff,%edi
cmp    $0x8,%edi
ja     1137 <get_test_type_name+0x27>
movslq %edi,%rax
lea    0xf38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    113e <get_test_type_name+0x2e>
mov    $0xffffffff,%eax
ret
lea    0xf19(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"one_to_one\00"
@.str.1 = [17 x i8] c"async_one_to_one\00"
@.str.2 = [11 x i8] c"all_to_all\00"
@.str.3 = [24 x i8] c"send_recv_end_recv_send\00"
@.str.4 = [6 x i8] c"noise\00"
@.str.5 = [15 x i8] c"noise_blocking\00"
@.str.6 = [6 x i8] c"bcast\00"
@.str.7 = [4 x i8] c"get\00"
@.str.8 = [4 x i8] c"put\00"
@.str.9 = [8 x i8] c"unknown\00"
define i32 @get_test_type_name(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %42
9: ; preds = %2
%10 = load i32, i32* %4
switch i32 %10, label %38 [
i32 1, label %11
i32 3, label %14
i32 2, label %17
i32 4, label %20
i32 5, label %23
i32 6, label %26
i32 7, label %29
i32 9, label %32
i32 8, label %35
]
11: ; preds = %9
%12 = load i8*, i8** %5
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %41
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %41
17: ; preds = %9
%18 = load i8*, i8** %5
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %41
20: ; preds = %9
%21 = load i8*, i8** %5
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %41
23: ; preds = %9
%24 = load i8*, i8** %5
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %41
26: ; preds = %9
%27 = load i8*, i8** %5
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %41
29: ; preds = %9
%30 = load i8*, i8** %5
%31 = call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %41
32: ; preds = %9
%33 = load i8*, i8** %5
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %41
35: ; preds = %9
%36 = load i8*, i8** %5
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %41
38: ; preds = %9
%39 = load i8*, i8** %5
%40 = call i32 @strcpy(i8* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %41
41: ; preds = %38, %35, %32, %29, %26, %23, %20, %17, %14, %11
store i32 0, i32* %3
br label %42
42: ; preds = %41, %8
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [11 x i8] c"one_to_one\00"
@.str.1 = [17 x i8] c"async_one_to_one\00"
@.str.2 = [11 x i8] c"all_to_all\00"
@.str.3 = [24 x i8] c"send_recv_end_recv_send\00"
@.str.4 = [6 x i8] c"noise\00"
@.str.5 = [15 x i8] c"noise_blocking\00"
@.str.6 = [6 x i8] c"bcast\00"
@.str.7 = [4 x i8] c"get\00"
@.str.8 = [4 x i8] c"put\00"
@.str.9 = [8 x i8] c"unknown\00"
@reltable.get_test_type_name = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.get_test_type_name to i64)) to i32)]
define i32 @get_test_type_name(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = add i32 %0, -1
%6 = icmp ult i32 %5, 9
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.get_test_type_name to i8*), i64 %9)
br label %11
11: ; preds = %4, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), %4 ]
%13 = tail call i32 @strcpy(i8* %1, i8* %12)
br label %14
14: ; preds = %11, %2
%15 = phi i32 [ -1, %2 ], [ 0, %11 ]
ret i32 %15
}