#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);
void PWMGenFaultClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group,
                      uint32_t ui32FaultTriggers) {
  ASSERT((ui32Base == 0x40028000) || (ui32Base == 0x40029000));
  ASSERT(_PWMGenValid(ui32Gen));
  ASSERT((ui32Group == 0) || (ui32Group == 1));
  ASSERT((ui32Group == 0) &&
         ((ui32FaultTriggers &
           ~(0x00000001 | 0x00000002 | 0x00000004 | 0x00000008)) == 0));
  ASSERT((ui32Group == 1) &&
         ((ui32FaultTriggers &
           ~(0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 |
             0x00000020 | 0x00000040 | 0x00000080)) == 0));
  if (ui32Group == 0) {
    (*((volatile uint32_t *)(((ui32Base) + 0x00000800 +
                              ((ui32Gen)-0x00000040) * 2) +
                             0x00000004))) = ui32FaultTriggers;
  } else {
    (*((volatile uint32_t *)(((ui32Base) + 0x00000800 +
                              ((ui32Gen)-0x00000040) * 2) +
                             0x00000008))) = ui32FaultTriggers;
  }
}


x86 assembly (clang, -O0):
<PWMGenFaultClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x40028000,-0x4(%rbp)
mov    %al,-0x11(%rbp)
je     1153 <PWMGenFaultClear+0x33>
cmpl   $0x40029000,-0x4(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
mov    -0x8(%rbp),%edi
call   1030 <_PWMGenValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x12(%rbp)
je     1188 <PWMGenFaultClear+0x68>
cmpl   $0x1,-0xc(%rbp)
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x13(%rbp)
jne    11b3 <PWMGenFaultClear+0x93>
mov    -0x10(%rbp),%eax
and    $0xfffffff0,%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
xor    %eax,%eax
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0x14(%rbp)
jne    11e0 <PWMGenFaultClear+0xc0>
mov    -0x10(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x14(%rbp)
mov    -0x14(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1219 <PWMGenFaultClear+0xf9>
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x800,%eax
mov    -0x8(%rbp),%edx
sub    $0x40,%edx
shl    $0x1,%edx
add    %edx,%eax
add    $0x4,%eax
cltq
mov    %ecx,(%rax)
jmp    1236 <PWMGenFaultClear+0x116>
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x800,%eax
mov    -0x8(%rbp),%edx
sub    $0x40,%edx
shl    $0x1,%edx
add    %edx,%eax
add    $0x8,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @PWMGenFaultClear(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1073905664
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load i32, i32* %5
%13 = icmp eq i32 %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 @ASSERT(i32 %16)
%18 = load i32, i32* %6
%19 = call i32 @_PWMGenValid(i32 %18)
%20 = call i32 @ASSERT(i32 %19)
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %14
%24 = load i32, i32* %7
%25 = icmp eq i32 %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 @ASSERT(i32 %28)
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32, i32* %8
%34 = and i32 %33, -16
%35 = icmp eq i32 %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 @ASSERT(i32 %38)
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load i32, i32* %8
%44 = and i32 %43, -256
%45 = icmp eq i32 %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 @ASSERT(i32 %48)
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %63
52: ; preds = %46
%53 = load i32, i32* %8
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 2048
%56 = load i32, i32* %6
%57 = sub nsw i32 %56, 64
%58 = mul nsw i32 %57, 2
%59 = add nsw i32 %55, %58
%60 = add nsw i32 %59, 4
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i32*
store volatile i32 %53, i32* %62
br label %74
63: ; preds = %46
%64 = load i32, i32* %8
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 2048
%67 = load i32, i32* %6
%68 = sub nsw i32 %67, 64
%69 = mul nsw i32 %68, 2
%70 = add nsw i32 %66, %69
%71 = add nsw i32 %70, 8
%72 = sext i32 %71 to i64
%73 = inttoptr i64 %72 to i32*
store volatile i32 %64, i32* %73
br label %74
74: ; preds = %63, %52
ret void
}

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