#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 fabs(int);
int fmod(double, int);
void wheel(double h, double s, double l, unsigned char *rgb) {
  double c, hp, x, r1, g1, b1, m;
  c = (1 - fabs(2 * l - 1)) * s;
  hp = h / 60;
  x = c * (1 - fabs(fmod(hp, 2) - 1));
  switch ((int)hp) {
  case 0:
    r1 = c, g1 = x, b1 = 0;
    break;
  case 1:
    r1 = x, g1 = c, b1 = 0;
    break;
  case 2:
    r1 = 0, g1 = c, b1 = x;
    break;
  case 3:
    r1 = 0, g1 = x, b1 = c;
    break;
  case 4:
    r1 = x, g1 = 0, b1 = c;
    break;
  case 5:
    r1 = c, g1 = 0, b1 = x;
    break;
  default:
    r1 = 0, g1 = 0, b1 = 0;
    break;
  }
  m = l - c / 2;
  rgb[0] = (unsigned char)(255 * (r1 + m));
  rgb[1] = (unsigned char)(255 * (g1 + m));
  rgb[2] = (unsigned char)(255 * (b1 + m));
}


x86 assembly (clang, -O0):
<wheel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xeb4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
mov    %eax,%ecx
mov    $0x1,%eax
mov    %eax,-0x64(%rbp)
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <fmod@plt>
mov    %eax,%edi
add    $0xffffffff,%edi
call   1040 <fabs@plt>
movsd  -0x70(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x5,%eax
ja     12b7 <wheel+0x197>
mov    -0x60(%rbp),%rax
lea    0xe38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12cf <wheel+0x1af>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xd2f(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xd14(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x2(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wheel>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
addsd  0xeb6(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mov    $0x1,%ebp
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  0xe8a(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1030 <fmod@plt>
lea    -0x1(%rax),%edi
call   1040 <fabs@plt>
cvttsd2si 0x8(%rsp),%ecx
cmp    $0x5,%ecx
ja     11d6 <wheel+0xb6>
sub    %eax,%ebp
cvtsi2sd %ebp,%xmm3
movsd  (%rsp),%xmm5
mulsd  %xmm5,%xmm3
xorpd  %xmm0,%xmm0
lea    0xe65(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
movapd %xmm3,%xmm1
movapd %xmm5,%xmm2
jmp    *%rcx
movapd %xmm5,%xmm1
movapd %xmm3,%xmm2
jmp    121f <wheel+0xff>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm5
jmp    121f <wheel+0xff>
xorpd  %xmm2,%xmm2
movapd %xmm5,%xmm1
movapd %xmm3,%xmm0
jmp    121f <wheel+0xff>
xorpd  %xmm2,%xmm2
movapd %xmm3,%xmm1
movapd %xmm5,%xmm0
jmp    121f <wheel+0xff>
xorpd  %xmm1,%xmm1
movapd %xmm5,%xmm0
movapd %xmm3,%xmm2
jmp    121f <wheel+0xff>
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm0
movapd %xmm5,%xmm2
mulsd  0xde9(%rip),%xmm5
movsd  0x10(%rsp),%xmm4
addsd  %xmm5,%xmm4
addsd  %xmm4,%xmm2
movsd  0xddb(%rip),%xmm3
mulsd  %xmm3,%xmm2
cvttsd2si %xmm2,%eax
mov    %al,(%rbx)
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm1
cvttsd2si %xmm1,%eax
mov    %al,0x1(%rbx)
addsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
cvttsd2si %xmm4,%eax
mov    %al,0x2(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @wheel(double %0, double %1, double %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i8* %3, i8** %8
%16 = load double, double* %7
%17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double -1.000000e+00)
%18 = fptosi double %17 to i32
%19 = call i32 @fabs(i32 %18)
%20 = sub nsw i32 1, %19
%21 = sitofp i32 %20 to double
%22 = load double, double* %6
%23 = fmul double %21, %22
store double %23, double* %9
%24 = load double, double* %5
%25 = fdiv double %24, 6.000000e+01
store double %25, double* %10
%26 = load double, double* %9
%27 = load double, double* %10
%28 = call i32 @fmod(double %27, i32 2)
%29 = sub nsw i32 %28, 1
%30 = call i32 @fabs(i32 %29)
%31 = sub nsw i32 1, %30
%32 = sitofp i32 %31 to double
%33 = fmul double %26, %32
store double %33, double* %11
%34 = load double, double* %10
%35 = fptosi double %34 to i32
switch i32 %35, label %54 [
i32 0, label %36
i32 1, label %39
i32 2, label %42
i32 3, label %45
i32 4, label %48
i32 5, label %51
]
36: ; preds = %4
%37 = load double, double* %9
store double %37, double* %12
%38 = load double, double* %11
store double %38, double* %13
store double 0.000000e+00, double* %14
br label %55
39: ; preds = %4
%40 = load double, double* %11
store double %40, double* %12
%41 = load double, double* %9
store double %41, double* %13
store double 0.000000e+00, double* %14
br label %55
42: ; preds = %4
store double 0.000000e+00, double* %12
%43 = load double, double* %9
store double %43, double* %13
%44 = load double, double* %11
store double %44, double* %14
br label %55
45: ; preds = %4
store double 0.000000e+00, double* %12
%46 = load double, double* %11
store double %46, double* %13
%47 = load double, double* %9
store double %47, double* %14
br label %55
48: ; preds = %4
%49 = load double, double* %11
store double %49, double* %12
store double 0.000000e+00, double* %13
%50 = load double, double* %9
store double %50, double* %14
br label %55
51: ; preds = %4
%52 = load double, double* %9
store double %52, double* %12
store double 0.000000e+00, double* %13
%53 = load double, double* %11
store double %53, double* %14
br label %55
54: ; preds = %4
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
br label %55
55: ; preds = %54, %51, %48, %45, %42, %39, %36
%56 = load double, double* %7
%57 = load double, double* %9
%58 = fdiv double %57, 2.000000e+00
%59 = fsub double %56, %58
store double %59, double* %15
%60 = load double, double* %12
%61 = load double, double* %15
%62 = fadd double %60, %61
%63 = fmul double 2.550000e+02, %62
%64 = fptoui double %63 to i8
%65 = load i8*, i8** %8
%66 = getelementptr inbounds i8, i8* %65, i64 0
store i8 %64, i8* %66
%67 = load double, double* %13
%68 = load double, double* %15
%69 = fadd double %67, %68
%70 = fmul double 2.550000e+02, %69
%71 = fptoui double %70 to i8
%72 = load i8*, i8** %8
%73 = getelementptr inbounds i8, i8* %72, i64 1
store i8 %71, i8* %73
%74 = load double, double* %14
%75 = load double, double* %15
%76 = fadd double %74, %75
%77 = fmul double 2.550000e+02, %76
%78 = fptoui double %77 to i8
%79 = load i8*, i8** %8
%80 = getelementptr inbounds i8, i8* %79, i64 2
store i8 %78, i8* %80
ret void
}

LLVM IR (-O2):
define void @wheel(double %0, double %1, double %2, i8* nocapture writeonly %3) {
%5 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
%6 = fptosi double %5 to i32
%7 = tail call i32 @fabs(i32 %6)
%8 = sub nsw i32 1, %7
%9 = sitofp i32 %8 to double
%10 = fmul double %9, %1
%11 = fdiv double %0, 6.000000e+01
%12 = tail call i32 @fmod(double %11, i32 2)
%13 = add nsw i32 %12, -1
%14 = tail call i32 @fabs(i32 %13)
%15 = sub nsw i32 1, %14
%16 = sitofp i32 %15 to double
%17 = fmul double %10, %16
%18 = fptosi double %11 to i32
switch i32 %18, label %24 [
i32 0, label %25
i32 1, label %19
i32 2, label %20
i32 3, label %21
i32 4, label %22
i32 5, label %23
]
19: ; preds = %4
br label %25
20: ; preds = %4
br label %25
21: ; preds = %4
br label %25
22: ; preds = %4
br label %25
23: ; preds = %4
br label %25
24: ; preds = %4
br label %25
25: ; preds = %4, %24, %23, %22, %21, %20, %19
%26 = phi double [ 0.000000e+00, %24 ], [ 0.000000e+00, %23 ], [ 0.000000e+00, %22 ], [ %17, %21 ], [ %10, %20 ], [ %10, %19 ], [ %17, %4 ]
%27 = phi double [ 0.000000e+00, %24 ], [ %17, %23 ], [ %10, %22 ], [ %10, %21 ], [ %17, %20 ], [ 0.000000e+00, %19 ], [ 0.000000e+00, %4 ]
%28 = phi double [ 0.000000e+00, %24 ], [ %10, %23 ], [ %17, %22 ], [ 0.000000e+00, %21 ], [ 0.000000e+00, %20 ], [ %17, %19 ], [ %10, %4 ]
%29 = fmul double %10, 5.000000e-01
%30 = fsub double %2, %29
%31 = fadd double %30, %28
%32 = fmul double %31, 2.550000e+02
%33 = fptoui double %32 to i8
store i8 %33, i8* %3
%34 = fadd double %30, %26
%35 = fmul double %34, 2.550000e+02
%36 = fptoui double %35 to i8
%37 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %36, i8* %37
%38 = fadd double %30, %27
%39 = fmul double %38, 2.550000e+02
%40 = fptoui double %39 to i8
%41 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %40, i8* %41
ret void
}