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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int _PWMGenValid(int);
uint32_t PWMGenFaultStatus(uint32_t ui32Base, uint32_t ui32Gen,
                           uint32_t ui32Group) {
  ASSERT((ui32Base == 0x40028000) || (ui32Base == 0x40029000));
  ASSERT(_PWMGenValid(ui32Gen));
  ASSERT((ui32Group == 0) || (ui32Group == 1));
  if (ui32Group == 0) {
    return ((*((volatile uint32_t *)(((ui32Base) + 0x00000800 +
                                      ((ui32Gen)-0x00000040) * 2) +
                                     0x00000004))));
  } else {
    return ((*((volatile uint32_t *)(((ui32Base) + 0x00000800 +
                                      ((ui32Gen)-0x00000040) * 2) +
                                     0x00000008))));
  }
}


x86 assembly (clang, -O0):
<PWMGenFaultStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x40028000,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1150 <PWMGenFaultStatus+0x30>
cmpl   $0x40029000,-0x8(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
mov    -0xc(%rbp),%edi
call   1030 <_PWMGenValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
je     1185 <PWMGenFaultStatus+0x65>
cmpl   $0x1,-0x10(%rbp)
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11be <PWMGenFaultStatus+0x9e>
mov    -0x8(%rbp),%eax
add    $0x800,%eax
mov    -0xc(%rbp),%ecx
sub    $0x40,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
add    $0x4,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11db <PWMGenFaultStatus+0xbb>
mov    -0x8(%rbp),%eax
add    $0x800,%eax
mov    -0xc(%rbp),%ecx
sub    $0x40,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
add    $0x8,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMGenFaultStatus>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
mov    %edi,%eax
and    $0xffffefff,%eax
xor    %edi,%edi
cmp    $0x40028000,%eax
sete   %dil
call   1040 <ASSERT@plt>
mov    %r14d,%edi
call   1030 <_PWMGenValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
setne  %bl
xor    %edi,%edi
cmp    $0x2,%ebp
setb   %dil
call   1040 <ASSERT@plt>
lea    (%r15,%rbx,4),%eax
lea    (%rax,%r14,2),%eax
add    $0x784,%eax
cltq
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PWMGenFaultStatus(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 1073905664
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1073909760
br label %13
13: ; preds = %10, %3
%14 = phi i1 [ true, %3 ], [ %12, %10 ]
%15 = zext i1 %14 to i32
%16 = call i32 @ASSERT(i32 %15)
%17 = load i32, i32* %6
%18 = call i32 @_PWMGenValid(i32 %17)
%19 = call i32 @ASSERT(i32 %18)
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %13
%23 = load i32, i32* %7
%24 = icmp eq i32 %23, 1
br label %25
25: ; preds = %22, %13
%26 = phi i1 [ true, %13 ], [ %24, %22 ]
%27 = zext i1 %26 to i32
%28 = call i32 @ASSERT(i32 %27)
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %25
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 2048
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 64
%36 = mul nsw i32 %35, 2
%37 = add nsw i32 %33, %36
%38 = add nsw i32 %37, 4
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
%41 = load volatile i32, i32* %40
store i32 %41, i32* %4
br label %53
42: ; preds = %25
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 2048
%45 = load i32, i32* %6
%46 = sub nsw i32 %45, 64
%47 = mul nsw i32 %46, 2
%48 = add nsw i32 %44, %47
%49 = add nsw i32 %48, 8
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i32*
%52 = load volatile i32, i32* %51
store i32 %52, i32* %4
br label %53
53: ; preds = %42, %31
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @PWMGenFaultStatus(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %0, -4097
%5 = icmp eq i32 %4, 1073905664
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = tail call i32 @_PWMGenValid(i32 %1)
%9 = tail call i32 @ASSERT(i32 %8)
%10 = icmp eq i32 %2, 0
%11 = icmp ult i32 %2, 2
%12 = zext i1 %11 to i32
%13 = tail call i32 @ASSERT(i32 %12)
%14 = shl i32 %1, 1
%15 = select i1 %10, i32 1924, i32 1928
%16 = add i32 %15, %0
%17 = add i32 %16, %14
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load volatile i32, i32* %19
ret i32 %20
}