#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 *,
                            char const *, char const *, char const *,
                            char const *, char const *);
void ironlake_debug_dref_ctl(char *result, int len, int reg, uint32_t val,
                             uint32_t devid) {
  const char *cpu_source;
  const char *ssc_source = val & (2 << 11) ? "enable" : "disable";
  const char *nonspread_source = val & (2 << 9) ? "enable" : "disable";
  const char *superspread_source = val & (2 << 7) ? "enable" : "disable";
  const char *ssc4_mode = val & (1 << 6) ? "centerspread" : "downspread";
  const char *ssc1 = val & (1 << 1) ? "enable" : "disable";
  const char *ssc4 = val & (1) ? "enable" : "disable";
  switch (val & (3 << 13)) {
  case (0 << 13):
    cpu_source = "disable";
    break;
  case (2 << 13):
    cpu_source = "downspread";
    break;
  case (3 << 13):
    cpu_source = "nonspread";
    break;
  default:
    cpu_source = "reserved";
  }
  snprintf(result, len,
           "cpu source %s, ssc_source %s, nonspread_source %s, "
           "superspread_source %s, ssc4_mode %s, ssc1 %s, ssc4 %s",
           cpu_source, ssc_source, nonspread_source, superspread_source,
           ssc4_mode, ssc1, ssc4);
}


x86 assembly (clang, -O0):
<ironlake_debug_dref_ctl>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xecc(%rip),%rcx
lea    0xecc(%rip),%rax
test   $0x1000,%edx
mov    %rax,%rdx
cmovne %rcx,%rdx
mov    %rdx,-0x30(%rbp)
mov    -0x1c(%rbp),%edx
test   $0x400,%edx
mov    %rax,%rdx
cmovne %rcx,%rdx
mov    %rdx,-0x38(%rbp)
mov    -0x1c(%rbp),%edx
test   $0x100,%edx
mov    %rax,%rdx
cmovne %rcx,%rdx
mov    %rdx,-0x40(%rbp)
mov    -0x1c(%rbp),%edx
mov    %dl,%dil
lea    0xe8e(%rip),%rsi
lea    0xe94(%rip),%rdx
test   $0x40,%dil
cmovne %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    -0x1c(%rbp),%edx
test   $0x2,%dl
mov    %rax,%rdx
cmovne %rcx,%rdx
mov    %rdx,-0x50(%rbp)
mov    -0x1c(%rbp),%dl
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x6000,%eax
mov    %eax,-0x5c(%rbp)
je     11ef <ironlake_debug_dref_ctl+0xdf>
jmp    11c9 <ironlake_debug_dref_ctl+0xb9>
mov    -0x5c(%rbp),%eax
sub    $0x4000,%eax
je     11ff <ironlake_debug_dref_ctl+0xef>
jmp    11dc <ironlake_debug_dref_ctl+0xcc>
mov    -0x5c(%rbp),%eax
sub    $0x6000,%eax
je     120f <ironlake_debug_dref_ctl+0xff>
jmp    121f <ironlake_debug_dref_ctl+0x10f>
lea    0xe11(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    122a <ironlake_debug_dref_ctl+0x11a>
lea    0xe16(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    122a <ironlake_debug_dref_ctl+0x11a>
lea    0xe11(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    122a <ironlake_debug_dref_ctl+0x11a>
lea    0xe0b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%rbx
mov    -0x48(%rbp),%r11
mov    -0x50(%rbp),%r10
mov    -0x58(%rbp),%rax
lea    0xde6(%rip),%rdx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <snprintf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<ironlake_debug_dref_ctl>:
lea    0xef0(%rip),%rdx
mov    %ecx,%eax
mov    %rdx,%r10
and    $0x6000,%eax
je     114a <ironlake_debug_dref_ctl+0x3a>
cmp    $0x6000,%eax
je     113a <ironlake_debug_dref_ctl+0x2a>
cmp    $0x4000,%eax
jne    1143 <ironlake_debug_dref_ctl+0x33>
lea    0xee4(%rip),%r10
jmp    114a <ironlake_debug_dref_ctl+0x3a>
lea    0xee6(%rip),%r10
jmp    114a <ironlake_debug_dref_ctl+0x3a>
lea    0xee7(%rip),%r10
push   %r14
push   %rbx
push   %rax
test   $0x1,%cl
lea    0xea8(%rip),%r8
mov    %r8,%r11
cmove  %rdx,%r11
test   $0x2,%cl
mov    %r8,%r14
cmove  %rdx,%r14
test   $0x40,%cl
lea    0xea9(%rip),%r9
lea    0xe95(%rip),%rbx
cmove  %r9,%rbx
test   $0x100,%ecx
mov    %r8,%rax
cmove  %rdx,%rax
test   $0x400,%ecx
mov    %r8,%r9
cmove  %rdx,%r9
test   $0x1000,%ecx
cmove  %rdx,%r8
lea    0xe91(%rip),%rdx
mov    %r10,%rcx
push   %r11
push   %r14
push   %rbx
push   %rax
call   1030 <snprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"enable\00"
@.str.1 = [8 x i8] c"disable\00"
@.str.2 = [13 x i8] c"centerspread\00"
@.str.3 = [11 x i8] c"downspread\00"
@.str.4 = [10 x i8] c"nonspread\00"
@.str.5 = [9 x i8] c"reserved\00"
@.str.6 = [105 x i8] c"cpu source %s, ssc_source %s, nonspread_source %s, superspread_source %s, ssc4_mode %s, ssc1 %s, ssc4 %s\00"
define void @ironlake_debug_dref_ctl(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*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = 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
%18 = load i32, i32* %9
%19 = and i32 %18, 4096
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
store i8* %22, i8** %12
%23 = load i32, i32* %9
%24 = and i32 %23, 1024
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
store i8* %27, i8** %13
%28 = load i32, i32* %9
%29 = and i32 %28, 256
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
store i8* %32, i8** %14
%33 = load i32, i32* %9
%34 = and i32 %33, 64
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
store i8* %37, i8** %15
%38 = load i32, i32* %9
%39 = and i32 %38, 2
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
store i8* %42, i8** %16
%43 = load i32, i32* %9
%44 = and i32 %43, 1
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
store i8* %47, i8** %17
%48 = load i32, i32* %9
%49 = and i32 %48, 24576
switch i32 %49, label %53 [
i32 0, label %50
i32 16384, label %51
i32 24576, label %52
]
50: ; preds = %5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %54
51: ; preds = %5
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %11
br label %54
52: ; preds = %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %11
br label %54
53: ; preds = %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %11
br label %54
54: ; preds = %53, %52, %51, %50
%55 = load i8*, i8** %6
%56 = load i32, i32* %7
%57 = load i8*, i8** %11
%58 = load i8*, i8** %12
%59 = load i8*, i8** %13
%60 = load i8*, i8** %14
%61 = load i8*, i8** %15
%62 = load i8*, i8** %16
%63 = load i8*, i8** %17
%64 = call i32 @snprintf(i8* %55, i32 %56, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.6, i64 0, i64 0), i8* %57, i8* %58, i8* %59, i8* %60, i8* %61, i8* %62, i8* %63)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"enable\00"
@.str.1 = [8 x i8] c"disable\00"
@.str.2 = [13 x i8] c"centerspread\00"
@.str.3 = [11 x i8] c"downspread\00"
@.str.4 = [10 x i8] c"nonspread\00"
@.str.5 = [9 x i8] c"reserved\00"
@.str.6 = [105 x i8] c"cpu source %s, ssc_source %s, nonspread_source %s, superspread_source %s, ssc4_mode %s, ssc1 %s, ssc4 %s\00"
define void @ironlake_debug_dref_ctl(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = and i32 %3, 24576
switch i32 %6, label %9 [
i32 0, label %10
i32 16384, label %7
i32 24576, label %8
]
7: ; preds = %5
br label %10
8: ; preds = %5
br label %10
9: ; preds = %5
br label %10
10: ; preds = %5, %9, %8, %7
%11 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %5 ]
%12 = and i32 %3, 1
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%15 = and i32 %3, 2
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%18 = and i32 %3, 64
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0)
%21 = and i32 %3, 256
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%24 = and i32 %3, 1024
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%27 = and i32 %3, 4096
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%30 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.6, i64 0, i64 0), i8* %11, i8* %29, i8* %26, i8* %23, i8* %20, i8* %17, i8* %14)
ret void
}