#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 cos(double);
double sin(double);
double cos_chirp(double time, double time_start, double duration,
                 double freq_start, double freq_stop, double amp_start,
                 double amp_stop) {
  double f;
  double a;
  double excite;
  if ((time > time_start) && ((time - time_start) < duration)) {
    f = freq_start +
        (freq_stop - freq_start) / (2.0 * duration) * (time - time_start);
    a = (amp_start - amp_stop) / 2.0 *
            cos(3.14159265358979 * ((time - time_start) / duration)) +
        (amp_start + amp_stop) / 2.0;
    excite = a * 0.017453292519943 *
             sin(2.0 * 3.14159265358979 * f * (time - time_start));
    return excite;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<cos_chirp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1263 <cos_chirp+0x143>
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1263 <cos_chirp+0x143>
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xe85(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xe3b(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe10(%rip),%xmm3
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdef(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xdd5(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126b <cos_chirp+0x14b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cos_chirp>:
movapd %xmm0,%xmm7
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm7
jbe    11e6 <cos_chirp+0xc6>
subsd  %xmm1,%xmm7
ucomisd %xmm7,%xmm2
jbe    11e6 <cos_chirp+0xc6>
sub    $0x28,%rsp
subsd  %xmm3,%xmm4
movapd %xmm7,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm2,%xmm2
divsd  %xmm2,%xmm4
mulsd  %xmm7,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,0x18(%rsp)
movapd %xmm5,%xmm1
subsd  %xmm6,%xmm1
mulsd  0xe8a(%rip),%xmm1
movsd  %xmm1,(%rsp)
mulsd  0xe85(%rip),%xmm0
movsd  %xmm7,0x20(%rsp)
movsd  %xmm5,0x8(%rsp)
movsd  %xmm6,0x10(%rsp)
call   1040 <cos@plt>
movsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
mulsd  0xe52(%rip),%xmm1
mulsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe51(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe46(%rip),%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @cos_chirp(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%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
%17 = alloca double
%18 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
%19 = load double, double* %9
%20 = load double, double* %10
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %67
22: ; preds = %7
%23 = load double, double* %9
%24 = load double, double* %10
%25 = fsub double %23, %24
%26 = load double, double* %11
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %67
28: ; preds = %22
%29 = load double, double* %12
%30 = load double, double* %13
%31 = load double, double* %12
%32 = fsub double %30, %31
%33 = load double, double* %11
%34 = fmul double 2.000000e+00, %33
%35 = fdiv double %32, %34
%36 = load double, double* %9
%37 = load double, double* %10
%38 = fsub double %36, %37
%39 = call double @llvm.fmuladd.f64(double %35, double %38, double %29)
store double %39, double* %16
%40 = load double, double* %14
%41 = load double, double* %15
%42 = fsub double %40, %41
%43 = fdiv double %42, 2.000000e+00
%44 = load double, double* %9
%45 = load double, double* %10
%46 = fsub double %44, %45
%47 = load double, double* %11
%48 = fdiv double %46, %47
%49 = fmul double 0x400921FB54442D11, %48
%50 = call double @cos(double %49)
%51 = load double, double* %14
%52 = load double, double* %15
%53 = fadd double %51, %52
%54 = fdiv double %53, 2.000000e+00
%55 = call double @llvm.fmuladd.f64(double %43, double %50, double %54)
store double %55, double* %17
%56 = load double, double* %17
%57 = fmul double %56, 0x3F91DF46A2529CE4
%58 = load double, double* %16
%59 = fmul double 0x401921FB54442D11, %58
%60 = load double, double* %9
%61 = load double, double* %10
%62 = fsub double %60, %61
%63 = fmul double %59, %62
%64 = call double @sin(double %63)
%65 = fmul double %57, %64
store double %65, double* %18
%66 = load double, double* %18
store double %66, double* %8
br label %68
67: ; preds = %22, %7
store double 0.000000e+00, double* %8
br label %68
68: ; preds = %67, %28
%69 = load double, double* %8
ret double %69
}

LLVM IR (-O2):
define double @cos_chirp(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fcmp ogt double %0, %1
br i1 %8, label %9, label %30
9: ; preds = %7
%10 = fsub double %0, %1
%11 = fcmp olt double %10, %2
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = fsub double %4, %3
%14 = fmul double %2, 2.000000e+00
%15 = fdiv double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double %10, double %3)
%17 = fsub double %5, %6
%18 = fmul double %17, 5.000000e-01
%19 = fdiv double %10, %2
%20 = fmul double %19, 0x400921FB54442D11
%21 = tail call double @cos(double %20)
%22 = fadd double %5, %6
%23 = fmul double %22, 5.000000e-01
%24 = tail call double @llvm.fmuladd.f64(double %18, double %21, double %23)
%25 = fmul double %24, 0x3F91DF46A2529CE4
%26 = fmul double %16, 0x401921FB54442D11
%27 = fmul double %10, %26
%28 = tail call double @sin(double %27)
%29 = fmul double %28, %25
br label %30
30: ; preds = %7, %9, %12
%31 = phi double [ %29, %12 ], [ 0.000000e+00, %9 ], [ 0.000000e+00, %7 ]
ret double %31
}