#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 *, char const *,
                            int);
void ironlake_debug_rawclk_freq(char *result, int len, int reg, uint32_t val,
                                uint32_t devid) {
  const char *tp1 = NULL, *tp2 = NULL;
  switch (val & (3 << 12)) {
  case 0:
    tp1 = "0.5us";
    break;
  case (1 << 12):
    tp1 = "1.0us";
    break;
  case (2 << 12):
    tp1 = "2.0us";
    break;
  case (3 << 12):
    tp1 = "4.0us";
    break;
  }
  switch (val & (3 << 10)) {
  case 0:
    tp2 = "1.5us";
    break;
  case (1 << 10):
    tp2 = "3.0us";
    break;
  case (2 << 10):
    tp2 = "6.0us";
    break;
  case (3 << 10):
    tp2 = "12.0us";
    break;
  }
  snprintf(result, len, "FDL_TP1 timer %s, FDL_TP2 timer %s, freq %d", tp1, tp2,
           val & 0x3ff);
}


x86 assembly (clang, -O0):
<ironlake_debug_rawclk_freq>:
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)
movq   $0x0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
and    $0x3000,%eax
mov    %eax,-0x2c(%rbp)
je     1188 <ironlake_debug_rawclk_freq+0x78>
jmp    114f <ironlake_debug_rawclk_freq+0x3f>
mov    -0x2c(%rbp),%eax
sub    $0x1000,%eax
je     1198 <ironlake_debug_rawclk_freq+0x88>
jmp    1162 <ironlake_debug_rawclk_freq+0x52>
mov    -0x2c(%rbp),%eax
sub    $0x2000,%eax
je     11a8 <ironlake_debug_rawclk_freq+0x98>
jmp    1175 <ironlake_debug_rawclk_freq+0x65>
mov    -0x2c(%rbp),%eax
sub    $0x3000,%eax
je     11b8 <ironlake_debug_rawclk_freq+0xa8>
jmp    11c3 <ironlake_debug_rawclk_freq+0xb3>
lea    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c3 <ironlake_debug_rawclk_freq+0xb3>
lea    0xe67(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c3 <ironlake_debug_rawclk_freq+0xb3>
lea    0xe76(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c3 <ironlake_debug_rawclk_freq+0xb3>
lea    0xe4d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0xc00,%eax
mov    %eax,-0x30(%rbp)
je     1212 <ironlake_debug_rawclk_freq+0x102>
jmp    11d9 <ironlake_debug_rawclk_freq+0xc9>
mov    -0x30(%rbp),%eax
sub    $0x400,%eax
je     1222 <ironlake_debug_rawclk_freq+0x112>
jmp    11ec <ironlake_debug_rawclk_freq+0xdc>
mov    -0x30(%rbp),%eax
sub    $0x800,%eax
je     1232 <ironlake_debug_rawclk_freq+0x122>
jmp    11ff <ironlake_debug_rawclk_freq+0xef>
mov    -0x30(%rbp),%eax
sub    $0xc00,%eax
je     1242 <ironlake_debug_rawclk_freq+0x132>
jmp    124d <ironlake_debug_rawclk_freq+0x13d>
lea    0xdf9(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    124d <ironlake_debug_rawclk_freq+0x13d>
lea    0xdef(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    124d <ironlake_debug_rawclk_freq+0x13d>
lea    0xde5(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    124d <ironlake_debug_rawclk_freq+0x13d>
lea    0xddb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x14(%rbp),%r9d
and    $0x3ff,%r9d
lea    0xdbd(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ironlake_debug_rawclk_freq>:
mov    %ecx,%r9d
mov    %ecx,%eax
shr    $0xc,%eax
and    $0x3,%eax
lea    0xf36(%rip),%rdx
movslq (%rdx,%rax,4),%rcx
add    %rdx,%rcx
mov    %r9d,%eax
shr    $0xa,%eax
and    $0x3,%eax
lea    0xf2f(%rip),%rdx
movslq (%rdx,%rax,4),%r8
add    %rdx,%r8
and    $0x3ff,%r9d
lea    0xedd(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"0.5us\00"
@.str.1 = [6 x i8] c"1.0us\00"
@.str.2 = [6 x i8] c"2.0us\00"
@.str.3 = [6 x i8] c"4.0us\00"
@.str.4 = [6 x i8] c"1.5us\00"
@.str.5 = [6 x i8] c"3.0us\00"
@.str.6 = [6 x i8] c"6.0us\00"
@.str.7 = [7 x i8] c"12.0us\00"
@.str.8 = [44 x i8] c"FDL_TP1 timer %s, FDL_TP2 timer %s, freq %d\00"
define void @ironlake_debug_rawclk_freq(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*
%12 = 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
store i8* null, i8** %12
%13 = load i32, i32* %9
%14 = and i32 %13, 12288
switch i32 %14, label %19 [
i32 0, label %15
i32 4096, label %16
i32 8192, label %17
i32 12288, label %18
]
15: ; preds = %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %11
br label %19
16: ; preds = %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %19
17: ; preds = %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %11
br label %19
18: ; preds = %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %11
br label %19
19: ; preds = %5, %18, %17, %16, %15
%20 = load i32, i32* %9
%21 = and i32 %20, 3072
switch i32 %21, label %26 [
i32 0, label %22
i32 1024, label %23
i32 2048, label %24
i32 3072, label %25
]
22: ; preds = %19
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %12
br label %26
23: ; preds = %19
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %12
br label %26
24: ; preds = %19
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %12
br label %26
25: ; preds = %19
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %12
br label %26
26: ; preds = %19, %25, %24, %23, %22
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = load i8*, i8** %11
%30 = load i8*, i8** %12
%31 = load i32, i32* %9
%32 = and i32 %31, 1023
%33 = call i32 @snprintf(i8* %27, i32 %28, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8* %29, i8* %30, i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"0.5us\00"
@.str.1 = [6 x i8] c"1.0us\00"
@.str.2 = [6 x i8] c"2.0us\00"
@.str.3 = [6 x i8] c"4.0us\00"
@.str.4 = [6 x i8] c"1.5us\00"
@.str.5 = [6 x i8] c"3.0us\00"
@.str.6 = [6 x i8] c"6.0us\00"
@.str.7 = [7 x i8] c"12.0us\00"
@.str.8 = [44 x i8] c"FDL_TP1 timer %s, FDL_TP2 timer %s, freq %d\00"
@reltable.ironlake_debug_rawclk_freq = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq to i64)) to i32)]
@reltable.ironlake_debug_rawclk_freq.10 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq.10 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq.10 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq.10 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([4 x i32]* @reltable.ironlake_debug_rawclk_freq.10 to i64)) to i32)]
define void @ironlake_debug_rawclk_freq(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = lshr i32 %3, 12
%7 = and i32 %6, 3
%8 = zext i32 %7 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.ironlake_debug_rawclk_freq to i8*), i64 %9)
%11 = lshr i32 %3, 10
%12 = and i32 %11, 3
%13 = zext i32 %12 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.ironlake_debug_rawclk_freq.10 to i8*), i64 %14)
%16 = and i32 %3, 1023
%17 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8* %10, i8* %15, i32 %16)
ret void
}