#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int apply_dpc_clkdiv0(volatile unsigned short *memregs, void *data) {
  int pcd = *(int *)data;
  int tmp;
  if ((pcd - 1) & ~0x3f) {
    fprintf(stderr, "pollux_set: invalid lcd clkdiv0: %d\n", pcd);
    return -1;
  }
  pcd = (pcd - 1) & 0x3f;
  tmp = memregs[0x31c4 >> 1];
  memregs[0x31c4 >> 1] = (tmp & ~0x3f0) | (pcd << 4);
  return 0;
}


x86 assembly (clang, -O0):
<apply_dpc_clkdiv0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
and    $0xffffffc0,%eax
cmp    $0x0,%eax
je     115f <apply_dpc_clkdiv0+0x4f>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xeb2(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <apply_dpc_clkdiv0+0x91>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
and    $0x3f,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x31c4(%rax),%ax
movzwl %ax,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
and    $0xfffffc0f,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x31c4(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_dpc_clkdiv0>:
push   %rax
mov    (%rsi),%edx
lea    -0x1(%rdx),%eax
cmp    $0x40,%eax
jae    113b <apply_dpc_clkdiv0+0x2b>
movzwl 0x31c4(%rdi),%ecx
and    $0xfffffc0f,%ecx
and    $0x3f,%eax
shl    $0x4,%eax
or     %ecx,%eax
mov    %ax,0x31c4(%rdi)
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"pollux_set: invalid lcd clkdiv0: %d\0A\00"
define i32 @apply_dpc_clkdiv0(i16* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i16*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i16* %0, i16** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = sub nsw i32 %11, 1
%13 = and i32 %12, -64
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i32, i32* %6
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 -1, i32* %3
br label %35
19: ; preds = %2
%20 = load i32, i32* %6
%21 = sub nsw i32 %20, 1
%22 = and i32 %21, 63
store i32 %22, i32* %6
%23 = load i16*, i16** %4
%24 = getelementptr inbounds i16, i16* %23, i64 6370
%25 = load volatile i16, i16* %24
%26 = zext i16 %25 to i32
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = and i32 %27, -1009
%29 = load i32, i32* %6
%30 = shl i32 %29, 4
%31 = or i32 %28, %30
%32 = trunc i32 %31 to i16
%33 = load i16*, i16** %4
%34 = getelementptr inbounds i16, i16* %33, i64 6370
store volatile i16 %32, i16* %34
store i32 0, i32* %3
br label %35
35: ; preds = %19, %15
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"pollux_set: invalid lcd clkdiv0: %d\0A\00"
define i32 @apply_dpc_clkdiv0(i16* %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
%4 = load i32, i32* %3
%5 = add nsw i32 %4, -1
%6 = icmp ult i32 %5, 64
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %18
10: ; preds = %2
%11 = getelementptr inbounds i16, i16* %0, i64 6370
%12 = load volatile i16, i16* %11
%13 = and i16 %12, -1009
%14 = trunc i32 %5 to i16
%15 = shl nuw nsw i16 %14, 4
%16 = and i16 %15, 1008
%17 = or i16 %13, %16
store volatile i16 %17, i16* %11
br label %18
18: ; preds = %10, %7
%19 = phi i32 [ -1, %7 ], [ 0, %10 ]
ret i32 %19
}