#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 */
unsigned char PWMARRGet(unsigned long);
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel,
                unsigned char ulDuty) {
  unsigned long ulCMRData;
  ;
  ;
  ;
  ulCMRData = (PWMARRGet(ulBase) * ulDuty) / 100;
  if ((PWMARRGet(ulBase) * ulDuty) / 100 == 0) {
    ulCMRData = 0;
  }
  (*((volatile unsigned long *)(ulBase + 0x00000034 + ulChannel * 4))) &=
      ~0x0000FFFF;
  (*((volatile unsigned long *)(ulBase + 0x00000034 + ulChannel * 4))) |=
      ulCMRData;
}


x86 assembly (clang, -O0):
<PWMDutySet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <PWMARRGet@plt>
movzbl %al,%eax
movzbl -0x11(%rbp),%ecx
imul   %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <PWMARRGet@plt>
movzbl %al,%eax
movzbl -0x11(%rbp),%ecx
imul   %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jne    1172 <PWMDutySet+0x62>
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x34,%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    (%rax),%rcx
and    $0xffffffffffff0000,%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
add    $0x34,%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    (%rax),%rcx
or     %rdx,%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMDutySet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <PWMARRGet@plt>
movzbl %al,%eax
imul   %r15d,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%ebp
shr    $0x11,%ebp
mov    %rbx,%rdi
call   1030 <PWMARRGet@plt>
movzbl %al,%eax
imul   %r15d,%eax
xor    %ecx,%ecx
cmp    $0x64,%eax
cmovae %rbp,%rcx
andq   $0xffffffffffff0000,0x34(%rbx,%r14,4)
ff ff
or     %rcx,0x34(%rbx,%r14,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @PWMDutySet(i64 %0, i64 %1, i8 zeroext %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8
%7 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i8 %2, i8* %6
%8 = load i64, i64* %4
%9 = call zeroext i8 @PWMARRGet(i64 %8)
%10 = zext i8 %9 to i32
%11 = load i8, i8* %6
%12 = zext i8 %11 to i32
%13 = mul nsw i32 %10, %12
%14 = sdiv i32 %13, 100
%15 = sext i32 %14 to i64
store i64 %15, i64* %7
%16 = load i64, i64* %4
%17 = call zeroext i8 @PWMARRGet(i64 %16)
%18 = zext i8 %17 to i32
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = mul nsw i32 %18, %20
%22 = sdiv i32 %21, 100
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %3
store i64 0, i64* %7
br label %25
25: ; preds = %24, %3
%26 = load i64, i64* %4
%27 = add i64 %26, 52
%28 = load i64, i64* %5
%29 = mul i64 %28, 4
%30 = add i64 %27, %29
%31 = inttoptr i64 %30 to i64*
%32 = load volatile i64, i64* %31
%33 = and i64 %32, -65536
store volatile i64 %33, i64* %31
%34 = load i64, i64* %7
%35 = load i64, i64* %4
%36 = add i64 %35, 52
%37 = load i64, i64* %5
%38 = mul i64 %37, 4
%39 = add i64 %36, %38
%40 = inttoptr i64 %39 to i64*
%41 = load volatile i64, i64* %40
%42 = or i64 %41, %34
store volatile i64 %42, i64* %40
ret void
}

LLVM IR (-O2):
define void @PWMDutySet(i64 %0, i64 %1, i8 zeroext %2) {
%4 = tail call zeroext i8 @PWMARRGet(i64 %0)
%5 = zext i8 %4 to i32
%6 = zext i8 %2 to i32
%7 = mul nuw nsw i32 %5, %6
%8 = trunc i32 %7 to i16
%9 = udiv i16 %8, 100
%10 = zext i16 %9 to i64
%11 = tail call zeroext i8 @PWMARRGet(i64 %0)
%12 = zext i8 %11 to i32
%13 = mul nuw nsw i32 %12, %6
%14 = icmp ult i32 %13, 100
%15 = select i1 %14, i64 0, i64 %10
%16 = add i64 %0, 52
%17 = shl i64 %1, 2
%18 = add i64 %16, %17
%19 = inttoptr i64 %18 to i64*
%20 = load volatile i64, i64* %19
%21 = and i64 %20, -65536
store volatile i64 %21, i64* %19
%22 = load volatile i64, i64* %19
%23 = or i64 %15, %22
store volatile i64 %23, i64* %19
ret void
}