#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
void hsw_debug_port_clk_sel(char *result, int len, int reg, uint32_t val,
                            uint32_t devid) {
  const char *clock = NULL;
  switch ((val >> 29) & 7) {
  case 0:
    clock = "LCPLL 2700";
    break;
  case 1:
    clock = "LCPLL 1350";
    break;
  case 2:
    clock = "LCPLL 810";
    break;
  case 3:
    clock = "SPLL";
    break;
  case 4:
    clock = "WRPLL 1";
    break;
  case 5:
    clock = "WRPLL 2";
    break;
  case 6:
    clock = "Reserved";
    break;
  case 7:
    clock = "None";
    break;
  }
  snprintf(result, len, "%s", clock);
}


x86 assembly (clang, -O0):
<hsw_debug_port_clk_sel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x1d,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x7,%eax
ja     11d5 <hsw_debug_port_clk_sel+0xc5>
mov    -0x28(%rbp),%rax
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebf(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xeb5(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xeaf(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xea4(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xe9c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xe94(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <hsw_debug_port_clk_sel+0xc5>
lea    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
lea    0xe7c(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsw_debug_port_clk_sel>:
shr    $0x1d,%ecx
lea    0xf2e(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
lea    0xf1b(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"LCPLL 2700\00"
@.str.1 = [11 x i8] c"LCPLL 1350\00"
@.str.2 = [10 x i8] c"LCPLL 810\00"
@.str.3 = [5 x i8] c"SPLL\00"
@.str.4 = [8 x i8] c"WRPLL 1\00"
@.str.5 = [8 x i8] c"WRPLL 2\00"
@.str.6 = [9 x i8] c"Reserved\00"
@.str.7 = [5 x i8] c"None\00"
@.str.8 = [3 x i8] c"%s\00"
define void @hsw_debug_port_clk_sel(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i8* null, i8** %11
%12 = load i32, i32* %9
%13 = ashr i32 %12, 29
%14 = and i32 %13, 7
switch i32 %14, label %23 [
i32 0, label %15
i32 1, label %16
i32 2, label %17
i32 3, label %18
i32 4, label %19
i32 5, label %20
i32 6, label %21
i32 7, label %22
]
15: ; preds = %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %11
br label %23
16: ; preds = %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %23
17: ; preds = %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %11
br label %23
18: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %11
br label %23
19: ; preds = %5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %11
br label %23
20: ; preds = %5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %11
br label %23
21: ; preds = %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %11
br label %23
22: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %11
br label %23
23: ; preds = %5, %22, %21, %20, %19, %18, %17, %16, %15
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = load i8*, i8** %11
%27 = call i32 @snprintf(i8* %24, i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %26)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"LCPLL 2700\00"
@.str.1 = [11 x i8] c"LCPLL 1350\00"
@.str.2 = [10 x i8] c"LCPLL 810\00"
@.str.3 = [5 x i8] c"SPLL\00"
@.str.4 = [8 x i8] c"WRPLL 1\00"
@.str.5 = [8 x i8] c"WRPLL 2\00"
@.str.6 = [9 x i8] c"Reserved\00"
@.str.7 = [5 x i8] c"None\00"
@.str.8 = [3 x i8] c"%s\00"
@reltable.hsw_debug_port_clk_sel = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i64)) to i32)]
define void @hsw_debug_port_clk_sel(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = lshr i32 %3, 29
%7 = zext i32 %6 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.hsw_debug_port_clk_sel to i8*), i64 %8)
%10 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %9)
ret void
}