#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;
int /*<<< orphan*/ printf(char *, double, double const, double const,
                          double const);
double sin(double);
double sin_sse_wrapper(double);
void compare() {
  for (double x = -M_PI / 2.0; x < M_PI / 2.0; x += M_PI / 100000) {
    const double reference = sin(x);
    const double sse = sin_sse_wrapper(x);
    printf("%12.8f %12.8f %12.8f %12.8f\n", x, reference, sse, reference - sse);
  }
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea9(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe9e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
mov    0x2e71(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe7d(%rip),%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11fa <compare+0xca>
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <sin_sse_wrapper@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
subsd  -0x18(%rbp),%xmm3
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e0d(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    116b <compare+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2eaa(%rip),%r14
movsd  (%r14),%xmm1
movsd  0xeb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xeb1(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11e1 <compare+0xb1>
lea    0xeb0(%rip),%rbx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin_sse_wrapper@plt>
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  (%r14),%xmm2
movapd %xmm2,%xmm1
divsd  0xe53(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe2d(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     1170 <compare+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@.str = [29 x i8] c"%12.8f %12.8f %12.8f %12.8f\0A\00"
define void @compare() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = load double, double* @M_PI
%5 = fneg double %4
%6 = fdiv double %5, 2.000000e+00
store double %6, double* %1
br label %7
7: ; preds = %24, %0
%8 = load double, double* %1
%9 = load double, double* @M_PI
%10 = fdiv double %9, 2.000000e+00
%11 = fcmp olt double %8, %10
br i1 %11, label %12, label %29
12: ; preds = %7
%13 = load double, double* %1
%14 = call double @sin(double %13)
store double %14, double* %2
%15 = load double, double* %1
%16 = call double @sin_sse_wrapper(double %15)
store double %16, double* %3
%17 = load double, double* %1
%18 = load double, double* %2
%19 = load double, double* %3
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fsub double %20, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %17, double %18, double %19, double %22)
br label %24
24: ; preds = %12
%25 = load double, double* @M_PI
%26 = fdiv double %25, 1.000000e+05
%27 = load double, double* %1
%28 = fadd double %27, %26
store double %28, double* %1
br label %7
29: ; preds = %7
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@.str = [29 x i8] c"%12.8f %12.8f %12.8f %12.8f\0A\00"
define void @compare() {
%1 = load double, double* @M_PI
%2 = fmul double %1, -5.000000e-01
%3 = fmul double %1, 5.000000e-01
%4 = fcmp olt double %2, %3
br i1 %4, label %6, label %5
5: ; preds = %6, %0
ret void
6: ; preds = %0, %6
%7 = phi double [ %14, %6 ], [ %2, %0 ]
%8 = tail call double @sin(double %7)
%9 = tail call double @sin_sse_wrapper(double %7)
%10 = fsub double %8, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %7, double %8, double %9, double %10)
%12 = load double, double* @M_PI
%13 = fdiv double %12, 1.000000e+05
%14 = fadd double %7, %13
%15 = fmul double %12, 5.000000e-01
%16 = fcmp olt double %14, %15
br i1 %16, label %6, label %5
}