#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 floor(double);
int /*<<< orphan*/ printf(char *, double);
int main() {
  double theta = 7e20;
  const double P1 = 4 * 7.85398125648498535156e-01;
  const double P2 = 4 * 3.77489470793079817668e-08;
  const double P3 = 4 * 2.69515142907905952645e-15;
  const double TwoPi = 2 * (P1 + P2 + P3);
  double y = 2 * floor(theta / TwoPi);
  double r = ((theta - y * P1) - y * P2) - y * P3;
  printf("%e\n", r);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  0xef0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe5c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe28(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdf4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xed7(%rip),%xmm0
call   1040 <floor@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xec9(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xec5(%rip),%xmm1
movsd  0xec5(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xebd(%rip),%xmm0
addsd  %xmm2,%xmm0
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%e\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double 7.000000e+20, double* %1
store double 0x400921FB40000000, double* %2
store double 0x3E84442D00000000, double* %3
store double 0x3D08469898CC5170, double* %4
store double 0x401921FB54442D18, double* %5
%8 = load double, double* %1
%9 = fdiv double %8, 0x401921FB54442D18
%10 = call i32 @floor(double %9)
%11 = mul nsw i32 2, %10
%12 = sitofp i32 %11 to double
store double %12, double* %6
%13 = load double, double* %1
%14 = load double, double* %6
%15 = fneg double %14
%16 = call double @llvm.fmuladd.f64(double %15, double 0x400921FB40000000, double %13)
%17 = load double, double* %6
%18 = fneg double %17
%19 = call double @llvm.fmuladd.f64(double %18, double 0x3E84442D00000000, double %16)
%20 = load double, double* %6
%21 = fneg double %20
%22 = call double @llvm.fmuladd.f64(double %21, double 0x3D08469898CC5170, double %19)
store double %22, double* %7
%23 = load double, double* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%e\0A\00"
define i32 @main() {
%1 = tail call i32 @floor(double 0x4418286971022FCF)
%2 = shl nsw i32 %1, 1
%3 = sitofp i32 %2 to double
%4 = fneg double %3
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x400921FB40000000, double 7.000000e+20)
%6 = tail call double @llvm.fmuladd.f64(double %4, double 0x3E84442D00000000, double %5)
%7 = tail call double @llvm.fmuladd.f64(double %4, double 0x3D08469898CC5170, double %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %7)
ret i32 0
}