void scif_init(int bps) {
  int i;
  *(volatile unsigned short *)0xffe80008 = 0x0;
  *(volatile unsigned short *)0xffe80018 = 0x6;
  *(volatile unsigned short *)0xffe80000 = 0x0;
  *(volatile unsigned char *)0xffe80004 = (50 * 1000000) / (32 * bps) - 1;
  for (i = 0; i < 100000; i++)
    ;
  *(volatile unsigned short *)0xffe80018 = 12;
  *(volatile unsigned short *)0xffe80018 = 0x8;
  *(volatile unsigned short *)0xffe80020 = 0;
  *(volatile unsigned short *)0xffe80010 = 0x60;
  *(volatile unsigned short *)0xffe80024 = 0;
  *(volatile unsigned short *)0xffe80008 = 0x30;
  for (i = 0; i < 100000; i++)
    ;
}


x86 assembly (clang, -O0):
<scif_init>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0xffe80008,%eax
movw   $0x0,(%rax)
mov    $0xffe80018,%eax
movw   $0x6,(%rax)
mov    $0xffe80000,%eax
movw   $0x0,(%rax)
mov    -0x4(%rbp),%ecx
shl    $0x5,%ecx
mov    $0x2faf080,%eax
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %al,%cl
mov    $0xffe80004,%eax
mov    %cl,(%rax)
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    1166 <scif_init+0x66>
jmp    1158 <scif_init+0x58>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <scif_init+0x46>
mov    $0xffe80018,%eax
movw   $0xc,(%rax)
mov    $0xffe80018,%eax
movw   $0x8,(%rax)
mov    $0xffe80020,%eax
movw   $0x0,(%rax)
mov    $0xffe80010,%eax
movw   $0x60,(%rax)
mov    $0xffe80024,%eax
movw   $0x0,(%rax)
mov    $0xffe80008,%eax
movw   $0x30,(%rax)
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    11c9 <scif_init+0xc9>
jmp    11bb <scif_init+0xbb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <scif_init+0xa9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<scif_init>:
mov    $0xffe80018,%ecx
movw   $0x0,-0x10(%rcx)
movw   $0x6,(%rcx)
movw   $0x0,-0x18(%rcx)
shl    $0x5,%edi
mov    $0x2faf080,%eax
xor    %edx,%edx
idiv   %edi
add    $0xff,%al
mov    %al,-0x14(%rcx)
movw   $0xc,(%rcx)
movw   $0x8,(%rcx)
movw   $0x0,0x8(%rcx)
movw   $0x60,-0x8(%rcx)
movw   $0x0,0xc(%rcx)
movw   $0x30,-0x10(%rcx)
ret

LLVM IR (-O0):
define void @scif_init(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store volatile i16 0, i16* inttoptr (i64 4293394440 to i16*)
store volatile i16 6, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394432 to i16*)
%4 = load i32, i32* %2
%5 = mul nsw i32 32, %4
%6 = sdiv i32 50000000, %5
%7 = sub nsw i32 %6, 1
%8 = trunc i32 %7 to i8
store volatile i8 %8, i8* inttoptr (i64 4293394436 to i8*)
store i32 0, i32* %3
br label %9
9: ; preds = %13, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 100000
br i1 %11, label %12, label %16
12: ; preds = %9
br label %13
13: ; preds = %12
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %9
16: ; preds = %9
store volatile i16 12, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 8, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394464 to i16*)
store volatile i16 96, i16* inttoptr (i64 4293394448 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394468 to i16*)
store volatile i16 48, i16* inttoptr (i64 4293394440 to i16*)
store i32 0, i32* %3
br label %17
17: ; preds = %21, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 100000
br i1 %19, label %20, label %24
20: ; preds = %17
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %17
24: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @scif_init(i32 %0) {
store volatile i16 0, i16* inttoptr (i64 4293394440 to i16*)
store volatile i16 6, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394432 to i16*)
%2 = shl nsw i32 %0, 5
%3 = sdiv i32 50000000, %2
%4 = trunc i32 %3 to i8
%5 = add i8 %4, -1
store volatile i8 %5, i8* inttoptr (i64 4293394436 to i8*)
store volatile i16 12, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 8, i16* inttoptr (i64 4293394456 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394464 to i16*)
store volatile i16 96, i16* inttoptr (i64 4293394448 to i16*)
store volatile i16 0, i16* inttoptr (i64 4293394468 to i16*)
store volatile i16 48, i16* inttoptr (i64 4293394440 to i16*)
ret void
}