#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 uint32_t *)(ui32GenBase + 0x00000000))) & 0x00000002) {
    ui32Width /= 2;
  }
  ui32Reg = (*((volatile uint32_t *)(ui32GenBase + 0x00000010)));
  ;
  ui32Reg = ui32Reg - ui32Width;
  if (((ui32PWMOut)&0x00000001)) {
    (*((volatile uint32_t *)(ui32GenBase + 0x0000001C))) = ui32Reg;
  } else {
    (*((volatile uint32_t *)(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),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     113f <PWMPulseWidthSet+0x3f>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%eax
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     1176 <PWMPulseWidthSet+0x76>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%eax
add    $0x1c,%eax
cltq
mov    %ecx,(%rax)
jmp    1183 <PWMPulseWidthSet+0x83>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%eax
add    $0x18,%eax
cltq
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMPulseWidthSet>:
mov    %esi,%eax
and    $0xffffffc0,%eax
add    %edi,%eax
cltq
testl  $0x2,(%rax)
je     111c <PWMPulseWidthSet+0x1c>
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
mov    %ecx,%edx
mov    0x10(%rax),%ecx
sub    %edx,%ecx
and    $0x1,%esi
lea    0x18(,%rsi,4),%edx
mov    %ecx,(%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 i32*
%17 = load volatile i32, i32* %16
%18 = and i32 %17, 2
%19 = icmp ne i32 %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 i32*
%28 = load volatile i32, i32* %27
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = load i32, i32* %6
%31 = sub nsw i32 %29, %30
store i32 %31, i32* %8
%32 = load i32, i32* %5
%33 = and i32 %32, 1
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %23
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 28
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
store volatile i32 %36, i32* %40
br label %47
41: ; preds = %23
%42 = load i32, i32* %8
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 24
%45 = sext i32 %44 to i64
%46 = inttoptr i64 %45 to i32*
store volatile i32 %42, i32* %46
br label %47
47: ; preds = %41, %35
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 i32*
%8 = load volatile i32, i32* %7
%9 = and i32 %8, 2
%10 = icmp eq i32 %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 i32*
%16 = load volatile i32, i32* %15
%17 = sub nsw i32 %16, %12
%18 = and i32 %1, 1
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i32 24, i32 28
%21 = add nsw i32 %5, %20
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
store volatile i32 %17, i32* %23
ret void
}