void CANInit(void) {
  int iMsg;
  (*((volatile unsigned long *)(0x40040000 + 0x00000000))) =
      0x00000001 | 0x00000040;
  for (iMsg = 1; iMsg <= 32; iMsg++) {
    while ((*((volatile unsigned long *)(0x40040000 + 0x00000020))) &
           0x00008000) {
    }
    (*((volatile unsigned long *)(0x40040000 + 0x00000024))) =
        0x00000080 | 0x00000020 | 0x00000010;
    (*((volatile unsigned long *)(0x40040000 + 0x00000034))) = 0;
    (*((volatile unsigned long *)(0x40040000 + 0x00000038))) = 0;
    (*((volatile unsigned long *)(0x40040000 + 0x00000020))) = iMsg;
  }
  (*((volatile unsigned long *)(0x40040000 + 0x00000004)));
}


x86 assembly (clang, -O0):
<CANInit>:
push   %rbp
mov    %rsp,%rbp
mov    $0x40040000,%eax
movq   $0x41,(%rax)
movl   $0x1,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jg     1181 <CANInit+0x81>
jmp    1126 <CANInit+0x26>
mov    $0x40040020,%eax
mov    (%rax),%rax
and    $0x8000,%rax
cmp    $0x0,%rax
je     1143 <CANInit+0x43>
jmp    1126 <CANInit+0x26>
mov    $0x40040024,%eax
movq   $0xb0,(%rax)
mov    $0x40040034,%eax
movq   $0x0,(%rax)
mov    $0x40040038,%eax
movq   $0x0,(%rax)
movslq -0x4(%rbp),%rcx
mov    $0x40040020,%eax
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1117 <CANInit+0x17>
mov    $0x40040004,%eax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANInit>:
movq   $0x41,0x40040000
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
testq  $0x8000,0x40040020
jne    1120 <CANInit+0x20>
movq   $0xb0,0x40040024
movq   $0x0,0x40040034
movq   $0x0,0x40040038
mov    %rax,0x40040020
40
lea    0x1(%rax),%rcx
xchg   %ax,%ax
testq  $0x8000,0x40040020
jne    1160 <CANInit+0x60>
movq   $0xb0,0x40040024
movq   $0x0,0x40040034
movq   $0x0,0x40040038
mov    %rcx,0x40040020
40
add    $0x2,%rax
cmp    $0x21,%rax
jne    1120 <CANInit+0x20>
mov    0x40040004,%rax
40
ret

LLVM IR (-O0):
define void @CANInit() {
%1 = alloca i32
store volatile i64 65, i64* inttoptr (i64 1074003968 to i64*)
store i32 1, i32* %1
br label %2
2: ; preds = %14, %0
%3 = load i32, i32* %1
%4 = icmp sle i32 %3, 32
br i1 %4, label %5, label %17
5: ; preds = %2
br label %6
6: ; preds = %10, %5
%7 = load volatile i64, i64* inttoptr (i64 1074004000 to i64*)
%8 = and i64 %7, 32768
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
store volatile i64 176, i64* inttoptr (i64 1074004004 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004020 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004024 to i64*)
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
store volatile i64 %13, i64* inttoptr (i64 1074004000 to i64*)
br label %14
14: ; preds = %11
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %2
17: ; preds = %2
%18 = load volatile i64, i64* inttoptr (i64 1074003972 to i64*)
ret void
}

LLVM IR (-O2):
define void @CANInit() {
store volatile i64 65, i64* inttoptr (i64 1074003968 to i64*)
br label %1
1: ; preds = %13, %0
%2 = phi i64 [ 1, %0 ], [ %14, %13 ]
br label %3
3: ; preds = %1, %3
%4 = load volatile i64, i64* inttoptr (i64 1074004000 to i64*)
%5 = and i64 %4, 32768
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3
store volatile i64 176, i64* inttoptr (i64 1074004004 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004020 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004024 to i64*)
store volatile i64 %2, i64* inttoptr (i64 1074004000 to i64*)
%8 = add nuw nsw i64 %2, 1
br label %9
9: ; preds = %9, %7
%10 = load volatile i64, i64* inttoptr (i64 1074004000 to i64*)
%11 = and i64 %10, 32768
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9
store volatile i64 176, i64* inttoptr (i64 1074004004 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004020 to i64*)
store volatile i64 0, i64* inttoptr (i64 1074004024 to i64*)
store volatile i64 %8, i64* inttoptr (i64 1074004000 to i64*)
%14 = add nuw nsw i64 %2, 2
%15 = icmp eq i64 %14, 33
br i1 %15, label %16, label %1
16: ; preds = %13
%17 = load volatile i64, i64* inttoptr (i64 1074003972 to i64*)
ret void
}