#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_pipe_clk_sel(char *result, int len, int reg, uint32_t val,
                            uint32_t devid) {
  const char *clock;
  switch ((val >> 29) & 7) {
  case 0:
    clock = "None";
    break;
  case 2:
    clock = "DDIB";
    break;
  case 3:
    clock = "DDIC";
    break;
  case 4:
    clock = "DDID";
    break;
  case 5:
    clock = "DDIE";
    break;
  default:
    clock = "Reserved";
    break;
  }
  snprintf(result, len, "%s", clock);
}


x86 assembly (clang, -O0):
<hsw_debug_pipe_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)
mov    -0x14(%rbp),%eax
shr    $0x1d,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     11a2 <hsw_debug_pipe_clk_sel+0x92>
mov    -0x28(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebf(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hsw_debug_pipe_clk_sel+0x9d>
lea    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hsw_debug_pipe_clk_sel+0x9d>
lea    0xea9(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hsw_debug_pipe_clk_sel+0x9d>
lea    0xe9e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hsw_debug_pipe_clk_sel+0x9d>
lea    0xe93(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hsw_debug_pipe_clk_sel+0x9d>
lea    0xe88(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
lea    0xe7b(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsw_debug_pipe_clk_sel>:
cmp    $0xbfffffff,%ecx
ja     1135 <hsw_debug_pipe_clk_sel+0x25>
shr    $0x1d,%ecx
lea    0xf06(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
lea    0xef2(%rip),%rdx
jmp    1030 <snprintf@plt>
lea    0xedd(%rip),%rcx
lea    0xedf(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"None\00"
@.str.1 = [5 x i8] c"DDIB\00"
@.str.2 = [5 x i8] c"DDIC\00"
@.str.3 = [5 x i8] c"DDID\00"
@.str.4 = [5 x i8] c"DDIE\00"
@.str.5 = [9 x i8] c"Reserved\00"
@.str.6 = [3 x i8] c"%s\00"
define void @hsw_debug_pipe_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
%12 = load i32, i32* %9
%13 = ashr i32 %12, 29
%14 = and i32 %13, 7
switch i32 %14, label %20 [
i32 0, label %15
i32 2, label %16
i32 3, label %17
i32 4, label %18
i32 5, label %19
]
15: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
br label %21
16: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %21
17: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %11
br label %21
18: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %11
br label %21
19: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %11
br label %21
20: ; preds = %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %11
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load i8*, i8** %11
%25 = call i32 @snprintf(i8* %22, i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %24)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"None\00"
@.str.1 = [5 x i8] c"DDIB\00"
@.str.2 = [5 x i8] c"DDIC\00"
@.str.3 = [5 x i8] c"DDID\00"
@.str.4 = [5 x i8] c"DDIE\00"
@.str.5 = [9 x i8] c"Reserved\00"
@.str.6 = [3 x i8] c"%s\00"
@reltable.hsw_debug_pipe_clk_sel = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i64)) to i32)]
define void @hsw_debug_pipe_clk_sel(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ult i32 %3, -1073741824
br i1 %6, label %7, label %12
7: ; preds = %5
%8 = lshr i32 %3, 29
%9 = zext i32 %8 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.hsw_debug_pipe_clk_sel to i8*), i64 %10)
br label %12
12: ; preds = %5, %7
%13 = phi i8* [ %11, %7 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %5 ]
%14 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %13)
ret void
}