#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 cos(double);
int sin(int);
double fprime(double x) {
  return -4 * cos(x) + 4 * x * sin(x) + 4 * x - 2 * sin(2 * x);
}


x86 assembly (clang, -O0):
<fprime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
imul   $0xfffffffc,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeba(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x8(%rbp),%edi
call   1030 <sin@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe83(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe66(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  -0x10(%rbp),%xmm0
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprime>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
shl    $0x2,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xeb8(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @fprime(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call i32 @cos(double %3)
%5 = mul nsw i32 -4, %4
%6 = sitofp i32 %5 to double
%7 = load double, double* %2
%8 = fmul double 4.000000e+00, %7
%9 = load double, double* %2
%10 = fptosi double %9 to i32
%11 = call i32 @sin(i32 %10)
%12 = sitofp i32 %11 to double
%13 = call double @llvm.fmuladd.f64(double %8, double %12, double %6)
%14 = load double, double* %2
%15 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %14, double %13)
%16 = load double, double* %2
%17 = fmul double 2.000000e+00, %16
%18 = fptosi double %17 to i32
%19 = call i32 @sin(i32 %18)
%20 = mul nsw i32 2, %19
%21 = sitofp i32 %20 to double
%22 = fsub double %15, %21
ret double %22
}

LLVM IR (-O2):
define double @fprime(double %0) {
%2 = tail call i32 @cos(double %0)
%3 = mul nsw i32 %2, -4
%4 = sitofp i32 %3 to double
%5 = fmul double %0, 4.000000e+00
%6 = fptosi double %0 to i32
%7 = tail call i32 @sin(i32 %6)
%8 = sitofp i32 %7 to double
%9 = tail call double @llvm.fmuladd.f64(double %5, double %8, double %4)
%10 = tail call double @llvm.fmuladd.f64(double %0, double 4.000000e+00, double %9)
%11 = fmul double %0, 2.000000e+00
%12 = fptosi double %11 to i32
%13 = tail call i32 @sin(i32 %12)
%14 = shl nsw i32 %13, 1
%15 = sitofp i32 %14 to double
%16 = fsub double %10, %15
ret double %16
}