#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 GetTypeCode(unsigned dEventType, char *sTypeCode) {
  switch (dEventType) {
  case 0:
    strcpy(sTypeCode, "TR");
    return 0;
  case 1:
    strcpy(sTypeCode, "TP");
    return 0;
  case 2:
    strcpy(sTypeCode, "TS");
    return 0;
  case 3:
    strcpy(sTypeCode, "CR");
    return 0;
  case 4:
    strcpy(sTypeCode, "CP");
    return 0;
  case 5:
    strcpy(sTypeCode, "CS");
    return 0;
  case 6:
    strcpy(sTypeCode, "SR");
    return 0;
  case 7:
    strcpy(sTypeCode, "RP");
    return 0;
  case 8:
    strcpy(sTypeCode, "PR");
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<GetTypeCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x8,%rax
ja     1240 <GetTypeCode+0x130>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
mov    -0x10(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    1247 <GetTypeCode+0x137>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetTypeCode>:
mov    $0xffffffff,%eax
cmp    $0x8,%edi
ja     113d <GetTypeCode+0x2d>
push   %rax
movslq %edi,%rax
lea    0xef7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"TR\00"
@.str.1 = [3 x i8] c"TP\00"
@.str.2 = [3 x i8] c"TS\00"
@.str.3 = [3 x i8] c"CR\00"
@.str.4 = [3 x i8] c"CP\00"
@.str.5 = [3 x i8] c"CS\00"
@.str.6 = [3 x i8] c"SR\00"
@.str.7 = [3 x i8] c"RP\00"
@.str.8 = [3 x i8] c"PR\00"
define i32 @GetTypeCode(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 i32, i32* %4
switch i32 %6, label %34 [
i32 0, label %7
i32 1, label %10
i32 2, label %13
i32 3, label %16
i32 4, label %19
i32 5, label %22
i32 6, label %25
i32 7, label %28
i32 8, label %31
]
7: ; preds = %2
%8 = load i8*, i8** %5
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %35
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %35
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %35
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %35
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %35
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %35
25: ; preds = %2
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %35
28: ; preds = %2
%29 = load i8*, i8** %5
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %35
31: ; preds = %2
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %35
34: ; preds = %2
store i32 -1, i32* %3
br label %35
35: ; preds = %34, %31, %28, %25, %22, %19, %16, %13, %10, %7
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"TR\00"
@.str.1 = [3 x i8] c"TP\00"
@.str.2 = [3 x i8] c"TS\00"
@.str.3 = [3 x i8] c"CR\00"
@.str.4 = [3 x i8] c"CP\00"
@.str.5 = [3 x i8] c"CS\00"
@.str.6 = [3 x i8] c"SR\00"
@.str.7 = [3 x i8] c"RP\00"
@.str.8 = [3 x i8] c"PR\00"
@reltable.GetTypeCode = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.GetTypeCode to i64)) to i32)]
define i32 @GetTypeCode(i32 %0, i8* %1) {
%3 = icmp ult i32 %0, 9
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.GetTypeCode to i8*), i64 %6)
%8 = tail call i32 @strcpy(i8* %1, i8* %7)
br label %9
9: ; preds = %2, %4
%10 = phi i32 [ -1, %2 ], [ 0, %4 ]
ret i32 %10
}