char *mk20dx256_cpu_family() {
  switch ((*((volatile unsigned int *)0x40048024) & 0x70) >> 4) {
  case 0x0:
    return "K10";
  case 0x1:
    return "K20";
  case 0x2:
    return "K61";
  case 0x4:
    return "K60";
  case 0x5:
    return "K70";
  }
  return "Unknown";
}


x86 assembly (clang, -O0):
<mk20dx256_cpu_family>:
push   %rbp
mov    %rsp,%rbp
mov    0x40048024,%eax
and    $0x70,%eax
shr    $0x4,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1184 <mk20dx256_cpu_family+0x84>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <mk20dx256_cpu_family+0x8f>
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <mk20dx256_cpu_family+0x8f>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <mk20dx256_cpu_family+0x8f>
lea    0xeb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <mk20dx256_cpu_family+0x8f>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <mk20dx256_cpu_family+0x8f>
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk20dx256_cpu_family>:
mov    0x40048024,%eax
shr    $0x4,%eax
and    $0x7,%eax
cmp    $0x5,%eax
ja     1121 <mk20dx256_cpu_family+0x21>
lea    0xf03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xeec(%rip),%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"K10\00"
@.str.1 = [4 x i8] c"K20\00"
@.str.2 = [4 x i8] c"K61\00"
@.str.3 = [4 x i8] c"K60\00"
@.str.4 = [4 x i8] c"K70\00"
@.str.5 = [8 x i8] c"Unknown\00"
define i8* @mk20dx256_cpu_family() {
%1 = alloca i8*
%2 = load volatile i32, i32* inttoptr (i64 1074036772 to i32*)
%3 = and i32 %2, 112
%4 = lshr i32 %3, 4
switch i32 %4, label %10 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
i32 4, label %8
i32 5, label %9
]
5: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %1
br label %11
6: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %11
7: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %11
8: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %11
9: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %11
10: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %11
11: ; preds = %10, %9, %8, %7, %6, %5
%12 = load i8*, i8** %1
ret i8* %12
}

LLVM IR (-O2):
@.str = [4 x i8] c"K10\00"
@.str.1 = [4 x i8] c"K20\00"
@.str.2 = [4 x i8] c"K61\00"
@.str.3 = [4 x i8] c"K60\00"
@.str.4 = [4 x i8] c"K70\00"
@.str.5 = [8 x i8] c"Unknown\00"
@reltable.mk20dx256_cpu_family = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.mk20dx256_cpu_family to i64)) to i32)]
define i8* @mk20dx256_cpu_family() {
%1 = load volatile i32, i32* inttoptr (i64 1074036772 to i32*)
%2 = lshr i32 %1, 4
%3 = and i32 %2, 7
%4 = icmp ult i32 %3, 6
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = zext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.mk20dx256_cpu_family to i8*), i64 %7)
br label %9
9: ; preds = %0, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %0 ]
ret i8* %10
}