#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 CANMessageClear(uint32_t ui32Base, uint32_t ui32ObjID) {
  ASSERT(_CANBaseValid(ui32Base));
  ASSERT((ui32ObjID >= 1) && (ui32ObjID <= 32));
  while ((*((volatile uint32_t *)(ui32Base + 0x00000020))) & 0x00008000) {
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000024))) = 0x00000080 | 0x00000020;
  (*((volatile uint32_t *)(ui32Base + 0x00000030))) = 0;
  (*((volatile uint32_t *)(ui32Base + 0x00000034))) = 0;
  (*((volatile uint32_t *)(ui32Base + 0x00000020))) = ui32ObjID & 0x0000003F;
}


x86 assembly (clang, -O0):
<CANMessageClear>:
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>
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     1156 <CANMessageClear+0x36>
cmpl   $0x20,-0x8(%rbp)
setle  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1180 <CANMessageClear+0x60>
jmp    1163 <CANMessageClear+0x43>
mov    -0x4(%rbp),%eax
add    $0x24,%eax
cltq
movl   $0xa0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x30,%eax
cltq
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x34,%eax
cltq
movl   $0x0,(%rax)
mov    -0x8(%rbp),%ecx
and    $0x3f,%ecx
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANMessageClear>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <_CANBaseValid@plt>
mov    %eax,%edi
call   1040 <ASSERT@plt>
lea    -0x1(%rbx),%eax
xor    %edi,%edi
cmp    $0x20,%eax
setb   %dil
call   1040 <ASSERT@plt>
movslq %ebp,%rax
nopw   0x0(%rax,%rax,1)
testl  $0x8000,0x20(%rax)
jne    1150 <CANMessageClear+0x30>
movl   $0xa0,0x24(%rax)
movl   $0x0,0x30(%rax)
movl   $0x0,0x34(%rax)
and    $0x3f,%ebx
mov    %ebx,0x20(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @CANMessageClear(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 sge i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 32
br label %13
13: ; preds = %10, %2
%14 = phi i1 [ false, %2 ], [ %12, %10 ]
%15 = zext i1 %14 to i32
%16 = call i32 @ASSERT(i32 %15)
br label %17
17: ; preds = %25, %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 32
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = load volatile i32, i32* %21
%23 = and i32 %22, 32768
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
br label %17
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 36
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
store volatile i32 160, i32* %30
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 48
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
store volatile i32 0, i32* %34
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 52
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
store volatile i32 0, i32* %38
%39 = load i32, i32* %4
%40 = and i32 %39, 63
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 32
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i32*
store volatile i32 %40, i32* %44
ret void
}

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