void CANClkSourceSelect(unsigned long ulBase, unsigned char ucSource) {
  unsigned long ulMWRAllow;
  ulMWRAllow = (*((volatile unsigned long *)(0x400FB980)));
  (*((volatile unsigned long *)(0x400FB980))) = 0xA5A5A5A5;
  switch (ulBase) {
  case 0x40070000: {
    (*((volatile unsigned long *)(0x400FB870))) = ucSource;
  }
  case 0x40074000: {
    (*((volatile unsigned long *)(0x400FB874))) = ucSource;
  }
  default:
    break;
  }
  (*((volatile unsigned long *)(0x400FB980))) = ulMWRAllow;
}


x86 assembly (clang, -O0):
<CANClkSourceSelect>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    0x400fb980,%rax
40
mov    %rax,-0x18(%rbp)
mov    $0xa5a5a5a5,%eax
mov    %rax,0x400fb980
40
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
sub    $0x40070000,%rax
je     1155 <CANClkSourceSelect+0x55>
jmp    1140 <CANClkSourceSelect+0x40>
mov    -0x20(%rbp),%rax
sub    $0x40074000,%rax
je     1163 <CANClkSourceSelect+0x63>
jmp    1171 <CANClkSourceSelect+0x71>
movzbl -0x9(%rbp),%eax
mov    %eax,%ecx
mov    $0x400fb870,%eax
mov    %rcx,(%rax)
movzbl -0x9(%rbp),%eax
mov    %eax,%ecx
mov    $0x400fb874,%eax
mov    %rcx,(%rax)
jmp    1176 <CANClkSourceSelect+0x76>
mov    -0x18(%rbp),%rcx
mov    $0x400fb980,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANClkSourceSelect>:
mov    0x400fb980,%rax
40
mov    $0xa5a5a5a5,%ecx
mov    %rcx,0x400fb980
40
cmp    $0x40070000,%rdi
je     112d <CANClkSourceSelect+0x2d>
cmp    $0x40074000,%rdi
jne    1141 <CANClkSourceSelect+0x41>
movzbl %sil,%ecx
jmp    1139 <CANClkSourceSelect+0x39>
movzbl %sil,%ecx
mov    %rcx,0x400fb870
40
mov    %rcx,0x400fb874
40
mov    %rax,0x400fb980
40
ret

LLVM IR (-O0):
define void @CANClkSourceSelect(i64 %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i8
%5 = alloca i64
store i64 %0, i64* %3
store i8 %1, i8* %4
%6 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store i64 %6, i64* %5
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
%7 = load i64, i64* %3
switch i64 %7, label %14 [
i64 1074200576, label %8
i64 1074216960, label %11
]
8: ; preds = %2
%9 = load i8, i8* %4
%10 = zext i8 %9 to i64
store volatile i64 %10, i64* inttoptr (i64 1074772080 to i64*)
br label %11
11: ; preds = %2, %8
%12 = load i8, i8* %4
%13 = zext i8 %12 to i64
store volatile i64 %13, i64* inttoptr (i64 1074772084 to i64*)
br label %14
14: ; preds = %2, %11
br label %15
15: ; preds = %14
%16 = load i64, i64* %5
store volatile i64 %16, i64* inttoptr (i64 1074772352 to i64*)
ret void
}

LLVM IR (-O2):
define void @CANClkSourceSelect(i64 %0, i8 zeroext %1) {
%3 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
switch i64 %0, label %10 [
i64 1074200576, label %6
i64 1074216960, label %4
]
4: ; preds = %2
%5 = zext i8 %1 to i64
br label %8
6: ; preds = %2
%7 = zext i8 %1 to i64
store volatile i64 %7, i64* inttoptr (i64 1074772080 to i64*)
br label %8
8: ; preds = %4, %6
%9 = phi i64 [ %5, %4 ], [ %7, %6 ]
store volatile i64 %9, i64* inttoptr (i64 1074772084 to i64*)
br label %10
10: ; preds = %8, %2
store volatile i64 %3, i64* inttoptr (i64 1074772352 to i64*)
ret void
}