#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);
void PWMGenFaultClear(unsigned long ulBase, unsigned long ulGen,
                      unsigned long ulGroup, unsigned long ulFaultTriggers) {
  DEBUG_ASSERT((ulBase == 0x40028000) || (ulBase == 0x40029000));
  DEBUG_ASSERT(PWMGenValid(ulGen));
  DEBUG_ASSERT((ulGroup == 0) || (ulGroup == 1));
  DEBUG_ASSERT((ulGroup == 0) &&
               ((ulFaultTriggers &
                 ~(0x00000001 | 0x00000002 | 0x00000004 | 0x00000008)) == 0));
  DEBUG_ASSERT((ulGroup == 1) &&
               ((ulFaultTriggers &
                 ~(0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 |
                   0x00000010 | 0x00000020 | 0x00000040 | 0x00000080)) == 0));
  if (ulGroup == 0) {
    (*((volatile unsigned long *)(((ulBase) + 0x00000800 +
                                   ((ulGen)-0x00000040) * 2) +
                                  0x00000004))) = ulFaultTriggers;
  } else {
    (*((volatile unsigned long *)(((ulBase) + 0x00000800 +
                                   ((ulGen)-0x00000040) * 2) +
                                  0x00000008))) = ulFaultTriggers;
  }
}


x86 assembly (clang, -O0):
<PWMGenFaultClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x1,%al
cmpq   $0x40028000,-0x8(%rbp)
40
mov    %al,-0x21(%rbp)
je     1159 <PWMGenFaultClear+0x39>
cmpq   $0x40029000,-0x8(%rbp)
40
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rdi
call   1040 <PWMGenValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    $0x1,%al
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x22(%rbp)
je     1191 <PWMGenFaultClear+0x71>
cmpq   $0x1,-0x18(%rbp)
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x23(%rbp)
jne    11c0 <PWMGenFaultClear+0xa0>
mov    -0x20(%rbp),%rax
and    $0xfffffffffffffff0,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %eax,%eax
cmpq   $0x1,-0x18(%rbp)
mov    %al,-0x24(%rbp)
jne    11f1 <PWMGenFaultClear+0xd1>
mov    -0x20(%rbp),%rax
and    $0xffffffffffffff00,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x24(%rbp)
mov    -0x24(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0x0,-0x18(%rbp)
jne    122f <PWMGenFaultClear+0x10f>
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0x800,%rax
mov    -0x10(%rbp),%rdx
sub    $0x40,%rdx
shl    $0x1,%rdx
add    %rdx,%rax
mov    %rcx,0x4(%rax)
jmp    1250 <PWMGenFaultClear+0x130>
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0x800,%rax
mov    -0x10(%rbp),%rdx
sub    $0x40,%rdx
shl    $0x1,%rdx
add    %rdx,%rax
mov    %rcx,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PWMGenFaultClear>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r13
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   %r13,%r13
setne  %bl
sete   %bpl
xor    %edi,%edi
cmp    $0x1,%r13
sete   %r13b
setbe  %dil
call   1030 <DEBUG_ASSERT@plt>
cmp    $0x10,%r12
setb   %al
and    %bpl,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmp    $0x100,%r12
setb   %al
and    %r13b,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
lea    (%r15,%rbx,4),%rax
mov    %r12,0x784(%rax,%r14,2)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @PWMGenFaultClear(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%9 = load i64, i64* %5
%10 = icmp eq i64 %9, 1073905664
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load i64, i64* %5
%13 = icmp eq i64 %12, 1073909760
br label %14
14: ; preds = %11, %4
%15 = phi i1 [ true, %4 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = call i32 @DEBUG_ASSERT(i32 %16)
%18 = load i64, i64* %6
%19 = call i32 @PWMGenValid(i64 %18)
%20 = call i32 @DEBUG_ASSERT(i32 %19)
%21 = load i64, i64* %7
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %14
%24 = load i64, i64* %7
%25 = icmp eq i64 %24, 1
br label %26
26: ; preds = %23, %14
%27 = phi i1 [ true, %14 ], [ %25, %23 ]
%28 = zext i1 %27 to i32
%29 = call i32 @DEBUG_ASSERT(i32 %28)
%30 = load i64, i64* %7
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i64, i64* %8
%34 = and i64 %33, -16
%35 = icmp eq i64 %34, 0
br label %36
36: ; preds = %32, %26
%37 = phi i1 [ false, %26 ], [ %35, %32 ]
%38 = zext i1 %37 to i32
%39 = call i32 @DEBUG_ASSERT(i32 %38)
%40 = load i64, i64* %7
%41 = icmp eq i64 %40, 1
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load i64, i64* %8
%44 = and i64 %43, -256
%45 = icmp eq i64 %44, 0
br label %46
46: ; preds = %42, %36
%47 = phi i1 [ false, %36 ], [ %45, %42 ]
%48 = zext i1 %47 to i32
%49 = call i32 @DEBUG_ASSERT(i32 %48)
%50 = load i64, i64* %7
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %62
52: ; preds = %46
%53 = load i64, i64* %8
%54 = load i64, i64* %5
%55 = add i64 %54, 2048
%56 = load i64, i64* %6
%57 = sub i64 %56, 64
%58 = mul i64 %57, 2
%59 = add i64 %55, %58
%60 = add i64 %59, 4
%61 = inttoptr i64 %60 to i64*
store volatile i64 %53, i64* %61
br label %72
62: ; preds = %46
%63 = load i64, i64* %8
%64 = load i64, i64* %5
%65 = add i64 %64, 2048
%66 = load i64, i64* %6
%67 = sub i64 %66, 64
%68 = mul i64 %67, 2
%69 = add i64 %65, %68
%70 = add i64 %69, 8
%71 = inttoptr i64 %70 to i64*
store volatile i64 %63, i64* %71
br label %72
72: ; preds = %62, %52
ret void
}

LLVM IR (-O2):
define void @PWMGenFaultClear(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = and i64 %0, -4097
%6 = icmp eq i64 %5, 1073905664
%7 = zext i1 %6 to i32
%8 = tail call i32 @DEBUG_ASSERT(i32 %7)
%9 = tail call i32 @PWMGenValid(i64 %1)
%10 = tail call i32 @DEBUG_ASSERT(i32 %9)
%11 = icmp eq i64 %2, 0
%12 = icmp eq i64 %2, 1
%13 = icmp ult i64 %2, 2
%14 = zext i1 %13 to i32
%15 = tail call i32 @DEBUG_ASSERT(i32 %14)
%16 = icmp ult i64 %3, 16
%17 = and i1 %11, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @DEBUG_ASSERT(i32 %18)
%20 = icmp ult i64 %3, 256
%21 = and i1 %12, %20
%22 = zext i1 %21 to i32
%23 = tail call i32 @DEBUG_ASSERT(i32 %22)
%24 = shl i64 %1, 1
%25 = select i1 %11, i64 1924, i64 1928
%26 = add i64 %25, %0
%27 = add i64 %26, %24
%28 = inttoptr i64 %27 to i64*
store volatile i64 %3, i64* %28
ret void
}