#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 */
uint32_t PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut) {
  uint32_t ui32GenBase, ui32Reg, ui32Load;
  ;
  ;
  ui32GenBase = ((ui32Base) + ((ui32PWMOut)&0xFFFFFFC0));
  ui32Load = (*((volatile uint32_t *)(ui32GenBase + 0x00000010)));
  if (((ui32PWMOut)&0x00000001)) {
    ui32Reg = (*((volatile uint32_t *)(ui32GenBase + 0x0000001C)));
  } else {
    ui32Reg = (*((volatile uint32_t *)(ui32GenBase + 0x00000018)));
  }
  ui32Reg = ui32Load - ui32Reg;
  if ((*((volatile uint32_t *)(ui32GenBase + 0x00000000))) & 0x00000002) {
    ui32Reg = ui32Reg * 2;
  }
  return (ui32Reg);
}


x86 assembly (clang, -O0):
<PWMPulseWidthGet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0xffffffc0,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1146 <PWMPulseWidthGet+0x46>
mov    -0xc(%rbp),%eax
add    $0x1c,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <PWMPulseWidthGet+0x53>
mov    -0xc(%rbp),%eax
add    $0x18,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x0,%eax
cltq
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     117b <PWMPulseWidthGet+0x7b>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMPulseWidthGet>:
mov    %esi,%eax
and    $0xffffffc0,%eax
add    %edi,%eax
movslq %eax,%rcx
mov    0x10(%rcx),%eax
and    $0x1,%esi
lea    0x18(,%rsi,4),%edx
sub    (%rdx,%rcx,1),%eax
mov    (%rcx),%ecx
shr    %cl
and    $0x1,%cl
shl    %cl,%eax
ret

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

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