unsigned long PRCMPeripheralClockGet(unsigned long ulPeripheral) {
  unsigned long ulClockFreq;
  unsigned long ulHiPulseDiv;
  unsigned long ulLoPulseDiv;
  if (((ulPeripheral == 0x00000013) | (ulPeripheral == 0x00000004) |
       (ulPeripheral == 0x00000003))) {
    return 40000000;
  } else if (ulPeripheral == 0x00000000) {
    ulHiPulseDiv =
        (((*((volatile unsigned long *)(0x44025000 + 0x00000000))) >> 8) &
         0x07);
    ulLoPulseDiv =
        ((*((volatile unsigned long *)(0x44025000 + 0x00000000))) & 0xFF);
  } else if (ulPeripheral == 0x00000002) {
    ulHiPulseDiv =
        (((*((volatile unsigned long *)(0x44025000 + 0x00000020))) >> 8) &
         0x07);
    ulLoPulseDiv =
        ((*((volatile unsigned long *)(0x44025000 + 0x00000020))) & 0xFF);
  } else {
    return 80000000;
  }
  ulClockFreq = (240000000 / ((ulHiPulseDiv + 1) + (ulLoPulseDiv + 1)));
  return ulClockFreq;
}


x86 assembly (clang, -O0):
<PRCMPeripheralClockGet>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x13,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmpq   $0x4,-0x10(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmpq   $0x3,-0x10(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     114b <PRCMPeripheralClockGet+0x4b>
movq   $0x2625a00,-0x8(%rbp)
02
jmp    11f7 <PRCMPeripheralClockGet+0xf7>
cmpq   $0x0,-0x10(%rbp)
jne    1181 <PRCMPeripheralClockGet+0x81>
mov    $0x44025000,%eax
mov    (%rax),%rax
shr    $0x8,%rax
and    $0x7,%rax
mov    %rax,-0x20(%rbp)
mov    $0x44025000,%eax
mov    (%rax),%rax
and    $0xff,%rax
mov    %rax,-0x28(%rbp)
jmp    11c9 <PRCMPeripheralClockGet+0xc9>
cmpq   $0x2,-0x10(%rbp)
jne    11b7 <PRCMPeripheralClockGet+0xb7>
mov    $0x44025020,%eax
mov    (%rax),%rax
shr    $0x8,%rax
and    $0x7,%rax
mov    %rax,-0x20(%rbp)
mov    $0x44025020,%eax
mov    (%rax),%rax
and    $0xff,%rax
mov    %rax,-0x28(%rbp)
jmp    11c4 <PRCMPeripheralClockGet+0xc4>
movq   $0x4c4b400,-0x8(%rbp)
04
jmp    11f7 <PRCMPeripheralClockGet+0xf7>
jmp    11c9 <PRCMPeripheralClockGet+0xc9>
jmp    11ce <PRCMPeripheralClockGet+0xce>
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
add    $0x1,%rax
add    %rax,%rcx
mov    $0xe4e1c00,%eax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMPeripheralClockGet>:
cmp    $0x13,%rdi
ja     1121 <PRCMPeripheralClockGet+0x21>
mov    $0x44025000,%ecx
mov    $0x2625a00,%eax
lea    0xee9(%rip),%rdx
movslq (%rdx,%rdi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
ret
mov    $0x4c4b400,%eax
ret
mov    $0x44025020,%ecx
mov    (%rcx),%rax
mov    (%rcx),%rcx
movzbl %cl,%ecx
shr    $0x8,%eax
and    $0x7,%eax
add    %eax,%ecx
add    $0x2,%ecx
mov    $0xe4e1c00,%eax
xor    %edx,%edx
div    %ecx
ret

LLVM IR (-O0):
define i64 @PRCMPeripheralClockGet(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
%7 = load i64, i64* %3
%8 = icmp eq i64 %7, 19
%9 = zext i1 %8 to i32
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, 4
%12 = zext i1 %11 to i32
%13 = or i32 %9, %12
%14 = load i64, i64* %3
%15 = icmp eq i64 %14, 3
%16 = zext i1 %15 to i32
%17 = or i32 %13, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %1
store i64 40000000, i64* %2
br label %49
20: ; preds = %1
%21 = load i64, i64* %3
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load volatile i64, i64* inttoptr (i64 1141002240 to i64*)
%25 = lshr i64 %24, 8
%26 = and i64 %25, 7
store i64 %26, i64* %5
%27 = load volatile i64, i64* inttoptr (i64 1141002240 to i64*)
%28 = and i64 %27, 255
store i64 %28, i64* %6
br label %40
29: ; preds = %20
%30 = load i64, i64* %3
%31 = icmp eq i64 %30, 2
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load volatile i64, i64* inttoptr (i64 1141002272 to i64*)
%34 = lshr i64 %33, 8
%35 = and i64 %34, 7
store i64 %35, i64* %5
%36 = load volatile i64, i64* inttoptr (i64 1141002272 to i64*)
%37 = and i64 %36, 255
store i64 %37, i64* %6
br label %39
38: ; preds = %29
store i64 80000000, i64* %2
br label %49
39: ; preds = %32
br label %40
40: ; preds = %39, %23
br label %41
41: ; preds = %40
%42 = load i64, i64* %5
%43 = add i64 %42, 1
%44 = load i64, i64* %6
%45 = add i64 %44, 1
%46 = add i64 %43, %45
%47 = udiv i64 240000000, %46
store i64 %47, i64* %4
%48 = load i64, i64* %4
store i64 %48, i64* %2
br label %49
49: ; preds = %41, %38, %19
%50 = load i64, i64* %2
ret i64 %50
}

LLVM IR (-O2):
define i64 @PRCMPeripheralClockGet(i64 %0) {
switch i64 %0, label %3 [
i64 19, label %16
i64 4, label %16
i64 3, label %16
i64 0, label %4
i64 2, label %2
]
2: ; preds = %1
br label %4
3: ; preds = %1
br label %16
4: ; preds = %1, %2
%5 = phi i64* [ inttoptr (i64 1141002272 to i64*), %2 ], [ inttoptr (i64 1141002240 to i64*), %1 ]
%6 = load volatile i64, i64* %5
%7 = load volatile i64, i64* %5
%8 = and i64 %7, 255
%9 = lshr i64 %6, 8
%10 = and i64 %9, 7
%11 = add nuw nsw i64 %10, %8
%12 = trunc i64 %11 to i32
%13 = add nuw nsw i32 %12, 2
%14 = udiv i32 240000000, %13
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %1, %1, %1, %4, %3
%17 = phi i64 [ %15, %4 ], [ 80000000, %3 ], [ 40000000, %1 ], [ 40000000, %1 ], [ 40000000, %1 ]
ret i64 %17
}