void ipod_set_cpu_speed(int speed) {
  int postscalar = speed / 3;
  (*(volatile unsigned int *)(0x70000020) =
       ((*(volatile unsigned int *)(0x70000020)) | (1 << 30)));
  (*(volatile unsigned int *)(0x60006020) =
       ((((*(volatile unsigned int *)(0x60006020)) & 0x0fffff8f) |
         (0x20000000 | ((0x2) << 4)))));
  (*(volatile unsigned int *)(0x60006034) = (0xaa020008 | (postscalar << 8)));
  int x;
  for (x = 0; x < 10000; x++)
    ;
  (*(volatile unsigned int *)(0x60006020) =
       ((((*(volatile unsigned int *)(0x60006020)) & 0x0fffff8f) |
         (0x20000000 | ((0x7) << 4)))));
}


x86 assembly (clang, -O0):
<ipod_set_cpu_speed>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    $0x70000020,%eax
mov    (%rax),%ecx
or     $0x40000000,%ecx
mov    $0x70000020,%eax
mov    %ecx,(%rax)
mov    $0x60006020,%eax
mov    (%rax),%ecx
and    $0xfffff8f,%ecx
or     $0x20000020,%ecx
mov    $0x60006020,%eax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
shl    $0x8,%ecx
or     $0xaa020008,%ecx
mov    $0x60006034,%eax
mov    %ecx,(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2710,-0xc(%rbp)
jge    117d <ipod_set_cpu_speed+0x7d>
jmp    116f <ipod_set_cpu_speed+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <ipod_set_cpu_speed+0x5d>
mov    $0x60006020,%eax
mov    (%rax),%ecx
and    $0xfffff8f,%ecx
or     $0x20000070,%ecx
mov    $0x60006020,%eax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipod_set_cpu_speed>:
movslq %edi,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
orl    $0x40000000,0x70000020
mov    $0xfffff8f,%ecx
mov    0x60006020,%edx
and    %ecx,%edx
or     $0x20000020,%edx
mov    %edx,0x60006020
shl    $0x8,%eax
or     $0xaa020008,%eax
mov    %eax,0x60006034
and    0x60006020,%ecx
or     $0x20000070,%ecx
mov    %ecx,0x60006020
ret

LLVM IR (-O0):
define void @ipod_set_cpu_speed(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sdiv i32 %5, 3
store i32 %6, i32* %3
%7 = load volatile i32, i32* inttoptr (i64 1879048224 to i32*)
%8 = or i32 %7, 1073741824
store volatile i32 %8, i32* inttoptr (i64 1879048224 to i32*)
%9 = load volatile i32, i32* inttoptr (i64 1610637344 to i32*)
%10 = and i32 %9, 268435343
%11 = or i32 %10, 536870944
store volatile i32 %11, i32* inttoptr (i64 1610637344 to i32*)
%12 = load i32, i32* %3
%13 = shl i32 %12, 8
%14 = or i32 -1442709496, %13
store volatile i32 %14, i32* inttoptr (i64 1610637364 to i32*)
store i32 0, i32* %4
br label %15
15: ; preds = %19, %1
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 10000
br i1 %17, label %18, label %22
18: ; preds = %15
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %15
22: ; preds = %15
%23 = load volatile i32, i32* inttoptr (i64 1610637344 to i32*)
%24 = and i32 %23, 268435343
%25 = or i32 %24, 536871024
store volatile i32 %25, i32* inttoptr (i64 1610637344 to i32*)
ret void
}

LLVM IR (-O2):
define void @ipod_set_cpu_speed(i32 %0) {
%2 = sdiv i32 %0, 3
%3 = load volatile i32, i32* inttoptr (i64 1879048224 to i32*)
%4 = or i32 %3, 1073741824
store volatile i32 %4, i32* inttoptr (i64 1879048224 to i32*)
%5 = load volatile i32, i32* inttoptr (i64 1610637344 to i32*)
%6 = and i32 %5, 268435343
%7 = or i32 %6, 536870944
store volatile i32 %7, i32* inttoptr (i64 1610637344 to i32*)
%8 = shl i32 %2, 8
%9 = or i32 %8, -1442709496
store volatile i32 %9, i32* inttoptr (i64 1610637364 to i32*)
%10 = load volatile i32, i32* inttoptr (i64 1610637344 to i32*)
%11 = and i32 %10, 268435343
%12 = or i32 %11, 536871024
store volatile i32 %12, i32* inttoptr (i64 1610637344 to i32*)
ret void
}