#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 */

/* Variables and functions */
int CANRegRead(unsigned long);
int /*<<< orphan*/ CANRegWrite(unsigned long, unsigned long);
void CANIntClear(unsigned long ulBase, unsigned long ulIntClr) {
  ;

  ;
  if (ulIntClr == 0x00008000) {
    CANRegRead(ulBase + 0x00000004);
  } else {
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
    CANRegWrite(ulBase + 0x00000024, 0x00000008);
    CANRegWrite(ulBase + 0x00000020, ulIntClr & 0x0000003F);
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
  }
}


x86 assembly (clang, -O0):
<CANIntClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x8000,-0x10(%rbp)
jne    1150 <CANIntClear+0x30>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1040 <CANRegRead@plt>
jmp    11c1 <CANIntClear+0xa1>
jmp    1155 <CANIntClear+0x35>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     1175 <CANIntClear+0x55>
jmp    1155 <CANIntClear+0x35>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0x8,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
and    $0x3f,%rsi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     11bc <CANIntClear+0x9c>
jmp    119c <CANIntClear+0x7c>
jmp    11c1 <CANIntClear+0xa1>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANIntClear>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
cmp    $0x8000,%rsi
jne    1142 <CANIntClear+0x22>
add    $0x4,%r15
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <CANRegRead@plt>
mov    %rsi,%r14
lea    0x20(%r15),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    1150 <CANIntClear+0x30>
add    $0x24,%r15
mov    $0x8,%esi
mov    %r15,%rdi
call   1030 <CANRegWrite@plt>
and    $0x3f,%r14d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <CANRegWrite@plt>
nop
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    1180 <CANIntClear+0x60>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @CANIntClear(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 32768
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i64, i64* %3
%9 = add i64 %8, 4
%10 = call i32 @CANRegRead(i64 %9)
br label %36
11: ; preds = %2
br label %12
12: ; preds = %18, %11
%13 = load i64, i64* %3
%14 = add i64 %13, 32
%15 = call i32 @CANRegRead(i64 %14)
%16 = and i32 %15, 32768
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
br label %12
19: ; preds = %12
%20 = load i64, i64* %3
%21 = add i64 %20, 36
%22 = call i32 @CANRegWrite(i64 %21, i64 8)
%23 = load i64, i64* %3
%24 = add i64 %23, 32
%25 = load i64, i64* %4
%26 = and i64 %25, 63
%27 = call i32 @CANRegWrite(i64 %24, i64 %26)
br label %28
28: ; preds = %34, %19
%29 = load i64, i64* %3
%30 = add i64 %29, 32
%31 = call i32 @CANRegRead(i64 %30)
%32 = and i32 %31, 32768
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %28
br label %28
35: ; preds = %28
br label %36
36: ; preds = %35, %7
ret void
}

LLVM IR (-O2):
define void @CANIntClear(i64 %0, i64 %1) {
%3 = icmp eq i64 %1, 32768
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = add i64 %0, 32
br label %9
6: ; preds = %2
%7 = add i64 %0, 4
%8 = tail call i32 @CANRegRead(i64 %7)
br label %22
9: ; preds = %4, %9
%10 = tail call i32 @CANRegRead(i64 %5)
%11 = and i32 %10, 32768
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9
%14 = add i64 %0, 36
%15 = tail call i32 @CANRegWrite(i64 %14, i64 8)
%16 = and i64 %1, 63
%17 = tail call i32 @CANRegWrite(i64 %5, i64 %16)
br label %18
18: ; preds = %18, %13
%19 = tail call i32 @CANRegRead(i64 %5)
%20 = and i32 %19, 32768
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %18
22: ; preds = %18, %6
ret void
}