#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 unsigned long *)(ui32GenBase + 0x00000010)));
  if (((ui32PWMOut)&0x00000001)) {
    ui32Reg = (*((volatile unsigned long *)(ui32GenBase + 0x0000001C)));
  } else {
    ui32Reg = (*((volatile unsigned long *)(ui32GenBase + 0x00000018)));
  }
  ui32Reg = ui32Load - ui32Reg;
  if ((*((volatile unsigned long *)(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),%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1148 <PWMPulseWidthGet+0x48>
mov    -0xc(%rbp),%eax
add    $0x1c,%eax
cltq
mov    (%rax),%rax
mov    %eax,-0x10(%rbp)
jmp    1156 <PWMPulseWidthGet+0x56>
mov    -0xc(%rbp),%eax
add    $0x18,%eax
cltq
mov    (%rax),%rax
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),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1181 <PWMPulseWidthGet+0x81>
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),%rax
and    $0x1,%esi
lea    0x18(,%rsi,4),%edx
mov    (%rdx,%rcx,1),%rdx
sub    %edx,%eax
mov    (%rcx),%rcx
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 i64*
%16 = load volatile i64, i64* %15
%17 = trunc i64 %16 to i32
store i32 %17, i32* %7
%18 = load i32, i32* %4
%19 = and i32 %18, 1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 28
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i64*
%26 = load volatile i64, i64* %25
%27 = trunc i64 %26 to i32
store i32 %27, i32* %6
br label %35
28: ; preds = %2
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 24
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i64*
%33 = load volatile i64, i64* %32
%34 = trunc i64 %33 to i32
store i32 %34, i32* %6
br label %35
35: ; preds = %28, %21
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = sub nsw i32 %36, %37
store i32 %38, i32* %6
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 0
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i64*
%43 = load volatile i64, i64* %42
%44 = and i64 %43, 2
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = load i32, i32* %6
%48 = mul nsw i32 %47, 2
store i32 %48, i32* %6
br label %49
49: ; preds = %46, %35
%50 = load i32, i32* %6
ret i32 %50
}

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 i64*
%8 = load volatile i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = and i32 %1, 1
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 24, i32 28
%13 = add nsw i32 %12, %4
%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 %9, %17
%19 = sext i32 %4 to i64
%20 = inttoptr i64 %19 to i64*
%21 = load volatile i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = lshr i32 %22, 1
%24 = and i32 %23, 1
%25 = shl nsw i32 %18, %24
ret i32 %25
}