#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 /*<<< orphan*/ AssertFailure(char *, int);
int /*<<< orphan*/ CANBaseValid(unsigned long);
int CANRegRead(unsigned long);
int /*<<< orphan*/ CANRegWrite(unsigned long, unsigned long);
void CANMessageClear(unsigned long ulBase, unsigned long ulObjID) {
  {
    if (!(CANBaseValid(ulBase))) {
      AssertFailure(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/"
          "Demo/ARMCM3_LM3S_EK_LM3S8962_Crossworks/Boot/lib/driverlib/canlib.c",
          2220);
    }
  };
  {
    if (!((ulObjID >= 1) && (ulObjID <= 32))) {
      AssertFailure(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/"
          "Demo/ARMCM3_LM3S_EK_LM3S8962_Crossworks/Boot/lib/driverlib/canlib.c",
          2221);
    }
  };
  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
call   1060 <CANBaseValid@plt>
cmp    $0x0,%eax
jne    1173 <CANMessageClear+0x33>
lea    0xe97(%rip),%rdi
mov    $0x8ac,%esi
call   1040 <AssertFailure@plt>
cmpq   $0x1,-0x10(%rbp)
jb     1189 <CANMessageClear+0x49>
cmpq   $0x20,-0x10(%rbp)
jbe    119a <CANMessageClear+0x5a>
lea    0xe70(%rip),%rdi
mov    $0x8ad,%esi
call   1040 <AssertFailure@plt>
jmp    119f <CANMessageClear+0x5f>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     11bf <CANMessageClear+0x7f>
jmp    119f <CANMessageClear+0x5f>
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
call   1060 <CANBaseValid@plt>
test   %eax,%eax
jne    1165 <CANMessageClear+0x25>
lea    0xea5(%rip),%rdi
mov    $0x8ac,%esi
call   1040 <AssertFailure@plt>
lea    -0x1(%r14),%rax
cmp    $0x20,%rax
jb     1180 <CANMessageClear+0x40>
lea    0xe8a(%rip),%rdi
mov    $0x8ad,%esi
call   1040 <AssertFailure@plt>
lea    0x20(%r15),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    1190 <CANMessageClear+0x50>
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):
@.str = [200 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S8962_Crossworks/Boot/lib/driverlib/canlib.c\00"
define void @CANMessageClear(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = call i32 @CANBaseValid(i64 %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 2220)
br label %10
10: ; preds = %8, %2
%11 = load i64, i64* %4
%12 = icmp uge i64 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i64, i64* %4
%15 = icmp ule i64 %14, 32
br i1 %15, label %18, label %16
16: ; preds = %13, %10
%17 = call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 2221)
br label %18
18: ; preds = %16, %13
br label %19
19: ; preds = %25, %18
%20 = load i64, i64* %3
%21 = add i64 %20, 32
%22 = call i32 @CANRegRead(i64 %21)
%23 = and i32 %22, 32768
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
br label %19
26: ; preds = %19
%27 = load i64, i64* %3
%28 = add i64 %27, 36
%29 = call i32 @CANRegWrite(i64 %28, i64 160)
%30 = load i64, i64* %3
%31 = add i64 %30, 48
%32 = call i32 @CANRegWrite(i64 %31, i64 0)
%33 = load i64, i64* %3
%34 = add i64 %33, 52
%35 = call i32 @CANRegWrite(i64 %34, i64 0)
%36 = load i64, i64* %3
%37 = add i64 %36, 32
%38 = load i64, i64* %4
%39 = and i64 %38, 63
%40 = call i32 @CANRegWrite(i64 %37, i64 %39)
ret void
}

LLVM IR (-O2):
@.str = [200 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S8962_Crossworks/Boot/lib/driverlib/canlib.c\00"
define void @CANMessageClear(i64 %0, i64 %1) {
%3 = tail call i32 @CANBaseValid(i64 %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 2220)
br label %7
7: ; preds = %5, %2
%8 = add i64 %1, -1
%9 = icmp ult i64 %8, 32
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 2221)
br label %12
12: ; preds = %7, %10
%13 = add i64 %0, 32
br label %14
14: ; preds = %14, %12
%15 = tail call i32 @CANRegRead(i64 %13)
%16 = and i32 %15, 32768
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %14
18: ; preds = %14
%19 = add i64 %0, 36
%20 = tail call i32 @CANRegWrite(i64 %19, i64 160)
%21 = add i64 %0, 48
%22 = tail call i32 @CANRegWrite(i64 %21, i64 0)
%23 = add i64 %0, 52
%24 = tail call i32 @CANRegWrite(i64 %23, i64 0)
%25 = and i64 %1, 63
%26 = tail call i32 @CANRegWrite(i64 %13, i64 %25)
ret void
}