#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 sin(double);
double step_chirp(double time, double time_start, double step_time,
                  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);
    if ((time - time_start) < step_time) {
      a = amp_start;
    } else {
      a = amp_stop;
    }
    excite = a * 0.017453292519943 *
             sin(2.0 * 3.14159265358979 * f * (time - time_start));
    return excite;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<step_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  %xmm7,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1224 <step_chirp+0x114>
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1224 <step_chirp+0x114>
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xe80(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c8 <step_chirp+0xb8>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    11d2 <step_chirp+0xc2>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe36(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe1c(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122c <step_chirp+0x11c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<step_chirp>:
xorpd  %xmm8,%xmm8
ucomisd %xmm1,%xmm0
jbe    1183 <step_chirp+0x73>
subsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm3
jbe    1183 <step_chirp+0x73>
sub    $0x18,%rsp
subsd  %xmm4,%xmm5
addsd  %xmm3,%xmm3
divsd  %xmm3,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm0,%xmm1
cmpltsd %xmm2,%xmm1
andpd  %xmm1,%xmm6
andnpd %xmm7,%xmm1
orpd   %xmm6,%xmm1
mulsd  0xeaa(%rip),%xmm1
movapd %xmm1,(%rsp)
addsd  %xmm4,%xmm5
mulsd  0xea1(%rip),%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm5,%xmm0
call   1030 <sin@plt>
movapd %xmm0,%xmm8
mulsd  (%rsp),%xmm8
add    $0x18,%rsp
movapd %xmm8,%xmm0
ret

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

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