#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 CANMessageClear(unsigned long ulBase, unsigned long ulObjID) {
  ;
  ;
  while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
  }
  CANRegWrite(ulBase + 0x00000024, 0x00000080 | 0x00000020);
  CANRegWrite(ulBase + 0x00000030, 0);
  CANRegWrite(ulBase + 0x00000034, 0);
  CANRegWrite(ulBase + 0x00000020, ulObjID & 0x0000003F);
}


x86 assembly (clang, -O0):
<CANMessageClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     1150 <CANMessageClear+0x30>
jmp    1130 <CANMessageClear+0x10>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0xa0,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x34,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
and    $0x3f,%rsi
call   1030 <CANRegWrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANMessageClear>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x20(%rdi),%rbx
nop
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    1130 <CANMessageClear+0x10>
lea    0x24(%r15),%rdi
mov    $0xa0,%esi
call   1030 <CANRegWrite@plt>
lea    0x30(%r15),%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
add    $0x34,%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
and    $0x3f,%r14d
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <CANRegWrite@plt>

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

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