#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 CANIntClear(unsigned long ulBase, unsigned long ulIntClr) {
  {
    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",
          1234);
    }
  };
  {
    if (!((ulIntClr == 0x00008000) || ((ulIntClr >= 1) && (ulIntClr <= 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",
          1235);
    }
  };
  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)
mov    -0x8(%rbp),%rdi
call   1060 <CANBaseValid@plt>
cmp    $0x0,%eax
jne    1173 <CANIntClear+0x33>
lea    0xe97(%rip),%rdi
mov    $0x4d2,%esi
call   1040 <AssertFailure@plt>
cmpq   $0x8000,-0x10(%rbp)
je     11a8 <CANIntClear+0x68>
cmpq   $0x1,-0x10(%rbp)
jb     1197 <CANIntClear+0x57>
cmpq   $0x20,-0x10(%rbp)
jbe    11a8 <CANIntClear+0x68>
lea    0xe62(%rip),%rdi
mov    $0x4d3,%esi
call   1040 <AssertFailure@plt>
cmpq   $0x8000,-0x10(%rbp)
jne    11c8 <CANIntClear+0x88>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1050 <CANRegRead@plt>
jmp    1239 <CANIntClear+0xf9>
jmp    11cd <CANIntClear+0x8d>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     11ed <CANIntClear+0xad>
jmp    11cd <CANIntClear+0x8d>
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   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     1234 <CANIntClear+0xf4>
jmp    1214 <CANIntClear+0xd4>
jmp    1239 <CANIntClear+0xf9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANIntClear>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <CANBaseValid@plt>
test   %eax,%eax
jne    1165 <CANIntClear+0x25>
lea    0xea5(%rip),%rdi
mov    $0x4d2,%esi
call   1040 <AssertFailure@plt>
cmp    $0x8000,%r14
je     1189 <CANIntClear+0x49>
lea    -0x1(%r14),%rax
cmp    $0x20,%rax
jb     1189 <CANIntClear+0x49>
lea    0xe81(%rip),%rdi
mov    $0x4d3,%esi
call   1040 <AssertFailure@plt>
cmp    $0x8000,%r14
jne    11a3 <CANIntClear+0x63>
add    $0x4,%r15
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <CANRegRead@plt>
lea    0x20(%r15),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    11b0 <CANIntClear+0x70>
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   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    11e0 <CANIntClear+0xa0>
pop    %rbx
pop    %r14
pop    %r15
ret

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 @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* %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 1234)
br label %10
10: ; preds = %8, %2
%11 = load i64, i64* %4
%12 = icmp eq i64 %11, 32768
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = load i64, i64* %4
%15 = icmp uge i64 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i64, i64* %4
%18 = icmp ule i64 %17, 32
br i1 %18, label %21, label %19
19: ; preds = %16, %13
%20 = call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 1235)
br label %21
21: ; preds = %19, %16, %10
%22 = load i64, i64* %4
%23 = icmp eq i64 %22, 32768
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i64, i64* %3
%26 = add i64 %25, 4
%27 = call i32 @CANRegRead(i64 %26)
br label %53
28: ; preds = %21
br label %29
29: ; preds = %35, %28
%30 = load i64, i64* %3
%31 = add i64 %30, 32
%32 = call i32 @CANRegRead(i64 %31)
%33 = and i32 %32, 32768
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %29
br label %29
36: ; preds = %29
%37 = load i64, i64* %3
%38 = add i64 %37, 36
%39 = call i32 @CANRegWrite(i64 %38, i64 8)
%40 = load i64, i64* %3
%41 = add i64 %40, 32
%42 = load i64, i64* %4
%43 = and i64 %42, 63
%44 = call i32 @CANRegWrite(i64 %41, i64 %43)
br label %45
45: ; preds = %51, %36
%46 = load i64, i64* %3
%47 = add i64 %46, 32
%48 = call i32 @CANRegRead(i64 %47)
%49 = and i32 %48, 32768
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %45
br label %45
52: ; preds = %45
br label %53
53: ; preds = %52, %24
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 @CANIntClear(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 1234)
br label %7
7: ; preds = %5, %2
%8 = icmp eq i64 %1, 32768
%9 = add i64 %1, -1
%10 = icmp ult i64 %9, 32
%11 = or i1 %8, %10
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 1235)
br label %14
14: ; preds = %12, %7
br i1 %8, label %17, label %15
15: ; preds = %14
%16 = add i64 %0, 32
br label %20
17: ; preds = %14
%18 = add i64 %0, 4
%19 = tail call i32 @CANRegRead(i64 %18)
br label %33
20: ; preds = %15, %20
%21 = tail call i32 @CANRegRead(i64 %16)
%22 = and i32 %21, 32768
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %20
24: ; preds = %20
%25 = add i64 %0, 36
%26 = tail call i32 @CANRegWrite(i64 %25, i64 8)
%27 = and i64 %1, 63
%28 = tail call i32 @CANRegWrite(i64 %16, i64 %27)
br label %29
29: ; preds = %29, %24
%30 = tail call i32 @CANRegRead(i64 %16)
%31 = and i32 %30, 32768
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %29
33: ; preds = %29, %17
ret void
}