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

/* Variables and functions */
int /*<<< orphan*/ DEBUG_ASSERT(int);
int PWMGenValid(unsigned long);
unsigned long PWMGenFaultTriggerGet(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) + (ulGen)) + 0x00000034))));
  } else {
    return ((*((volatile unsigned long *)(((ulBase) + (ulGen)) + 0x00000038))));
  }
}


x86 assembly (clang, -O0):
<PWMGenFaultTriggerGet>:
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 <PWMGenFaultTriggerGet+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 <PWMGenFaultTriggerGet+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    11ba <PWMGenFaultTriggerGet+0x9a>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    0x34(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <PWMGenFaultTriggerGet+0xaa>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i64 @PWMGenFaultTriggerGet(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 %38
31: ; preds = %25
%32 = load i64, i64* %5
%33 = load i64, i64* %6
%34 = add i64 %32, %33
%35 = add i64 %34, 52
%36 = inttoptr i64 %35 to i64*
%37 = load volatile i64, i64* %36
store i64 %37, i64* %4
br label %45
38: ; preds = %25
%39 = load i64, i64* %5
%40 = load i64, i64* %6
%41 = add i64 %39, %40
%42 = add i64 %41, 56
%43 = inttoptr i64 %42 to i64*
%44 = load volatile i64, i64* %43
store i64 %44, i64* %4
br label %45
45: ; preds = %38, %31
%46 = load i64, i64* %4
ret i64 %46
}

LLVM IR (-O2):
define i64 @PWMGenFaultTriggerGet(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 = add i64 %1, %0
%15 = select i1 %10, i64 52, i64 56
%16 = add i64 %14, %15
%17 = inttoptr i64 %16 to i64*
%18 = load volatile i64, i64* %17
ret i64 %18
}