#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 */
typedef int offset;

/* Variables and functions */
scalar_t__ sin(float);
int sin_color_cycle(float time, float wavelength, int start, int end) {
  float midpoint = (start + end) / 2;
  float amplitude = (end - start) / 2;
  if (amplitude == 0 || wavelength == 0) {
    return -1;
  }
  float offset = (midpoint / amplitude);
  float rad = (((2 * 3.14) * time) / wavelength) + ((3 * 3.14) / 2);
  return (int)amplitude * ((offset) + sin(rad));
}


x86 assembly (clang, -O0):
<sin_color_cycle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1172 <sin_color_cycle+0x62>
jp     1172 <sin_color_cycle+0x62>
jmp    1189 <sin_color_cycle+0x79>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1195 <sin_color_cycle+0x85>
jp     1195 <sin_color_cycle+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    121b <sin_color_cycle+0x10b>
movss  -0x18(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe53(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe32(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
cvttss2si -0x1c(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <sin@plt>
movss  -0x2c(%rbp),%xmm1
movss  -0x28(%rbp),%xmm0
cvtsi2ss %rax,%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin_color_cycle>:
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
mov    $0xffffffff,%eax
jne    1123 <sin_color_cycle+0x13>
jnp    11a9 <sin_color_cycle+0x99>
mov    %esi,%ecx
sub    %edi,%ecx
lea    0x1(%rcx),%edx
cmp    $0x3,%edx
jb     11a9 <sin_color_cycle+0x99>
sub    $0x28,%rsp
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
add    %edi,%esi
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
cvtsi2ss %eax,%xmm3
divss  %xmm2,%xmm3
movss  %xmm3,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mulsd  0xe98(%rip),%xmm0
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
addsd  0xe90(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvttps2dq %xmm2,%xmm1
cvtdq2ps %xmm1,%xmm1
movaps %xmm1,0x10(%rsp)
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
cvttss2si %xmm0,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @sin_color_cycle(float %0, float %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %6
store float %1, float* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = add nsw i32 %14, %15
%17 = sdiv i32 %16, 2
%18 = sitofp i32 %17 to float
store float %18, float* %10
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = sub nsw i32 %19, %20
%22 = sdiv i32 %21, 2
%23 = sitofp i32 %22 to float
store float %23, float* %11
%24 = load float, float* %11
%25 = fcmp oeq float %24, 0.000000e+00
br i1 %25, label %29, label %26
26: ; preds = %4
%27 = load float, float* %7
%28 = fcmp oeq float %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %26, %4
store i32 -1, i32* %5
br label %52
30: ; preds = %26
%31 = load float, float* %10
%32 = load float, float* %11
%33 = fdiv float %31, %32
store float %33, float* %12
%34 = load float, float* %6
%35 = fpext float %34 to double
%36 = fmul double 6.280000e+00, %35
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = fdiv double %36, %38
%40 = fadd double %39, 4.710000e+00
%41 = fptrunc double %40 to float
store float %41, float* %13
%42 = load float, float* %11
%43 = fptosi float %42 to i32
%44 = sitofp i32 %43 to float
%45 = load float, float* %12
%46 = load float, float* %13
%47 = call i64 @sin(float %46)
%48 = sitofp i64 %47 to float
%49 = fadd float %45, %48
%50 = fmul float %44, %49
%51 = fptosi float %50 to i32
store i32 %51, i32* %5
br label %52
52: ; preds = %30, %29
%53 = load i32, i32* %5
ret i32 %53
}

LLVM IR (-O2):
define i32 @sin_color_cycle(float %0, float %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %3, %2
%6 = sdiv i32 %5, 2
%7 = sitofp i32 %6 to float
%8 = add i32 %5, 1
%9 = icmp ult i32 %8, 3
%10 = fcmp oeq float %1, 0.000000e+00
%11 = or i1 %10, %9
br i1 %11, label %30, label %12
12: ; preds = %4
%13 = add nsw i32 %3, %2
%14 = sdiv i32 %13, 2
%15 = sitofp i32 %14 to float
%16 = fdiv float %15, %7
%17 = fpext float %0 to double
%18 = fmul double %17, 6.280000e+00
%19 = fpext float %1 to double
%20 = fdiv double %18, %19
%21 = fadd double %20, 4.710000e+00
%22 = fptrunc double %21 to float
%23 = fptosi float %7 to i32
%24 = sitofp i32 %23 to float
%25 = tail call i64 @sin(float %22)
%26 = sitofp i64 %25 to float
%27 = fadd float %16, %26
%28 = fmul float %27, %24
%29 = fptosi float %28 to i32
br label %30
30: ; preds = %4, %12
%31 = phi i32 [ %29, %12 ], [ -1, %4 ]
ret i32 %31
}