#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EndCritical(long);
void BSP_Time_Init(void) {
  long sr;
  (*((volatile uint32_t *)0x400FE65C)) |= 0x20;
  while (((*((volatile uint32_t *)0x400FEA5C)) & 0x20) == 0) {
  };
  (*((volatile uint32_t *)0x4004F00C)) &= ~0x00000100;
  (*((volatile uint32_t *)0x4004F000)) = 0x00000004;
  (*((volatile uint32_t *)0x4004F008)) = 0x00000002;
  (*((volatile uint32_t *)0x4004F02C)) = 0xFFFFFFFF;
  (*((volatile uint32_t *)0x4004F03C)) = 79;
  (*((volatile uint32_t *)0x4004F024)) = 0x00000100;
  (*((volatile uint32_t *)0x4004F018)) &= ~0x00000100;
  (*((volatile uint32_t *)0x4004F00C)) |= 0x00000100;
  EndCritical(sr);
}


x86 assembly (clang, -O0):
<BSP_Time_Init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x400fe65c,%eax
mov    (%rax),%ecx
or     $0x20,%ecx
mov    $0x400fe65c,%eax
mov    %ecx,(%rax)
mov    $0x400fea5c,%eax
mov    (%rax),%eax
and    $0x20,%eax
cmp    $0x0,%eax
jne    1141 <BSP_Time_Init+0x31>
jmp    1129 <BSP_Time_Init+0x19>
mov    $0x4004f00c,%eax
mov    (%rax),%ecx
and    $0xfffffeff,%ecx
mov    $0x4004f00c,%eax
mov    %ecx,(%rax)
mov    $0x4004f000,%eax
movl   $0x4,(%rax)
mov    $0x4004f008,%eax
movl   $0x2,(%rax)
mov    $0x4004f02c,%eax
movl   $0xffffffff,(%rax)
mov    $0x4004f03c,%eax
movl   $0x4f,(%rax)
mov    $0x4004f024,%eax
movl   $0x100,(%rax)
mov    $0x4004f018,%eax
mov    (%rax),%ecx
and    $0xfffffeff,%ecx
mov    $0x4004f018,%eax
mov    %ecx,(%rax)
mov    $0x4004f00c,%eax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    $0x4004f00c,%eax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <EndCritical@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_Time_Init>:
orl    $0x20,0x400fe65c
20
nopl   0x0(%rax,%rax,1)
testl  $0x20,0x400fea5c
je     1120 <BSP_Time_Init+0x10>
andl   $0xfffffeff,0x4004f00c
ff fe ff ff
movl   $0x4,0x4004f000
movl   $0x2,0x4004f008
movl   $0xffffffff,0x4004f02c
ff ff ff ff
movl   $0x4f,0x4004f03c
movl   $0x100,0x4004f024
andl   $0xfffffeff,0x4004f018
ff fe ff ff
orl    $0x100,0x4004f00c
jmp    1030 <EndCritical@plt>

LLVM IR (-O0):
define void @BSP_Time_Init() {
%1 = alloca i64
%2 = load volatile i32, i32* inttoptr (i64 1074783836 to i32*)
%3 = or i32 %2, 32
store volatile i32 %3, i32* inttoptr (i64 1074783836 to i32*)
br label %4
4: ; preds = %8, %0
%5 = load volatile i32, i32* inttoptr (i64 1074784860 to i32*)
%6 = and i32 %5, 32
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %4
9: ; preds = %4
%10 = load volatile i32, i32* inttoptr (i64 1074065420 to i32*)
%11 = and i32 %10, -257
store volatile i32 %11, i32* inttoptr (i64 1074065420 to i32*)
store volatile i32 4, i32* inttoptr (i64 1074065408 to i32*)
store volatile i32 2, i32* inttoptr (i64 1074065416 to i32*)
store volatile i32 -1, i32* inttoptr (i64 1074065452 to i32*)
store volatile i32 79, i32* inttoptr (i64 1074065468 to i32*)
store volatile i32 256, i32* inttoptr (i64 1074065444 to i32*)
%12 = load volatile i32, i32* inttoptr (i64 1074065432 to i32*)
%13 = and i32 %12, -257
store volatile i32 %13, i32* inttoptr (i64 1074065432 to i32*)
%14 = load volatile i32, i32* inttoptr (i64 1074065420 to i32*)
%15 = or i32 %14, 256
store volatile i32 %15, i32* inttoptr (i64 1074065420 to i32*)
%16 = load i64, i64* %1
%17 = call i32 @EndCritical(i64 %16)
ret void
}

LLVM IR (-O2):
define void @BSP_Time_Init() {
%1 = load volatile i32, i32* inttoptr (i64 1074783836 to i32*)
%2 = or i32 %1, 32
store volatile i32 %2, i32* inttoptr (i64 1074783836 to i32*)
br label %3
3: ; preds = %3, %0
%4 = load volatile i32, i32* inttoptr (i64 1074784860 to i32*)
%5 = and i32 %4, 32
%6 = icmp eq i32 %5, 0
br i1 %6, label %3, label %7
7: ; preds = %3
%8 = load volatile i32, i32* inttoptr (i64 1074065420 to i32*)
%9 = and i32 %8, -257
store volatile i32 %9, i32* inttoptr (i64 1074065420 to i32*)
store volatile i32 4, i32* inttoptr (i64 1074065408 to i32*)
store volatile i32 2, i32* inttoptr (i64 1074065416 to i32*)
store volatile i32 -1, i32* inttoptr (i64 1074065452 to i32*)
store volatile i32 79, i32* inttoptr (i64 1074065468 to i32*)
store volatile i32 256, i32* inttoptr (i64 1074065444 to i32*)
%10 = load volatile i32, i32* inttoptr (i64 1074065432 to i32*)
%11 = and i32 %10, -257
store volatile i32 %11, i32* inttoptr (i64 1074065432 to i32*)
%12 = load volatile i32, i32* inttoptr (i64 1074065420 to i32*)
%13 = or i32 %12, 256
store volatile i32 %13, i32* inttoptr (i64 1074065420 to i32*)
%14 = tail call i32 @EndCritical(i64 undef)
ret void
}