#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 ulGen;
typedef scalar_t__ ulBase;

/* Variables and functions */
int /*<<< orphan*/ DEBUG_ASSERT(int);
int PWMGenValid(unsigned long);
unsigned long PWMGenFaultStatus(unsigned long ulBase, unsigned long ulGen,
                                unsigned long ulGroup) {
  DEBUG_ASSERT((ulBase == 0x40028000) || (ulBase == 0x40029000));
  DEBUG_ASSERT(PWMGenValid(ulGen));
  DEBUG_ASSERT((ulGroup == 0) || (ulGroup == 1));
  if (ulGroup == 0) {
    return ((*((volatile unsigned long *)(((ulBase) + 0x00000800 +
                                           ((ulGen)-0x00000040) * 2) +
                                          0x00000004))));
  } else {
    return ((*((volatile unsigned long *)(((ulBase) + 0x00000800 +
                                           ((ulGen)-0x00000040) * 2) +
                                          0x00000008))));
  }
}


x86 assembly (clang, -O0):
<PWMGenFaultStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x1,%al
cmpq   $0x40028000,-0x10(%rbp)
40
mov    %al,-0x21(%rbp)
je     1155 <PWMGenFaultStatus+0x35>
cmpq   $0x40029000,-0x10(%rbp)
40
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x18(%rbp),%rdi
call   1040 <PWMGenValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x1,%al
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x22(%rbp)
je     118d <PWMGenFaultStatus+0x6d>
cmpq   $0x1,-0x20(%rbp)
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11cb <PWMGenFaultStatus+0xab>
mov    -0x10(%rbp),%rax
add    $0x800,%rax
mov    -0x18(%rbp),%rcx
sub    $0x40,%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    0x4(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11ec <PWMGenFaultStatus+0xcc>
mov    -0x10(%rbp),%rax
add    $0x800,%rax
mov    -0x18(%rbp),%rcx
sub    $0x40,%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMGenFaultStatus>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdi,%rax
and    $0xffffffffffffefff,%rax
xor    %edi,%edi
cmp    $0x40028000,%rax
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r14,%rdi
call   1040 <PWMGenValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %ebx,%ebx
test   %r12,%r12
setne  %bl
xor    %edi,%edi
cmp    $0x2,%r12
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
lea    (%r15,%rbx,4),%rax
mov    0x784(%rax,%r14,2),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @PWMGenFaultStatus(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %5
%9 = icmp eq i64 %8, 1073905664
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i64, i64* %5
%12 = icmp eq i64 %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 @DEBUG_ASSERT(i32 %15)
%17 = load i64, i64* %6
%18 = call i32 @PWMGenValid(i64 %17)
%19 = call i32 @DEBUG_ASSERT(i32 %18)
%20 = load i64, i64* %7
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %13
%23 = load i64, i64* %7
%24 = icmp eq i64 %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 @DEBUG_ASSERT(i32 %27)
%29 = load i64, i64* %7
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %25
%32 = load i64, i64* %5
%33 = add i64 %32, 2048
%34 = load i64, i64* %6
%35 = sub i64 %34, 64
%36 = mul i64 %35, 2
%37 = add i64 %33, %36
%38 = add i64 %37, 4
%39 = inttoptr i64 %38 to i64*
%40 = load volatile i64, i64* %39
store i64 %40, i64* %4
br label %51
41: ; preds = %25
%42 = load i64, i64* %5
%43 = add i64 %42, 2048
%44 = load i64, i64* %6
%45 = sub i64 %44, 64
%46 = mul i64 %45, 2
%47 = add i64 %43, %46
%48 = add i64 %47, 8
%49 = inttoptr i64 %48 to i64*
%50 = load volatile i64, i64* %49
store i64 %50, i64* %4
br label %51
51: ; preds = %41, %31
%52 = load i64, i64* %4
ret i64 %52
}

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