#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 *, int, int, int,
                            int);
void hsw_debug_lp_wm(char *result, int len, int reg, uint32_t val,
                     uint32_t devid) {
  const char *enable;
  uint32_t latency, fbc, pri, cur;
  enable = ((val >> 31) & 1) ? "enabled" : "disabled";
  latency = (val >> 24) & 0x7F;
  fbc = (val >> 20) & 0xF;
  pri = (val >> 8) & 0x3FF;
  cur = val & 0xFF;
  snprintf(result, len, "%s, latency %d, fbc %d, pri %d, cur %d", enable,
           latency, fbc, pri, cur);
}


x86 assembly (clang, -O0):
<hsw_debug_lp_wm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x14(%rbp),%edx
sar    $0x1f,%edx
and    $0x1,%edx
lea    0xecf(%rip),%rax
lea    0xec0(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x18,%eax
and    $0x7f,%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x14,%eax
and    $0xf,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x8,%eax
and    $0x3ff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x2c(%rbp),%r10d
mov    -0x30(%rbp),%eax
lea    0xe74(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsw_debug_lp_wm>:
push   %rax
test   %ecx,%ecx
lea    0xeee(%rip),%rdx
lea    0xedf(%rip),%r10
cmovns %rdx,%r10
mov    %ecx,%r9d
mov    %ecx,%eax
movzbl %cl,%r11d
mov    %ecx,%r8d
shr    $0x18,%r8d
and    $0x7f,%r8d
shr    $0x14,%r9d
and    $0xf,%r9d
shr    $0x8,%eax
and    $0x3ff,%eax
lea    0xec1(%rip),%rdx
mov    %r10,%rcx
push   %r11
push   %rax
call   1030 <snprintf@plt>
add    $0x10,%rsp
pop    %rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"enabled\00"
@.str.1 = [9 x i8] c"disabled\00"
@.str.2 = [39 x i8] c"%s, latency %d, fbc %d, pri %d, cur %d\00"
define void @hsw_debug_lp_wm(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 i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
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
%16 = load i32, i32* %9
%17 = ashr i32 %16, 31
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
store i8* %21, i8** %11
%22 = load i32, i32* %9
%23 = ashr i32 %22, 24
%24 = and i32 %23, 127
store i32 %24, i32* %12
%25 = load i32, i32* %9
%26 = ashr i32 %25, 20
%27 = and i32 %26, 15
store i32 %27, i32* %13
%28 = load i32, i32* %9
%29 = ashr i32 %28, 8
%30 = and i32 %29, 1023
store i32 %30, i32* %14
%31 = load i32, i32* %9
%32 = and i32 %31, 255
store i32 %32, i32* %15
%33 = load i8*, i8** %6
%34 = load i32, i32* %7
%35 = load i8*, i8** %11
%36 = load i32, i32* %12
%37 = load i32, i32* %13
%38 = load i32, i32* %14
%39 = load i32, i32* %15
%40 = call i32 @snprintf(i8* %33, i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %35, i32 %36, i32 %37, i32 %38, i32 %39)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"enabled\00"
@.str.1 = [9 x i8] c"disabled\00"
@.str.2 = [39 x i8] c"%s, latency %d, fbc %d, pri %d, cur %d\00"
define void @hsw_debug_lp_wm(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, -1
%7 = select i1 %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0)
%8 = lshr i32 %3, 24
%9 = and i32 %8, 127
%10 = lshr i32 %3, 20
%11 = and i32 %10, 15
%12 = lshr i32 %3, 8
%13 = and i32 %12, 1023
%14 = and i32 %3, 255
%15 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %7, i32 %9, i32 %11, i32 %13, i32 %14)
ret void
}