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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int _CANBaseValid(int);
void CANIntClear(uint32_t ui32Base, uint32_t ui32IntClr) {
  ASSERT(_CANBaseValid(ui32Base));
  ASSERT((ui32IntClr == 0x00008000) ||
         ((ui32IntClr >= 1) && (ui32IntClr <= 32)));
  if (ui32IntClr == 0x00008000) {
    (*((volatile uint32_t *)(ui32Base + 0x00000004)));
  } else {
    while ((*((volatile uint32_t *)(ui32Base + 0x00000020))) & 0x00008000) {
    }
    (*((volatile uint32_t *)(ui32Base + 0x00000024))) = 0x00000008;
    (*((volatile uint32_t *)(ui32Base + 0x00000020))) = ui32IntClr & 0x0000003F;
    while ((*((volatile uint32_t *)(ui32Base + 0x00000020))) & 0x00008000) {
    }
  }
}


x86 assembly (clang, -O0):
<CANIntClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <_CANBaseValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
mov    $0x1,%al
cmpl   $0x8000,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     116e <CANIntClear+0x4e>
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0xa(%rbp)
jl     1168 <CANIntClear+0x48>
cmpl   $0x20,-0x8(%rbp)
setle  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
cmpl   $0x8000,-0x8(%rbp)
jne    1197 <CANIntClear+0x77>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    (%rax),%eax
jmp    11f9 <CANIntClear+0xd9>
jmp    119c <CANIntClear+0x7c>
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     11b9 <CANIntClear+0x99>
jmp    119c <CANIntClear+0x7c>
mov    -0x4(%rbp),%eax
add    $0x24,%eax
cltq
movl   $0x8,(%rax)
mov    -0x8(%rbp),%ecx
and    $0x3f,%ecx
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     11f4 <CANIntClear+0xd4>
jmp    11d7 <CANIntClear+0xb7>
jmp    11f9 <CANIntClear+0xd9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANIntClear>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <_CANBaseValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
cmp    $0x8000,%ebx
sete   %al
lea    -0x1(%rbx),%ecx
cmp    $0x20,%ecx
setb   %cl
or     %al,%cl
movzbl %cl,%edi
call   1040 <ASSERT@plt>
movslq %ebp,%rax
cmp    $0x8000,%ebx
jne    1160 <CANIntClear+0x40>
mov    0x4(%rax),%eax
jmp    1189 <CANIntClear+0x69>
nop
testl  $0x8000,0x20(%rax)
jne    1160 <CANIntClear+0x40>
movl   $0x8,0x24(%rax)
and    $0x3f,%ebx
mov    %ebx,0x20(%rax)
cs nopw 0x0(%rax,%rax,1)
testl  $0x8000,0x20(%rax)
jne    1180 <CANIntClear+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @CANIntClear(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i32 @_CANBaseValid(i32 %5)
%7 = call i32 @ASSERT(i32 %6)
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 32768
br i1 %9, label %18, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 32
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br label %18
18: ; preds = %16, %2
%19 = phi i1 [ true, %2 ], [ %17, %16 ]
%20 = zext i1 %19 to i32
%21 = call i32 @ASSERT(i32 %20)
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 32768
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 4
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i32*
%29 = load volatile i32, i32* %28
br label %61
30: ; preds = %18
br label %31
31: ; preds = %39, %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 32
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i32*
%36 = load volatile i32, i32* %35
%37 = and i32 %36, 32768
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %31
br label %31
40: ; preds = %31
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 36
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i32*
store volatile i32 8, i32* %44
%45 = load i32, i32* %4
%46 = and i32 %45, 63
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 32
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
store volatile i32 %46, i32* %50
br label %51
51: ; preds = %59, %40
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 32
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to i32*
%56 = load volatile i32, i32* %55
%57 = and i32 %56, 32768
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %51
br label %51
60: ; preds = %51
br label %61
61: ; preds = %60, %24
ret void
}

LLVM IR (-O2):
define void @CANIntClear(i32 %0, i32 %1) {
%3 = tail call i32 @_CANBaseValid(i32 %0)
%4 = tail call i32 @ASSERT(i32 %3)
%5 = icmp eq i32 %1, 32768
%6 = add i32 %1, -1
%7 = icmp ult i32 %6, 32
%8 = or i1 %5, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @ASSERT(i32 %9)
br i1 %5, label %15, label %11
11: ; preds = %2
%12 = add nsw i32 %0, 32
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
br label %20
15: ; preds = %2
%16 = add nsw i32 %0, 4
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = load volatile i32, i32* %18
br label %33
20: ; preds = %11, %20
%21 = load volatile i32, i32* %14
%22 = and i32 %21, 32768
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %20
24: ; preds = %20
%25 = add nsw i32 %0, 36
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
store volatile i32 8, i32* %27
%28 = and i32 %1, 63
store volatile i32 %28, i32* %14
br label %29
29: ; preds = %29, %24
%30 = load volatile i32, i32* %14
%31 = and i32 %30, 32768
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %29
33: ; preds = %29, %15
ret void
}