#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*/ string_append(int, char *, char *);
void handle_cavium(int which, int part, char *model_string) {
  switch (part) {
  case 0x0a0:
    string_append(which, "ThunderX", model_string);
    break;
  case 0x0a1:
    string_append(which, "ThunderX 88XX", model_string);
    break;
  case 0x0a2:
    string_append(which, "ThunderX 81XX", model_string);
    break;
  case 0x0a3:
    string_append(which, "ThunderX 83XX", model_string);
    break;
  case 0x0af:
    string_append(which, "ThunderX2 99XX", model_string);
    break;
  default:
    string_append(which, "Unknown", model_string);
    break;
  }
}


x86 assembly (clang, -O0):
<handle_cavium>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff60,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xf,%eax
ja     11c5 <handle_cavium+0xb5>
mov    -0x18(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xee5(%rip),%rsi
call   1030 <string_append@plt>
jmp    11d8 <handle_cavium+0xc8>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xed6(%rip),%rsi
call   1030 <string_append@plt>
jmp    11d8 <handle_cavium+0xc8>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xecc(%rip),%rsi
call   1030 <string_append@plt>
jmp    11d8 <handle_cavium+0xc8>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xec2(%rip),%rsi
call   1030 <string_append@plt>
jmp    11d8 <handle_cavium+0xc8>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xeb8(%rip),%rsi
call   1030 <string_append@plt>
jmp    11d8 <handle_cavium+0xc8>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xeaf(%rip),%rsi
call   1030 <string_append@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_cavium>:
mov    %esi,%eax
add    $0xffffff60,%eax
cmp    $0xf,%eax
ja     1157 <handle_cavium+0x47>
lea    0xf1d(%rip),%rsi
lea    0xed6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0f(%rip),%rsi
jmp    1030 <string_append@plt>
lea    0xf11(%rip),%rsi
jmp    1030 <string_append@plt>
lea    0xf13(%rip),%rsi
jmp    1030 <string_append@plt>
lea    0xf24(%rip),%rsi
jmp    1030 <string_append@plt>
lea    0xf09(%rip),%rsi
jmp    1030 <string_append@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"ThunderX\00"
@.str.1 = [14 x i8] c"ThunderX 88XX\00"
@.str.2 = [14 x i8] c"ThunderX 81XX\00"
@.str.3 = [14 x i8] c"ThunderX 83XX\00"
@.str.4 = [15 x i8] c"ThunderX2 99XX\00"
@.str.5 = [8 x i8] c"Unknown\00"
define void @handle_cavium(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
switch i32 %7, label %28 [
i32 160, label %8
i32 161, label %12
i32 162, label %16
i32 163, label %20
i32 175, label %24
]
8: ; preds = %3
%9 = load i32, i32* %4
%10 = load i8*, i8** %6
%11 = call i32 @string_append(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %32
12: ; preds = %3
%13 = load i32, i32* %4
%14 = load i8*, i8** %6
%15 = call i32 @string_append(i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %32
16: ; preds = %3
%17 = load i32, i32* %4
%18 = load i8*, i8** %6
%19 = call i32 @string_append(i32 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %32
20: ; preds = %3
%21 = load i32, i32* %4
%22 = load i8*, i8** %6
%23 = call i32 @string_append(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %32
24: ; preds = %3
%25 = load i32, i32* %4
%26 = load i8*, i8** %6
%27 = call i32 @string_append(i32 %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %26)
br label %32
28: ; preds = %3
%29 = load i32, i32* %4
%30 = load i8*, i8** %6
%31 = call i32 @string_append(i32 %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %24, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"ThunderX\00"
@.str.1 = [14 x i8] c"ThunderX 88XX\00"
@.str.2 = [14 x i8] c"ThunderX 81XX\00"
@.str.3 = [14 x i8] c"ThunderX 83XX\00"
@.str.4 = [15 x i8] c"ThunderX2 99XX\00"
@.str.5 = [8 x i8] c"Unknown\00"
define void @handle_cavium(i32 %0, i32 %1, i8* %2) {
switch i32 %1, label %8 [
i32 160, label %9
i32 161, label %4
i32 162, label %5
i32 163, label %6
i32 175, label %7
]
4: ; preds = %3
br label %9
5: ; preds = %3
br label %9
6: ; preds = %3
br label %9
7: ; preds = %3
br label %9
8: ; preds = %3
br label %9
9: ; preds = %3, %8, %7, %6, %5, %4
%10 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %3 ]
%11 = tail call i32 @string_append(i32 %0, i8* %10, i8* %2)
ret void
}