#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 */
double M_PI;
double atan(double);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  unsigned int n = 16;
  double theta = M_PI / 3.0;
  double sintab[n];
  double inv_2_n = 1.0;
  unsigned int i;
  for (i = 0; i < n; i++) {
    sintab[i] = atan(inv_2_n);
    inv_2_n *= 0.5;
  }
  double k_inv = 0.6072529350088812561694467525049282631123908521500897724;
  double x = k_inv;
  double y = 0.0;
  double z = theta;
  double v = 1.0;
  double d, tx, ty, tz;
  printf("   n           x            y            z         -d*An\n");
  printf("init %12.8f %12.8f %12.8f %12.8f\n", x, y, z, 0.0);
  for (i = 0; i < n; i++) {
    d = (z >= 0.0) ? 1 : -1;
    tx = x - d * v * y;
    ty = y + d * v * x;
    tz = z - d * sintab[i];
    x = tx;
    y = ty;
    z = tz;
    v *= 0.5;
    printf("%4u %12.8f %12.8f %12.8f %12.8f\n", i, x, y, z, d * sintab[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x10,-0x8(%rbp)
mov    0x2ea8(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11d2 <main+0xb2>
movsd  -0x28(%rbp),%xmm0
call   1040 <atan@plt>
mov    -0x80(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xe5e(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1190 <main+0x70>
movsd  0xe36(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
lea    0xe2e(%rip),%rdi
xorps  %xmm3,%xmm3
mov    $0x4,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1369 <main+0x249>
mov    -0x80(%rbp),%rax
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%ecx
mov    $0x1,%edx
ucomisd %xmm1,%xmm0
cmovae %edx,%ecx
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movq   %xmm0,%rcx
movabs $0x8000000000000000,%rdx
xor    %rdx,%rcx
movq   %rcx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rcx
movabs $0x8000000000000000,%rdx
xor    %rdx,%rcx
movq   %rcx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xcf4(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x2c(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
mov    -0x2c(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm3
lea    0xd28(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123d <main+0x11d>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    0x2ea5(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xeac(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xea7(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xf33(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0xe96(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe91(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xf1d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0xe80(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe7b(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movsd  0xe6a(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe65(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xef1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movsd  0xe54(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe4f(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movsd  0xe3e(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe39(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movsd  0xe28(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe23(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movsd  0xe0f(%rip),%xmm0
call   1050 <atan@plt>
movsd  0xe0a(%rip),%xmm0
call   1050 <atan@plt>
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movsd  (%rsp),%xmm0
divsd  0xdf1(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
movsd  0xdd9(%rip),%xmm0
xorpd  %xmm1,%xmm1
xorps  %xmm3,%xmm3
movsd  (%rsp),%xmm2
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xd36(%rip),%xmm5
movsd  0xdb6(%rip),%xmm0
movsd  0xdb6(%rip),%xmm3
xor    %ebx,%ebx
lea    0xe3d(%rip),%r15
lea    0xe78(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
movsd  (%rsp),%xmm2
ucomisd 0xd99(%rip),%xmm2
movapd %xmm0,%xmm6
setae  %al
movsd  (%r15,%rax,8),%xmm1
movsd  %xmm5,0x8(%rsp)
mulsd  %xmm1,%xmm5
movapd %xmm5,%xmm4
xorpd  0xe0e(%rip),%xmm4
unpcklpd %xmm5,%xmm4
shufpd $0x1,%xmm0,%xmm0
mulpd  %xmm4,%xmm0
addpd  %xmm6,%xmm0
mulsd  %xmm1,%xmm3
subsd  %xmm3,%xmm2
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mov    %r14,%rdi
mov    %ebx,%esi
movapd %xmm0,0x10(%rsp)
movsd  %xmm2,(%rsp)
mov    $0x4,%al
call   1040 <printf@plt>
cmp    $0xf,%rbx
je     1383 <main+0x253>
movsd  0x8(%rsp),%xmm5
mulsd  0xc9a(%rip),%xmm5
movsd  0x28(%rsp,%rbx,8),%xmm3
add    $0x1,%rbx
movapd 0x10(%rsp),%xmm0
jmp    12f0 <main+0x1c0>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@.str = [58 x i8] c" n x y z -d*An\0A\00"
@.str.1 = [34 x i8] c"init %12.8f %12.8f %12.8f %12.8f\0A\00"
@.str.2 = [33 x i8] c"%4u %12.8f %12.8f %12.8f %12.8f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i8*
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 0, i32* %1
store i32 16, i32* %2
%17 = load double, double* @M_PI
%18 = fdiv double %17, 3.000000e+00
store double %18, double* %3
%19 = load i32, i32* %2
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %4
%22 = alloca double, i64 %20
store i64 %20, i64* %5
store double 1.000000e+00, double* %6
store i32 0, i32* %7
br label %23
23: ; preds = %35, %0
%24 = load i32, i32* %7
%25 = load i32, i32* %2
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load double, double* %6
%29 = call double @atan(double %28)
%30 = load i32, i32* %7
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds double, double* %22, i64 %31
store double %29, double* %32
%33 = load double, double* %6
%34 = fmul double %33, 5.000000e-01
store double %34, double* %6
br label %35
35: ; preds = %27
%36 = load i32, i32* %7
%37 = add i32 %36, 1
store i32 %37, i32* %7
br label %23
38: ; preds = %23
store double 0x3FE36E9DB5086BCB, double* %8
%39 = load double, double* %8
store double %39, double* %9
store double 0.000000e+00, double* %10
%40 = load double, double* %3
store double %40, double* %11
store double 1.000000e+00, double* %12
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%42 = load double, double* %9
%43 = load double, double* %10
%44 = load double, double* %11
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %42, double %43, double %44, double 0.000000e+00)
store i32 0, i32* %7
br label %46
46: ; preds = %93, %38
%47 = load i32, i32* %7
%48 = load i32, i32* %2
%49 = icmp ult i32 %47, %48
br i1 %49, label %50, label %96
50: ; preds = %46
%51 = load double, double* %11
%52 = fcmp oge double %51, 0.000000e+00
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 1, i32 -1
%55 = sitofp i32 %54 to double
store double %55, double* %13
%56 = load double, double* %9
%57 = load double, double* %13
%58 = load double, double* %12
%59 = fmul double %57, %58
%60 = load double, double* %10
%61 = fneg double %59
%62 = call double @llvm.fmuladd.f64(double %61, double %60, double %56)
store double %62, double* %14
%63 = load double, double* %10
%64 = load double, double* %13
%65 = load double, double* %12
%66 = fmul double %64, %65
%67 = load double, double* %9
%68 = call double @llvm.fmuladd.f64(double %66, double %67, double %63)
store double %68, double* %15
%69 = load double, double* %11
%70 = load double, double* %13
%71 = load i32, i32* %7
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds double, double* %22, i64 %72
%74 = load double, double* %73
%75 = fneg double %70
%76 = call double @llvm.fmuladd.f64(double %75, double %74, double %69)
store double %76, double* %16
%77 = load double, double* %14
store double %77, double* %9
%78 = load double, double* %15
store double %78, double* %10
%79 = load double, double* %16
store double %79, double* %11
%80 = load double, double* %12
%81 = fmul double %80, 5.000000e-01
store double %81, double* %12
%82 = load i32, i32* %7
%83 = load double, double* %9
%84 = load double, double* %10
%85 = load double, double* %11
%86 = load double, double* %13
%87 = load i32, i32* %7
%88 = zext i32 %87 to i64
%89 = getelementptr inbounds double, double* %22, i64 %88
%90 = load double, double* %89
%91 = fmul double %86, %90
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %82, double %83, double %84, double %85, double %91)
br label %93
93: ; preds = %50
%94 = load i32, i32* %7
%95 = add i32 %94, 1
store i32 %95, i32* %7
br label %46
96: ; preds = %46
store i32 0, i32* %1
%97 = load i8*, i8** %4
%98 = load i32, i32* %1
ret i32 %98
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@.str.1 = [34 x i8] c"init %12.8f %12.8f %12.8f %12.8f\0A\00"
@.str.2 = [33 x i8] c"%4u %12.8f %12.8f %12.8f %12.8f\0A\00"
@str = [57 x i8] c" n x y z -d*An\00"
define i32 @main() {
%1 = load double, double* @M_PI
%2 = alloca [16 x double]
%3 = tail call double @atan(double 1.000000e+00)
%4 = tail call double @atan(double 5.000000e-01)
%5 = bitcast [16 x double]* %2 to <2 x double>*
store <2 x double> <double 0x3FE921FB54442D18, double 0x3FDDAC670561BB4F>, <2 x double>* %5
%6 = tail call double @atan(double 2.500000e-01)
%7 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 2
%8 = tail call double @atan(double 1.250000e-01)
%9 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 0x3FCF5B75F92C80DD, double 0x3FBFD5BA9AAC2F6E>, <2 x double>* %9
%10 = tail call double @atan(double 6.250000e-02)
%11 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 4
%12 = tail call double @atan(double 3.125000e-02)
%13 = bitcast double* %11 to <2 x double>*
store <2 x double> <double 0x3FAFF55BB72CFDEA, double 0x3F9FFD55BBA97625>, <2 x double>* %13
%14 = tail call double @atan(double 1.562500e-02)
%15 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 6
%16 = tail call double @atan(double 7.812500e-03)
%17 = bitcast double* %15 to <2 x double>*
store <2 x double> <double 0x3F8FFF555BBB729B, double 0x3F7FFFD555BBBA97>, <2 x double>* %17
%18 = tail call double @atan(double 3.906250e-03)
%19 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 8
%20 = tail call double @atan(double 0x3F60000000000000)
%21 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 0x3F6FFFF5555BBBB7, double 0x3F5FFFFD5555BBBC>, <2 x double>* %21
%22 = tail call double @atan(double 0x3F50000000000000)
%23 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 10
%24 = tail call double @atan(double 0x3F40000000000000)
%25 = bitcast double* %23 to <2 x double>*
store <2 x double> <double 0x3F4FFFFF55555BBC, double 0x3F3FFFFFD55555BC>, <2 x double>* %25
%26 = tail call double @atan(double 0x3F30000000000000)
%27 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 12
%28 = tail call double @atan(double 0x3F20000000000000)
%29 = bitcast double* %27 to <2 x double>*
store <2 x double> <double 0x3F2FFFFFF555555C, double 0x3F1FFFFFFD555556>, <2 x double>* %29
%30 = tail call double @atan(double 0x3F10000000000000)
%31 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 14
%32 = tail call double @atan(double 0x3F00000000000000)
%33 = bitcast double* %31 to <2 x double>*
store <2 x double> <double 0x3F0FFFFFFF555555, double 0x3EFFFFFFFFD55555>, <2 x double>* %33
%34 = fdiv double %1, 3.000000e+00
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double 0x3FE36E9DB5086BCB, double 0.000000e+00, double %34, double 0.000000e+00)
br label %37
37: ; preds = %60, %0
%38 = phi double [ 0x3FE921FB54442D18, %0 ], [ %63, %60 ]
%39 = phi i64 [ 0, %0 ], [ %58, %60 ]
%40 = phi double [ 1.000000e+00, %0 ], [ %61, %60 ]
%41 = phi double [ %34, %0 ], [ %52, %60 ]
%42 = phi <2 x double> [ <double 0x3FE36E9DB5086BCB, double 0.000000e+00>, %0 ], [ %50, %60 ]
%43 = fcmp oge double %41, 0.000000e+00
%44 = select i1 %43, double 1.000000e+00, double -1.000000e+00
%45 = fmul double %40, %44
%46 = fneg double %45
%47 = insertelement <2 x double> poison, double %46, i64 0
%48 = insertelement <2 x double> %47, double %45, i64 1
%49 = shufflevector <2 x double> %42, <2 x double> undef, <2 x i32> <i32 1, i32 0>
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %48, <2 x double> %49, <2 x double> %42)
%51 = fneg double %44
%52 = tail call double @llvm.fmuladd.f64(double %51, double %38, double %41)
%53 = fmul double %44, %38
%54 = trunc i64 %39 to i32
%55 = extractelement <2 x double> %50, i64 0
%56 = extractelement <2 x double> %50, i64 1
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %54, double %55, double %56, double %52, double %53)
%58 = add nuw nsw i64 %39, 1
%59 = icmp eq i64 %58, 16
br i1 %59, label %64, label %60
60: ; preds = %37
%61 = fmul double %40, 5.000000e-01
%62 = getelementptr inbounds [16 x double], [16 x double]* %2, i64 0, i64 %58
%63 = load double, double* %62
br label %37
64: ; preds = %37
ret i32 0
}