#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*/ CANBaseValid(unsigned long);
int CANRegRead(unsigned long);
int /*<<< orphan*/ CANRegWrite(unsigned long, unsigned long);
int /*<<< orphan*/ DEBUG_ASSERT(int /*<<< orphan*/);
void CANInit(unsigned long ulBase) {
  unsigned long ulMsg;
  DEBUG_ASSERT(CANBaseValid(ulBase));
  CANRegWrite(ulBase + 0x00000000, 0x00000001);
  while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
  }
  CANRegWrite(ulBase + 0x00000024, 0x00000080 | 0x00000020 | 0x00000010);
  CANRegWrite(ulBase + 0x00000034, 0);
  CANRegWrite(ulBase + 0x00000038, 0);
  for (ulMsg = 1; ulMsg <= 32; ulMsg++) {
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
    CANRegWrite(ulBase + 0x00000020, ulMsg);
  }
  CANRegWrite(ulBase + 0x00000024, 0x00000004 | 0x00000008);
  for (ulMsg = 1; ulMsg <= 32; ulMsg++) {
    while (CANRegRead(ulBase + 0x00000020) & 0x00008000) {
    }
    CANRegWrite(ulBase + 0x00000020, ulMsg);
  }
  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>
mov    %eax,%edi
call   1050 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rdi
add    $0x0,%rdi
mov    $0x1,%esi
call   1030 <CANRegWrite@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     118e <CANInit+0x4e>
jmp    116e <CANInit+0x2e>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0xb0,%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    $0x38,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <CANRegWrite@plt>
movq   $0x1,-0x10(%rbp)
cmpq   $0x20,-0x10(%rbp)
ja     121c <CANInit+0xdc>
jmp    11da <CANInit+0x9a>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     11fa <CANInit+0xba>
jmp    11da <CANInit+0x9a>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <CANRegWrite@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11ca <CANInit+0x8a>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    $0xc,%esi
call   1030 <CANRegWrite@plt>
movq   $0x1,-0x10(%rbp)
cmpq   $0x20,-0x10(%rbp)
ja     1288 <CANInit+0x148>
jmp    1246 <CANInit+0x106>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <CANRegRead@plt>
and    $0x8000,%eax
cmp    $0x0,%eax
je     1266 <CANInit+0x126>
jmp    1246 <CANInit+0x106>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <CANRegWrite@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1236 <CANInit+0xf6>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1040 <CANRegRead@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANInit>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <CANBaseValid@plt>
mov    %eax,%edi
call   1050 <DEBUG_ASSERT@plt>
mov    $0x1,%esi
mov    %r14,%rdi
call   1030 <CANRegWrite@plt>
lea    0x20(%r14),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    1170 <CANInit+0x30>
lea    0x24(%r14),%r15
mov    $0xb0,%esi
mov    %r15,%rdi
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,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    11b0 <CANInit+0x70>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <CANRegWrite@plt>
add    $0x1,%r12
cmp    $0x21,%r12
jne    11b0 <CANInit+0x70>
mov    $0xc,%esi
mov    %r15,%rdi
call   1030 <CANRegWrite@plt>
mov    $0x1,%r15d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <CANRegRead@plt>
test   $0x8000,%eax
jne    11f0 <CANInit+0xb0>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <CANRegWrite@plt>
add    $0x1,%r15
cmp    $0x21,%r15
jne    11f0 <CANInit+0xb0>
add    $0x4,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <CANRegRead@plt>

LLVM IR (-O0):
define void @CANInit(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i32 @CANBaseValid(i64 %4)
%6 = call i32 @DEBUG_ASSERT(i32 %5)
%7 = load i64, i64* %2
%8 = add i64 %7, 0
%9 = call i32 @CANRegWrite(i64 %8, i64 1)
br label %10
10: ; preds = %16, %1
%11 = load i64, i64* %2
%12 = add i64 %11, 32
%13 = call i32 @CANRegRead(i64 %12)
%14 = and i32 %13, 32768
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %10
17: ; preds = %10
%18 = load i64, i64* %2
%19 = add i64 %18, 36
%20 = call i32 @CANRegWrite(i64 %19, i64 176)
%21 = load i64, i64* %2
%22 = add i64 %21, 52
%23 = call i32 @CANRegWrite(i64 %22, i64 0)
%24 = load i64, i64* %2
%25 = add i64 %24, 56
%26 = call i32 @CANRegWrite(i64 %25, i64 0)
store i64 1, i64* %3
br label %27
27: ; preds = %43, %17
%28 = load i64, i64* %3
%29 = icmp ule i64 %28, 32
br i1 %29, label %30, label %46
30: ; preds = %27
br label %31
31: ; preds = %37, %30
%32 = load i64, i64* %2
%33 = add i64 %32, 32
%34 = call i32 @CANRegRead(i64 %33)
%35 = and i32 %34, 32768
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
br label %31
38: ; preds = %31
%39 = load i64, i64* %2
%40 = add i64 %39, 32
%41 = load i64, i64* %3
%42 = call i32 @CANRegWrite(i64 %40, i64 %41)
br label %43
43: ; preds = %38
%44 = load i64, i64* %3
%45 = add i64 %44, 1
store i64 %45, i64* %3
br label %27
46: ; preds = %27
%47 = load i64, i64* %2
%48 = add i64 %47, 36
%49 = call i32 @CANRegWrite(i64 %48, i64 12)
store i64 1, i64* %3
br label %50
50: ; preds = %66, %46
%51 = load i64, i64* %3
%52 = icmp ule i64 %51, 32
br i1 %52, label %53, label %69
53: ; preds = %50
br label %54
54: ; preds = %60, %53
%55 = load i64, i64* %2
%56 = add i64 %55, 32
%57 = call i32 @CANRegRead(i64 %56)
%58 = and i32 %57, 32768
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %54
br label %54
61: ; preds = %54
%62 = load i64, i64* %2
%63 = add i64 %62, 32
%64 = load i64, i64* %3
%65 = call i32 @CANRegWrite(i64 %63, i64 %64)
br label %66
66: ; preds = %61
%67 = load i64, i64* %3
%68 = add i64 %67, 1
store i64 %68, i64* %3
br label %50
69: ; preds = %50
%70 = load i64, i64* %2
%71 = add i64 %70, 4
%72 = call i32 @CANRegRead(i64 %71)
ret void
}

LLVM IR (-O2):
define void @CANInit(i64 %0) {
%2 = tail call i32 @CANBaseValid(i64 %0)
%3 = tail call i32 @DEBUG_ASSERT(i32 %2)
%4 = tail call i32 @CANRegWrite(i64 %0, i64 1)
%5 = add i64 %0, 32
br label %6
6: ; preds = %6, %1
%7 = tail call i32 @CANRegRead(i64 %5)
%8 = and i32 %7, 32768
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6
%11 = add i64 %0, 36
%12 = tail call i32 @CANRegWrite(i64 %11, i64 176)
%13 = add i64 %0, 52
%14 = tail call i32 @CANRegWrite(i64 %13, i64 0)
%15 = add i64 %0, 56
%16 = tail call i32 @CANRegWrite(i64 %15, i64 0)
br label %17
17: ; preds = %10, %23
%18 = phi i64 [ 1, %10 ], [ %25, %23 ]
br label %19
19: ; preds = %17, %19
%20 = tail call i32 @CANRegRead(i64 %5)
%21 = and i32 %20, 32768
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %19
23: ; preds = %19
%24 = tail call i32 @CANRegWrite(i64 %5, i64 %18)
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, 33
br i1 %26, label %27, label %17
27: ; preds = %23
%28 = tail call i32 @CANRegWrite(i64 %11, i64 12)
br label %29
29: ; preds = %27, %35
%30 = phi i64 [ 1, %27 ], [ %37, %35 ]
br label %31
31: ; preds = %29, %31
%32 = tail call i32 @CANRegRead(i64 %5)
%33 = and i32 %32, 32768
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %31
35: ; preds = %31
%36 = tail call i32 @CANRegWrite(i64 %5, i64 %30)
%37 = add nuw nsw i64 %30, 1
%38 = icmp eq i64 %37, 33
br i1 %38, label %39, label %29
39: ; preds = %35
%40 = add i64 %0, 4
%41 = tail call i32 @CANRegRead(i64 %40)
ret void
}