void BSP_Timer_Start(unsigned int timerIndex) {
  if (timerIndex == 0) {
    (*(volatile unsigned *)0x51000008) |= 0x00000001;
  } else if (timerIndex == 1) {
    (*(volatile unsigned *)0x51000008) |= 0x00000100;
  } else if (timerIndex == 2) {
    (*(volatile unsigned *)0x51000008) |= 0x00001000;
  } else if (timerIndex == 3) {
    (*(volatile unsigned *)0x51000008) |= 0x00000100;
  } else {
    (*(volatile unsigned *)0x51000008) |= 0x00001000;
  }
}


x86 assembly (clang, -O0):
<BSP_Timer_Start>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1127 <BSP_Timer_Start+0x27>
mov    $0x51000008,%eax
mov    (%rax),%ecx
or     $0x1,%ecx
mov    $0x51000008,%eax
mov    %ecx,(%rax)
jmp    11b3 <BSP_Timer_Start+0xb3>
cmpl   $0x1,-0x4(%rbp)
jne    114a <BSP_Timer_Start+0x4a>
mov    $0x51000008,%eax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    $0x51000008,%eax
mov    %ecx,(%rax)
jmp    11ae <BSP_Timer_Start+0xae>
cmpl   $0x2,-0x4(%rbp)
jne    116d <BSP_Timer_Start+0x6d>
mov    $0x51000008,%eax
mov    (%rax),%ecx
or     $0x1000,%ecx
mov    $0x51000008,%eax
mov    %ecx,(%rax)
jmp    11a9 <BSP_Timer_Start+0xa9>
cmpl   $0x3,-0x4(%rbp)
jne    1190 <BSP_Timer_Start+0x90>
mov    $0x51000008,%eax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    $0x51000008,%eax
mov    %ecx,(%rax)
jmp    11a4 <BSP_Timer_Start+0xa4>
mov    $0x51000008,%eax
mov    (%rax),%ecx
or     $0x1000,%ecx
mov    $0x51000008,%eax
mov    %ecx,(%rax)
jmp    11a9 <BSP_Timer_Start+0xa9>
jmp    11ae <BSP_Timer_Start+0xae>
jmp    11b3 <BSP_Timer_Start+0xb3>
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_Timer_Start>:
mov    $0x1000,%eax
cmp    $0x3,%edi
ja     1117 <BSP_Timer_Start+0x17>
movslq %edi,%rax
lea    0xeec(%rip),%rcx
mov    (%rcx,%rax,4),%eax
or     %eax,0x51000008
ret

LLVM IR (-O0):
define void @BSP_Timer_Start(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%7 = or i32 %6, 1
store volatile i32 %7, i32* inttoptr (i64 1358954504 to i32*)
br label %32
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%13 = or i32 %12, 256
store volatile i32 %13, i32* inttoptr (i64 1358954504 to i32*)
br label %31
14: ; preds = %8
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%19 = or i32 %18, 4096
store volatile i32 %19, i32* inttoptr (i64 1358954504 to i32*)
br label %30
20: ; preds = %14
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%25 = or i32 %24, 256
store volatile i32 %25, i32* inttoptr (i64 1358954504 to i32*)
br label %29
26: ; preds = %20
%27 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%28 = or i32 %27, 4096
store volatile i32 %28, i32* inttoptr (i64 1358954504 to i32*)
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %17
br label %31
31: ; preds = %30, %11
br label %32
32: ; preds = %31, %5
ret void
}

LLVM IR (-O2):
@switch.table.BSP_Timer_Start = [4 x i32] [i32 1, i32 256, i32 4096, i32 256]
define void @BSP_Timer_Start(i32 %0) {
%2 = icmp ult i32 %0, 4
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.BSP_Timer_Start, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %1, %3
%8 = phi i32 [ %6, %3 ], [ 4096, %1 ]
%9 = load volatile i32, i32* inttoptr (i64 1358954504 to i32*)
%10 = or i32 %9, %8
store volatile i32 %10, i32* inttoptr (i64 1358954504 to i32*)
ret void
}