#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;
double pow(int /*<<< orphan*/, int);
int /*<<< orphan*/ sin(double);
double _win(double t, double left, double width, double rise,
            double amplitude) {
  double r, a;
  width -= rise;
  t -= left - rise / 2;
  if (t <= 0) {
    r = 0.0;
  } else if (t < rise) {
    a = t / rise * M_PI / 2;
    r = pow(sin(a), 2);
  } else if (t < rise + width) {
    r = 1.0;
  } else if (t < rise + width + rise) {
    a = (t - width) / rise * M_PI / 2;
    r = pow(sin(a), 2);
  } else {
    r = 0.0;
  }
  return (r * amplitude);
}


x86 assembly (clang, -O0):
<_win>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1197 <_win+0x77>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    129c <_win+0x17c>
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f1 <_win+0xd1>
movsd  -0x8(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    0x2e2c(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1297 <_win+0x177>
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121c <_win+0xfc>
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1292 <_win+0x172>
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1285 <_win+0x165>
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    0x2d98(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xda4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    128d <_win+0x16d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1292 <_win+0x172>
jmp    1297 <_win+0x177>
jmp    129c <_win+0x17c>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_win>:
push   %rax
movsd  0xed7(%rip),%xmm5
mulsd  %xmm3,%xmm5
addsd  %xmm1,%xmm5
subsd  %xmm5,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    11ac <_win+0x8c>
ucomisd %xmm0,%xmm3
jbe    114c <_win+0x2c>
movsd  %xmm4,(%rsp)
jmp    117b <_win+0x5b>
subsd  %xmm3,%xmm2
movapd %xmm2,%xmm5
addsd  %xmm3,%xmm5
ucomisd %xmm0,%xmm5
jbe    1168 <_win+0x48>
movsd  0xea2(%rip),%xmm1
jmp    11ac <_win+0x8c>
addsd  %xmm3,%xmm5
ucomisd %xmm0,%xmm5
jbe    11ac <_win+0x8c>
movsd  %xmm4,(%rsp)
subsd  %xmm2,%xmm0
divsd  %xmm3,%xmm0
mov    0x2e62(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  0xe7e(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm4
mulsd  %xmm4,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @_win(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %2, %3
%7 = fmul double %3, 5.000000e-01
%8 = fsub double %1, %7
%9 = fsub double %0, %8
%10 = fcmp ugt double %9, 0.000000e+00
br i1 %10, label %11, label %29
11: ; preds = %5
%12 = fcmp olt double %9, %3
br i1 %12, label %21, label %13
13: ; preds = %11
%14 = fadd double %6, %3
%15 = fcmp olt double %9, %14
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = fadd double %14, %3
%18 = fcmp olt double %9, %17
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = fsub double %9, %6
br label %21
21: ; preds = %11, %19
%22 = phi double [ %20, %19 ], [ %9, %11 ]
%23 = fdiv double %22, %3
%24 = load double, double* @M_PI
%25 = fmul double %23, %24
%26 = fmul double %25, 5.000000e-01
%27 = tail call i32 @sin(double %26)
%28 = tail call double @pow(i32 %27, i32 2)
br label %29
29: ; preds = %21, %16, %13, %5
%30 = phi double [ 0.000000e+00, %5 ], [ 1.000000e+00, %13 ], [ 0.000000e+00, %16 ], [ %28, %21 ]
%31 = fmul double %30, %4
ret double %31
}