#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*/ DEBUG_ASSERT(int);
void FanChannelDutySet(unsigned long ulBase, unsigned long ulChannel,
                       unsigned long ulDuty) {
  DEBUG_ASSERT(ulBase == 0x40084000);
  DEBUG_ASSERT(ulChannel < 6);
  DEBUG_ASSERT(ulDuty < 512);
  (*((volatile unsigned long *)(ulBase + 0x00000014 + (ulChannel * 0x10)))) =
      (ulDuty << 16) & 0x01FF0000;
}


x86 assembly (clang, -O0):
<FanChannelDutySet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x40084000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x6,-0x10(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x200,-0x18(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x18(%rbp),%rcx
shl    $0x10,%rcx
and    $0x1ff0000,%rcx
mov    -0x8(%rbp),%rax
add    $0x14,%rax
mov    -0x10(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FanChannelDutySet>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x40084000,%r15
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x6,%r14
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x200,%rbx
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
shl    $0x10,%ebx
and    $0x1ff0000,%ebx
shl    $0x4,%r14
mov    %rbx,0x14(%r15,%r14,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @FanChannelDutySet(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 1074282496
%9 = zext i1 %8 to i32
%10 = call i32 @DEBUG_ASSERT(i32 %9)
%11 = load i64, i64* %5
%12 = icmp ult i64 %11, 6
%13 = zext i1 %12 to i32
%14 = call i32 @DEBUG_ASSERT(i32 %13)
%15 = load i64, i64* %6
%16 = icmp ult i64 %15, 512
%17 = zext i1 %16 to i32
%18 = call i32 @DEBUG_ASSERT(i32 %17)
%19 = load i64, i64* %6
%20 = shl i64 %19, 16
%21 = and i64 %20, 33488896
%22 = load i64, i64* %4
%23 = add i64 %22, 20
%24 = load i64, i64* %5
%25 = mul i64 %24, 16
%26 = add i64 %23, %25
%27 = inttoptr i64 %26 to i64*
store volatile i64 %21, i64* %27
ret void
}

LLVM IR (-O2):
define void @FanChannelDutySet(i64 %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %0, 1074282496
%5 = zext i1 %4 to i32
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = icmp ult i64 %1, 6
%8 = zext i1 %7 to i32
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = icmp ult i64 %2, 512
%11 = zext i1 %10 to i32
%12 = tail call i32 @DEBUG_ASSERT(i32 %11)
%13 = shl i64 %2, 16
%14 = and i64 %13, 33488896
%15 = add i64 %0, 20
%16 = shl i64 %1, 4
%17 = add i64 %15, %16
%18 = inttoptr i64 %17 to i64*
store volatile i64 %14, i64* %18
ret void
}