#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;
typedef scalar_t__ ui32PWMOut;
typedef int ui32Base;

/* Variables and functions */
void PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut,
                      uint32_t ui32Width) {
  uint32_t ui32GenBase, ui32Reg;
  ;
  ;
  ui32GenBase = ((ui32Base) + ((ui32PWMOut)&0xFFFFFFC0));
  if ((*((volatile unsigned long *)(ui32GenBase + 0x00000000))) & 0x00000002) {
    ui32Width /= 2;
  }
  ui32Reg = (*((volatile unsigned long *)(ui32GenBase + 0x00000010)));
  ;
  ui32Reg = ui32Reg - ui32Width;
  if (((ui32PWMOut)&0x00000001)) {
    (*((volatile unsigned long *)(ui32GenBase + 0x0000001C))) = ui32Reg;
  } else {
    (*((volatile unsigned long *)(ui32GenBase + 0x00000018))) = ui32Reg;
  }
}


x86 assembly (clang, -O0):
<PWMPulseWidthSet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0xffffffc0,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x0,%eax
cltq
mov    (%rax),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1142 <PWMPulseWidthSet+0x42>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117c <PWMPulseWidthSet+0x7c>
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%eax
add    $0x1c,%eax
cltq
mov    %rcx,(%rax)
jmp    118b <PWMPulseWidthSet+0x8b>
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%eax
add    $0x18,%eax
cltq
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMPulseWidthSet>:
mov    %esi,%eax
and    $0xffffffc0,%eax
add    %edi,%eax
cltq
testq  $0x2,(%rax)
je     111d <PWMPulseWidthSet+0x1d>
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
mov    %ecx,%edx
mov    0x10(%rax),%rcx
sub    %edx,%ecx
and    $0x1,%esi
movslq %ecx,%rcx
lea    0x18(,%rsi,4),%edx
mov    %rcx,(%rax,%rdx,1)
ret

LLVM IR (-O0):
define void @PWMPulseWidthSet(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = and i32 %10, -64
%12 = add i32 %9, %11
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 0
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i64*
%17 = load volatile i64, i64* %16
%18 = and i64 %17, 2
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i32, i32* %6
%22 = sdiv i32 %21, 2
store i32 %22, i32* %6
br label %23
23: ; preds = %20, %3
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 16
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i64*
%28 = load volatile i64, i64* %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
store i32 %32, i32* %8
%33 = load i32, i32* %5
%34 = and i32 %33, 1
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %23
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 28
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i64*
store volatile i64 %38, i64* %42
br label %50
43: ; preds = %23
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 24
%48 = sext i32 %47 to i64
%49 = inttoptr i64 %48 to i64*
store volatile i64 %45, i64* %49
br label %50
50: ; preds = %43, %36
ret void
}

LLVM IR (-O2):
define void @PWMPulseWidthSet(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %1, -64
%5 = add i32 %4, %0
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i64*
%8 = load volatile i64, i64* %7
%9 = and i64 %8, 2
%10 = icmp eq i64 %9, 0
%11 = sdiv i32 %2, 2
%12 = select i1 %10, i32 %2, i32 %11
%13 = add nsw i32 %5, 16
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i64*
%16 = load volatile i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = sub nsw i32 %17, %12
%19 = and i32 %1, 1
%20 = icmp eq i32 %19, 0
%21 = sext i32 %18 to i64
%22 = select i1 %20, i32 24, i32 28
%23 = add nsw i32 %5, %22
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i64*
store volatile i64 %21, i64* %25
ret void
}