#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, int);
void CANInit(unsigned long ulBase) {
  int iMsg;
  {
    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",
          473);
    }
  };
  CANRegWrite(ulBase + 0x00000000, 0x00000001);
  while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
  }
  CANRegWrite(ulBase + 0x00000024, 0x00000080 | 0x00000020 | 0x00000010);
  CANRegWrite(ulBase + 0x00000034, 0);
  CANRegWrite(ulBase + 0x00000038, 0);
  for (iMsg = 1; iMsg <= 32; iMsg++) {
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
    CANRegWrite(ulBase + 0x00000020, iMsg);
  }
  CANRegWrite(ulBase + 0x00000024, 0x00000004 | 0x00000008);
  for (iMsg = 1; iMsg <= 32; iMsg++) {
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
    CANRegWrite(ulBase + 0x00000020, iMsg);
  }
  CANRegRead(ulBase + 0x00000004);
}


x86 assembly (clang, -O0):
<CANInit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <CANBaseValid@plt>
cmp    $0x0,%eax
jne    116f <CANInit+0x2f>
lea    0xe9b(%rip),%rdi
mov    $0x1d9,%esi
call   1040 <AssertFailure@plt>
mov    -0x8(%rbp),%rdi
add    $0x0,%rdi
mov    $0x1,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     11a1 <CANInit+0x61>
jmp    1181 <CANInit+0x41>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0xb0,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x34,%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x38,%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jg     1225 <CANInit+0xe5>
jmp    11e7 <CANInit+0xa7>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     1207 <CANInit+0xc7>
jmp    11e7 <CANInit+0xa7>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0xc(%rbp),%esi
call   1030 <CANRegWrite@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <CANInit+0x98>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0xc,%esi
call   1030 <CANRegWrite@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jg     128b <CANInit+0x14b>
jmp    124d <CANInit+0x10d>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1050 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     126d <CANInit+0x12d>
jmp    124d <CANInit+0x10d>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0xc(%rbp),%esi
call   1030 <CANRegWrite@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    123e <CANInit+0xfe>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1050 <CANRegRead@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANInit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <CANBaseValid@plt>
test   %eax,%eax
jne    1164 <CANInit+0x24>
lea    0xea6(%rip),%rdi
mov    $0x1d9,%esi
call   1040 <AssertFailure@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <CANRegWrite@plt>
lea    0x20(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    1180 <CANInit+0x40>
lea    0x24(%r14),%r15
mov    %r15,%rdi
mov    $0xb0,%esi
call   1030 <CANRegWrite@plt>
lea    0x34(%r14),%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
lea    0x38(%r14),%rdi
xor    %esi,%esi
call   1030 <CANRegWrite@plt>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    11c0 <CANInit+0x80>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <CANRegWrite@plt>
add    $0x1,%ebp
cmp    $0x21,%ebp
jne    11c0 <CANInit+0x80>
mov    %r15,%rdi
mov    $0xc,%esi
call   1030 <CANRegWrite@plt>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <CANRegRead@plt>
test   $0x8000,%eax
jne    1200 <CANInit+0xc0>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <CANRegWrite@plt>
add    $0x1,%ebp
cmp    $0x21,%ebp
jne    1200 <CANInit+0xc0>
add    $0x4,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <CANRegRead@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 @CANInit(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i32 @CANBaseValid(i64 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 473)
br label %9
9: ; preds = %7, %1
%10 = load i64, i64* %2
%11 = add i64 %10, 0
%12 = call i32 @CANRegWrite(i64 %11, i32 1)
br label %13
13: ; preds = %19, %9
%14 = load i64, i64* %2
%15 = add i64 %14, 32
%16 = call i32 @CANRegRead(i64 %15)
%17 = and i32 %16, 32768
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13
br label %13
20: ; preds = %13
%21 = load i64, i64* %2
%22 = add i64 %21, 36
%23 = call i32 @CANRegWrite(i64 %22, i32 176)
%24 = load i64, i64* %2
%25 = add i64 %24, 52
%26 = call i32 @CANRegWrite(i64 %25, i32 0)
%27 = load i64, i64* %2
%28 = add i64 %27, 56
%29 = call i32 @CANRegWrite(i64 %28, i32 0)
store i32 1, i32* %3
br label %30
30: ; preds = %46, %20
%31 = load i32, i32* %3
%32 = icmp sle i32 %31, 32
br i1 %32, label %33, label %49
33: ; preds = %30
br label %34
34: ; preds = %40, %33
%35 = load i64, i64* %2
%36 = add i64 %35, 32
%37 = call i32 @CANRegRead(i64 %36)
%38 = and i32 %37, 32768
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
br label %34
41: ; preds = %34
%42 = load i64, i64* %2
%43 = add i64 %42, 32
%44 = load i32, i32* %3
%45 = call i32 @CANRegWrite(i64 %43, i32 %44)
br label %46
46: ; preds = %41
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %30
49: ; preds = %30
%50 = load i64, i64* %2
%51 = add i64 %50, 36
%52 = call i32 @CANRegWrite(i64 %51, i32 12)
store i32 1, i32* %3
br label %53
53: ; preds = %69, %49
%54 = load i32, i32* %3
%55 = icmp sle i32 %54, 32
br i1 %55, label %56, label %72
56: ; preds = %53
br label %57
57: ; preds = %63, %56
%58 = load i64, i64* %2
%59 = add i64 %58, 32
%60 = call i32 @CANRegRead(i64 %59)
%61 = and i32 %60, 32768
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %57
br label %57
64: ; preds = %57
%65 = load i64, i64* %2
%66 = add i64 %65, 32
%67 = load i32, i32* %3
%68 = call i32 @CANRegWrite(i64 %66, i32 %67)
br label %69
69: ; preds = %64
%70 = load i32, i32* %3
%71 = add nsw i32 %70, 1
store i32 %71, i32* %3
br label %53
72: ; preds = %53
%73 = load i64, i64* %2
%74 = add i64 %73, 4
%75 = call i32 @CANRegRead(i64 %74)
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 @CANInit(i64 %0) {
%2 = tail call i32 @CANBaseValid(i64 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 473)
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @CANRegWrite(i64 %0, i32 1)
%8 = add i64 %0, 32
br label %9
9: ; preds = %9, %6
%10 = tail call i32 @CANRegRead(i64 %8)
%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, i32 176)
%16 = add i64 %0, 52
%17 = tail call i32 @CANRegWrite(i64 %16, i32 0)
%18 = add i64 %0, 56
%19 = tail call i32 @CANRegWrite(i64 %18, i32 0)
br label %20
20: ; preds = %13, %26
%21 = phi i32 [ 1, %13 ], [ %28, %26 ]
br label %22
22: ; preds = %20, %22
%23 = tail call i32 @CANRegRead(i64 %8)
%24 = and i32 %23, 32768
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %22
26: ; preds = %22
%27 = tail call i32 @CANRegWrite(i64 %8, i32 %21)
%28 = add nuw nsw i32 %21, 1
%29 = icmp eq i32 %28, 33
br i1 %29, label %30, label %20
30: ; preds = %26
%31 = tail call i32 @CANRegWrite(i64 %14, i32 12)
br label %32
32: ; preds = %30, %38
%33 = phi i32 [ 1, %30 ], [ %40, %38 ]
br label %34
34: ; preds = %32, %34
%35 = tail call i32 @CANRegRead(i64 %8)
%36 = and i32 %35, 32768
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %34
38: ; preds = %34
%39 = tail call i32 @CANRegWrite(i64 %8, i32 %33)
%40 = add nuw nsw i32 %33, 1
%41 = icmp eq i32 %40, 33
br i1 %41, label %42, label %32
42: ; preds = %38
%43 = add i64 %0, 4
%44 = tail call i32 @CANRegRead(i64 %43)
ret void
}