#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long long scm_page_col(long long);
long long scm_page_level(long long);
long long scm_page_root(long long);
long long scm_page_row(long long);
int /*<<< orphan*/ scm_vector(long long, double, double, double *);
void scm_page_corners(long long i, double *v) {
  long long l = scm_page_level(i);
  long long f = scm_page_root(i);
  long long r = scm_page_row(i);
  long long c = scm_page_col(i);
  long long n = 1LL << l;
  scm_vector(f, (double)(r + 0) / n, (double)(c + 0) / n, v + 0);
  scm_vector(f, (double)(r + 0) / n, (double)(c + 1) / n, v + 3);
  scm_vector(f, (double)(r + 1) / n, (double)(c + 0) / n, v + 6);
  scm_vector(f, (double)(r + 1) / n, (double)(c + 1) / n, v + 9);
}


x86 assembly (clang, -O0):
<scm_page_corners>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <scm_page_level@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <scm_page_root@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <scm_page_row@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <scm_page_col@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rcx
mov    $0x1,%eax
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    $0x0,%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
add    $0x0,%rax
cvtsi2sd %rax,%xmm1
cvtsi2sdq -0x38(%rbp),%xmm2
divsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rsi
call   1030 <scm_vector@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    $0x0,%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm1
cvtsi2sdq -0x38(%rbp),%xmm2
divsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rsi
add    $0x18,%rsi
call   1030 <scm_vector@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
add    $0x0,%rax
cvtsi2sd %rax,%xmm1
cvtsi2sdq -0x38(%rbp),%xmm2
divsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rsi
add    $0x30,%rsi
call   1030 <scm_vector@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm1
cvtsi2sdq -0x38(%rbp),%xmm2
divsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rsi
add    $0x48,%rsi
call   1030 <scm_vector@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scm_page_corners>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <scm_page_level@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1040 <scm_page_root@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <scm_page_row@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1070 <scm_page_col@plt>
mov    %rax,%rbx
mov    $0x1,%eax
mov    %r13d,%ecx
shl    %cl,%rax
cvtsi2sd %r12,%xmm0
cvtsi2sd %rax,%xmm2
movsd  %xmm2,(%rsp)
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
cvtsi2sd %rbx,%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <scm_vector@plt>
add    $0x1,%rbx
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
divsd  (%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0x18(%r15),%rsi
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <scm_vector@plt>
add    $0x1,%r12
xorps  %xmm0,%xmm0
cvtsi2sd %r12,%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x30(%r15),%rsi
mov    %r14,%rdi
movsd  0x18(%rsp),%xmm1
call   1030 <scm_vector@plt>
add    $0x48,%r15
mov    %r14,%rdi
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r15,%rsi
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <scm_vector@plt>

LLVM IR (-O0):
define void @scm_page_corners(i64 %0, double* %1) {
%3 = alloca i64
%4 = alloca double*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i64 %0, i64* %3
store double* %1, double** %4
%10 = load i64, i64* %3
%11 = call i64 @scm_page_level(i64 %10)
store i64 %11, i64* %5
%12 = load i64, i64* %3
%13 = call i64 @scm_page_root(i64 %12)
store i64 %13, i64* %6
%14 = load i64, i64* %3
%15 = call i64 @scm_page_row(i64 %14)
store i64 %15, i64* %7
%16 = load i64, i64* %3
%17 = call i64 @scm_page_col(i64 %16)
store i64 %17, i64* %8
%18 = load i64, i64* %5
%19 = shl i64 1, %18
store i64 %19, i64* %9
%20 = load i64, i64* %6
%21 = load i64, i64* %7
%22 = add nsw i64 %21, 0
%23 = sitofp i64 %22 to double
%24 = load i64, i64* %9
%25 = sitofp i64 %24 to double
%26 = fdiv double %23, %25
%27 = load i64, i64* %8
%28 = add nsw i64 %27, 0
%29 = sitofp i64 %28 to double
%30 = load i64, i64* %9
%31 = sitofp i64 %30 to double
%32 = fdiv double %29, %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = call i32 @scm_vector(i64 %20, double %26, double %32, double* %34)
%36 = load i64, i64* %6
%37 = load i64, i64* %7
%38 = add nsw i64 %37, 0
%39 = sitofp i64 %38 to double
%40 = load i64, i64* %9
%41 = sitofp i64 %40 to double
%42 = fdiv double %39, %41
%43 = load i64, i64* %8
%44 = add nsw i64 %43, 1
%45 = sitofp i64 %44 to double
%46 = load i64, i64* %9
%47 = sitofp i64 %46 to double
%48 = fdiv double %45, %47
%49 = load double*, double** %4
%50 = getelementptr inbounds double, double* %49, i64 3
%51 = call i32 @scm_vector(i64 %36, double %42, double %48, double* %50)
%52 = load i64, i64* %6
%53 = load i64, i64* %7
%54 = add nsw i64 %53, 1
%55 = sitofp i64 %54 to double
%56 = load i64, i64* %9
%57 = sitofp i64 %56 to double
%58 = fdiv double %55, %57
%59 = load i64, i64* %8
%60 = add nsw i64 %59, 0
%61 = sitofp i64 %60 to double
%62 = load i64, i64* %9
%63 = sitofp i64 %62 to double
%64 = fdiv double %61, %63
%65 = load double*, double** %4
%66 = getelementptr inbounds double, double* %65, i64 6
%67 = call i32 @scm_vector(i64 %52, double %58, double %64, double* %66)
%68 = load i64, i64* %6
%69 = load i64, i64* %7
%70 = add nsw i64 %69, 1
%71 = sitofp i64 %70 to double
%72 = load i64, i64* %9
%73 = sitofp i64 %72 to double
%74 = fdiv double %71, %73
%75 = load i64, i64* %8
%76 = add nsw i64 %75, 1
%77 = sitofp i64 %76 to double
%78 = load i64, i64* %9
%79 = sitofp i64 %78 to double
%80 = fdiv double %77, %79
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 9
%83 = call i32 @scm_vector(i64 %68, double %74, double %80, double* %82)
ret void
}

LLVM IR (-O2):
define void @scm_page_corners(i64 %0, double* %1) {
%3 = tail call i64 @scm_page_level(i64 %0)
%4 = tail call i64 @scm_page_root(i64 %0)
%5 = tail call i64 @scm_page_row(i64 %0)
%6 = tail call i64 @scm_page_col(i64 %0)
%7 = shl nuw i64 1, %3
%8 = sitofp i64 %5 to double
%9 = sitofp i64 %7 to double
%10 = fdiv double %8, %9
%11 = sitofp i64 %6 to double
%12 = fdiv double %11, %9
%13 = tail call i32 @scm_vector(i64 %4, double %10, double %12, double* %1)
%14 = add nsw i64 %6, 1
%15 = sitofp i64 %14 to double
%16 = fdiv double %15, %9
%17 = getelementptr inbounds double, double* %1, i64 3
%18 = tail call i32 @scm_vector(i64 %4, double %10, double %16, double* %17)
%19 = add nsw i64 %5, 1
%20 = sitofp i64 %19 to double
%21 = fdiv double %20, %9
%22 = getelementptr inbounds double, double* %1, i64 6
%23 = tail call i32 @scm_vector(i64 %4, double %21, double %12, double* %22)
%24 = getelementptr inbounds double, double* %1, i64 9
%25 = tail call i32 @scm_vector(i64 %4, double %21, double %16, double* %24)
ret void
}