#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 */
int /*<<< orphan*/ PeirceQuincuncial(double const, double const, double *,
                                     double *);
double cos(double);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
int main() {
  const int nx = 10;
  const int ny = 10;
  int ix, iy;
  printf("PVF(1)\n");
  for (ix = 0; ix < nx; ++ix) {
    const double tx = ((double)ix + 0.5) / (double)nx;
    const double x = 2 * tx - 1.;
    for (iy = 0; iy < ny; ++iy) {
      const double ty = ((double)iy + 0.5) / (double)ny;
      const double y = 2 * ty - 1.;
      double phi;
      double theta;
      PeirceQuincuncial(x, y, &phi, &theta);
      printf("p{%g, %g, %g}\n", sin(phi) * cos(theta), sin(phi) * sin(theta),
             cos(phi));
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    12b6 <main+0x176>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe51(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    12a3 <main+0x163>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe3a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe26(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe04(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1030 <PeirceQuincuncial@plt>
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
lea    0xd92(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bf <main+0x7f>
jmp    12a8 <main+0x168>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
movsd  0xe89(%rip),%xmm2
movsd  0xe89(%rip),%xmm3
movsd  0xe89(%rip),%xmm4
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r15
lea    0xe88(%rip),%rbx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
addsd  %xmm2,%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,0x28(%rsp)
mov    $0xa,%ebp
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x38(%rsp)
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm4,%xmm1
movsd  0x28(%rsp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <PeirceQuincuncial@plt>
movsd  0x10(%rsp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm2
mov    %rbx,%rdi
movsd  0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x3,%al
call   1050 <printf@plt>
movsd  0x38(%rsp),%xmm0
movsd  0xd97(%rip),%xmm1
movsd  0xd87(%rip),%xmm4
movsd  0xd77(%rip),%xmm3
movsd  0xd67(%rip),%xmm2
addsd  %xmm1,%xmm0
add    $0xffffffff,%ebp
jne    11d0 <main+0x80>
movsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%r12d
cmp    $0xa,%r12d
jne    11a0 <main+0x50>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PVF(1)\0A\00"
@.str.1 = [15 x i8] c"p{%g, %g, %g}\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %1
store i32 10, i32* %2
store i32 10, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %13
13: ; preds = %53, %0
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %56
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = fadd double %18, 5.000000e-01
%20 = fdiv double %19, 1.000000e+01
store double %20, double* %6
%21 = load double, double* %6
%22 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %21, double -1.000000e+00)
store double %22, double* %7
store i32 0, i32* %5
br label %23
23: ; preds = %49, %16
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %52
26: ; preds = %23
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 5.000000e-01
%30 = fdiv double %29, 1.000000e+01
store double %30, double* %8
%31 = load double, double* %8
%32 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %31, double -1.000000e+00)
store double %32, double* %9
%33 = load double, double* %7
%34 = load double, double* %9
%35 = call i32 @PeirceQuincuncial(double %33, double %34, double* %10, double* %11)
%36 = load double, double* %10
%37 = call double @sin(double %36)
%38 = load double, double* %11
%39 = call double @cos(double %38)
%40 = fmul double %37, %39
%41 = load double, double* %10
%42 = call double @sin(double %41)
%43 = load double, double* %11
%44 = call double @sin(double %43)
%45 = fmul double %42, %44
%46 = load double, double* %10
%47 = call double @cos(double %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %40, double %45, double %47)
br label %49
49: ; preds = %26
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %23
52: ; preds = %23
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %13
56: ; preds = %13
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"p{%g, %g, %g}\0A\00"
@str = [7 x i8] c"PVF(1)\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
br label %6
6: ; preds = %0, %34
%7 = phi i32 [ 0, %0 ], [ %35, %34 ]
%8 = sitofp i32 %7 to double
%9 = fadd double %8, 5.000000e-01
%10 = fdiv double %9, 1.000000e+01
%11 = call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double -1.000000e+00)
br label %12
12: ; preds = %6, %12
%13 = phi i32 [ 0, %6 ], [ %32, %12 ]
%14 = sitofp i32 %13 to double
%15 = fadd double %14, 5.000000e-01
%16 = fdiv double %15, 1.000000e+01
%17 = call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double -1.000000e+00)
%18 = call i32 @PeirceQuincuncial(double %11, double %17, double* %1, double* %2)
%19 = load double, double* %1
%20 = call double @sin(double %19)
%21 = load double, double* %2
%22 = call double @cos(double %21)
%23 = fmul double %20, %22
%24 = load double, double* %1
%25 = call double @sin(double %24)
%26 = load double, double* %2
%27 = call double @sin(double %26)
%28 = fmul double %25, %27
%29 = load double, double* %1
%30 = call double @cos(double %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %23, double %28, double %30)
%32 = add nuw nsw i32 %13, 1
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %12
34: ; preds = %12
%35 = add nuw nsw i32 %7, 1
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %6
37: ; preds = %34
ret i32 0
}