#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 uint16_t;
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *mv6_model_str(uint16_t id) {
  static char str[32];
  switch (id & 0xfff0) {
  case 0x0480:
    return "mv88e6046";
  case 0x0950:
    return "mv88e6095";
  case 0x0990:
    return "mv88e6097";
  case 0x1a70:
    return "mv88e6185";
  case 0x3520:
    return "mv88e6352";
  }
  snprintf(str, sizeof(str), "UNKNOWN(%#.4x)", id);
  return str;
}


x86 assembly (clang, -O0):
<mv6_model_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff0,%eax
mov    %eax,-0x10(%rbp)
sub    $0x480,%eax
je     1182 <mv6_model_str+0x72>
jmp    1136 <mv6_model_str+0x26>
mov    -0x10(%rbp),%eax
sub    $0x950,%eax
je     1192 <mv6_model_str+0x82>
jmp    1149 <mv6_model_str+0x39>
mov    -0x10(%rbp),%eax
sub    $0x990,%eax
je     11a2 <mv6_model_str+0x92>
jmp    115c <mv6_model_str+0x4c>
mov    -0x10(%rbp),%eax
sub    $0x1a70,%eax
je     11b2 <mv6_model_str+0xa2>
jmp    116f <mv6_model_str+0x5f>
mov    -0x10(%rbp),%eax
sub    $0x3520,%eax
je     11c2 <mv6_model_str+0xb2>
jmp    11d2 <mv6_model_str+0xc2>
lea    0xe77(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <mv6_model_str+0xe8>
lea    0xe71(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <mv6_model_str+0xe8>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <mv6_model_str+0xe8>
lea    0xe65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <mv6_model_str+0xe8>
lea    0xe5f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <mv6_model_str+0xe8>
mov    -0xc(%rbp),%ecx
lea    0x2e64(%rip),%rdi
mov    $0x20,%esi
lea    0xe4a(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e4c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mv6_model_str>:
push   %rbx
mov    %edi,%ecx
mov    %edi,%eax
and    $0xfffffff0,%eax
movswl %ax,%edx
movzwl %dx,%eax
cmp    $0x98f,%edx
jle    1144 <mv6_model_str+0x34>
cmp    $0x990,%eax
je     115b <mv6_model_str+0x4b>
cmp    $0x1a70,%eax
je     1164 <mv6_model_str+0x54>
cmp    $0x3520,%eax
jne    1176 <mv6_model_str+0x66>
lea    0xee6(%rip),%rbx
jmp    1191 <mv6_model_str+0x81>
cmp    $0x480,%eax
je     116d <mv6_model_str+0x5d>
cmp    $0x950,%eax
jne    1176 <mv6_model_str+0x66>
lea    0xeb1(%rip),%rbx
jmp    1191 <mv6_model_str+0x81>
lea    0xeb2(%rip),%rbx
jmp    1191 <mv6_model_str+0x81>
lea    0xeb3(%rip),%rbx
jmp    1191 <mv6_model_str+0x81>
lea    0xe8c(%rip),%rbx
jmp    1191 <mv6_model_str+0x81>
lea    0x2ec3(%rip),%rbx
lea    0xeae(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@mv6_model_str.str = internal global [32 x i8] zeroinitializer
@.str = [10 x i8] c"mv88e6046\00"
@.str.1 = [10 x i8] c"mv88e6095\00"
@.str.2 = [10 x i8] c"mv88e6097\00"
@.str.3 = [10 x i8] c"mv88e6185\00"
@.str.4 = [10 x i8] c"mv88e6352\00"
@.str.5 = [15 x i8] c"UNKNOWN(%#.4x)\00"
define i8* @mv6_model_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 65520
switch i32 %5, label %11 [
i32 1152, label %6
i32 2384, label %7
i32 2448, label %8
i32 6768, label %9
i32 13600, label %10
]
6: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %14
7: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %14
8: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %14
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_model_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %12)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_model_str.str, i64 0, i64 0), i8** %2
br label %14
14: ; preds = %11, %10, %9, %8, %7, %6
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@mv6_model_str.str = internal global [32 x i8] zeroinitializer
@.str = [10 x i8] c"mv88e6046\00"
@.str.1 = [10 x i8] c"mv88e6095\00"
@.str.2 = [10 x i8] c"mv88e6097\00"
@.str.3 = [10 x i8] c"mv88e6185\00"
@.str.4 = [10 x i8] c"mv88e6352\00"
@.str.5 = [15 x i8] c"UNKNOWN(%#.4x)\00"
define i8* @mv6_model_str(i32 %0) {
%2 = trunc i32 %0 to i16
%3 = and i16 %2, -16
switch i16 %3, label %8 [
i16 1152, label %10
i16 2384, label %4
i16 2448, label %5
i16 6768, label %6
i16 13600, label %7
]
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
%9 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_model_str.str, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %1, %8, %7, %6, %5, %4
%11 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @mv6_model_str.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %11
}