#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 */
scalar_t__ floor(double);
void hsvrgb(double *hsv, double *rgb) {
  double f, p, q, t;
  int i;
  hsv[0] = ((int)hsv[0] % 360) / 60.;
  i = (int)floor((double)hsv[0]);
  f = hsv[0] - i;
  p = hsv[2] * (1.0 - hsv[1]);
  q = hsv[2] * (1.0 - (hsv[1] * f));
  t = hsv[2] * (1.0 - (hsv[1] * (1.0 - f)));
  switch (i) {
  case 0:
    rgb[0] = hsv[2];
    rgb[1] = t;
    rgb[2] = p;
    break;
  case 1:
    rgb[0] = q;
    rgb[1] = hsv[2];
    rgb[2] = p;
    break;
  case 2:
    rgb[0] = p;
    rgb[1] = hsv[2];
    rgb[2] = t;
    break;
  case 3:
    rgb[0] = p;
    rgb[1] = q;
    rgb[2] = hsv[2];
    break;
  case 4:
    rgb[0] = t;
    rgb[1] = p;
    rgb[2] = hsv[2];
    break;
  case 5:
    rgb[0] = hsv[2];
    rgb[1] = p;
    rgb[2] = q;
    break;
  }
}


x86 assembly (clang, -O0):
<hsvrgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvttsd2si (%rax),%ecx
movslq %ecx,%rdx
imul   $0xffffffffb60b60b7,%rdx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x8,%edx
add    %esi,%edx
imul   $0x168,%edx,%edx
sub    %edx,%ecx
cvtsi2sd %ecx,%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <floor@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
movsd  0x10(%rax),%xmm0
movsd  0xe6e(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
movsd  0x10(%rax),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  0x10(%rax),%xmm0
movsd  -0x18(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x5,%rax
ja     1348 <hsvrgb+0x238>
mov    -0x40(%rbp),%rax
lea    0xdf8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1348 <hsvrgb+0x238>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1348 <hsvrgb+0x238>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1348 <hsvrgb+0x238>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1348 <hsvrgb+0x238>
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1348 <hsvrgb+0x238>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsvrgb>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cvttsd2si (%rdi),%eax
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x8,%ecx
add    %edx,%ecx
imul   $0x168,%ecx,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    %rsi,%r14
divsd  0xeb5(%rip),%xmm0
movsd  %xmm0,(%rdi)
call   1030 <floor@plt>
cmp    $0x5,%eax
ja     122e <hsvrgb+0x11e>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rbx),%xmm3
subsd  %xmm0,%xmm3
movsd  0x8(%rbx),%xmm4
movsd  0x10(%rbx),%xmm2
movsd  0xe8a(%rip),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm4,%xmm0
mulsd  %xmm2,%xmm0
movapd %xmm1,%xmm5
subsd  %xmm3,%xmm5
mulsd  %xmm4,%xmm5
mulsd  %xmm3,%xmm4
movapd %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm5,%xmm1
mulsd  %xmm2,%xmm1
mov    %eax,%eax
lea    0xe59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  %xmm2,(%r14)
movsd  %xmm1,0x8(%r14)
jmp    1228 <hsvrgb+0x118>
movsd  %xmm3,(%r14)
movsd  0x10(%rbx),%xmm1
movsd  %xmm1,0x8(%r14)
jmp    1228 <hsvrgb+0x118>
movsd  %xmm0,(%r14)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x8(%r14)
movapd %xmm1,%xmm0
jmp    1228 <hsvrgb+0x118>
movsd  %xmm0,(%r14)
movsd  %xmm3,0x8(%r14)
movsd  0x10(%rbx),%xmm0
jmp    1228 <hsvrgb+0x118>
movsd  %xmm1,(%r14)
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rbx),%xmm0
jmp    1228 <hsvrgb+0x118>
movsd  %xmm2,(%r14)
movsd  %xmm0,0x8(%r14)
movapd %xmm3,%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @hsvrgb(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = fptosi double %12 to i32
%14 = srem i32 %13, 360
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 6.000000e+01
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 0
store double %16, double* %18
%19 = load double*, double** %3
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = call i64 @floor(double %21)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %9
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load i32, i32* %9
%28 = sitofp i32 %27 to double
%29 = fsub double %26, %28
store double %29, double* %5
%30 = load double*, double** %3
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double*, double** %3
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = fsub double 1.000000e+00, %35
%37 = fmul double %32, %36
store double %37, double* %6
%38 = load double*, double** %3
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = load double*, double** %3
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = load double, double* %5
%45 = fneg double %43
%46 = call double @llvm.fmuladd.f64(double %45, double %44, double 1.000000e+00)
%47 = fmul double %40, %46
store double %47, double* %7
%48 = load double*, double** %3
%49 = getelementptr inbounds double, double* %48, i64 2
%50 = load double, double* %49
%51 = load double*, double** %3
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = load double, double* %5
%55 = fsub double 1.000000e+00, %54
%56 = fneg double %53
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double 1.000000e+00)
%58 = fmul double %50, %57
store double %58, double* %8
%59 = load i32, i32* %9
switch i32 %59, label %132 [
i32 0, label %60
i32 1, label %72
i32 2, label %84
i32 3, label %96
i32 4, label %108
i32 5, label %120
]
60: ; preds = %2
%61 = load double*, double** %3
%62 = getelementptr inbounds double, double* %61, i64 2
%63 = load double, double* %62
%64 = load double*, double** %4
%65 = getelementptr inbounds double, double* %64, i64 0
store double %63, double* %65
%66 = load double, double* %8
%67 = load double*, double** %4
%68 = getelementptr inbounds double, double* %67, i64 1
store double %66, double* %68
%69 = load double, double* %6
%70 = load double*, double** %4
%71 = getelementptr inbounds double, double* %70, i64 2
store double %69, double* %71
br label %132
72: ; preds = %2
%73 = load double, double* %7
%74 = load double*, double** %4
%75 = getelementptr inbounds double, double* %74, i64 0
store double %73, double* %75
%76 = load double*, double** %3
%77 = getelementptr inbounds double, double* %76, i64 2
%78 = load double, double* %77
%79 = load double*, double** %4
%80 = getelementptr inbounds double, double* %79, i64 1
store double %78, double* %80
%81 = load double, double* %6
%82 = load double*, double** %4
%83 = getelementptr inbounds double, double* %82, i64 2
store double %81, double* %83
br label %132
84: ; preds = %2
%85 = load double, double* %6
%86 = load double*, double** %4
%87 = getelementptr inbounds double, double* %86, i64 0
store double %85, double* %87
%88 = load double*, double** %3
%89 = getelementptr inbounds double, double* %88, i64 2
%90 = load double, double* %89
%91 = load double*, double** %4
%92 = getelementptr inbounds double, double* %91, i64 1
store double %90, double* %92
%93 = load double, double* %8
%94 = load double*, double** %4
%95 = getelementptr inbounds double, double* %94, i64 2
store double %93, double* %95
br label %132
96: ; preds = %2
%97 = load double, double* %6
%98 = load double*, double** %4
%99 = getelementptr inbounds double, double* %98, i64 0
store double %97, double* %99
%100 = load double, double* %7
%101 = load double*, double** %4
%102 = getelementptr inbounds double, double* %101, i64 1
store double %100, double* %102
%103 = load double*, double** %3
%104 = getelementptr inbounds double, double* %103, i64 2
%105 = load double, double* %104
%106 = load double*, double** %4
%107 = getelementptr inbounds double, double* %106, i64 2
store double %105, double* %107
br label %132
108: ; preds = %2
%109 = load double, double* %8
%110 = load double*, double** %4
%111 = getelementptr inbounds double, double* %110, i64 0
store double %109, double* %111
%112 = load double, double* %6
%113 = load double*, double** %4
%114 = getelementptr inbounds double, double* %113, i64 1
store double %112, double* %114
%115 = load double*, double** %3
%116 = getelementptr inbounds double, double* %115, i64 2
%117 = load double, double* %116
%118 = load double*, double** %4
%119 = getelementptr inbounds double, double* %118, i64 2
store double %117, double* %119
br label %132
120: ; preds = %2
%121 = load double*, double** %3
%122 = getelementptr inbounds double, double* %121, i64 2
%123 = load double, double* %122
%124 = load double*, double** %4
%125 = getelementptr inbounds double, double* %124, i64 0
store double %123, double* %125
%126 = load double, double* %6
%127 = load double*, double** %4
%128 = getelementptr inbounds double, double* %127, i64 1
store double %126, double* %128
%129 = load double, double* %7
%130 = load double*, double** %4
%131 = getelementptr inbounds double, double* %130, i64 2
store double %129, double* %131
br label %132
132: ; preds = %2, %120, %108, %96, %84, %72, %60
ret void
}

LLVM IR (-O2):
define void @hsvrgb(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = fptosi double %3 to i32
%5 = srem i32 %4, 360
%6 = sitofp i32 %5 to double
%7 = fdiv double %6, 6.000000e+01
store double %7, double* %0
%8 = tail call i64 @floor(double %7)
%9 = trunc i64 %8 to i32
%10 = load double, double* %0
%11 = sitofp i32 %9 to double
%12 = fsub double %10, %11
%13 = getelementptr inbounds double, double* %0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %0, i64 1
%16 = load double, double* %15
%17 = fsub double 1.000000e+00, %16
%18 = fmul double %14, %17
%19 = fneg double %16
%20 = tail call double @llvm.fmuladd.f64(double %19, double %12, double 1.000000e+00)
%21 = fmul double %14, %20
%22 = fsub double 1.000000e+00, %12
%23 = tail call double @llvm.fmuladd.f64(double %19, double %22, double 1.000000e+00)
%24 = fmul double %14, %23
switch i32 %9, label %44 [
i32 0, label %25
i32 1, label %27
i32 2, label %30
i32 3, label %33
i32 4, label %36
i32 5, label %39
]
25: ; preds = %2
store double %14, double* %1
%26 = getelementptr inbounds double, double* %1, i64 1
store double %24, double* %26
br label %41
27: ; preds = %2
store double %21, double* %1
%28 = load double, double* %13
%29 = getelementptr inbounds double, double* %1, i64 1
store double %28, double* %29
br label %41
30: ; preds = %2
store double %18, double* %1
%31 = load double, double* %13
%32 = getelementptr inbounds double, double* %1, i64 1
store double %31, double* %32
br label %41
33: ; preds = %2
store double %18, double* %1
%34 = getelementptr inbounds double, double* %1, i64 1
store double %21, double* %34
%35 = load double, double* %13
br label %41
36: ; preds = %2
store double %24, double* %1
%37 = getelementptr inbounds double, double* %1, i64 1
store double %18, double* %37
%38 = load double, double* %13
br label %41
39: ; preds = %2
store double %14, double* %1
%40 = getelementptr inbounds double, double* %1, i64 1
store double %18, double* %40
br label %41
41: ; preds = %25, %27, %30, %33, %36, %39
%42 = phi double [ %21, %39 ], [ %38, %36 ], [ %35, %33 ], [ %24, %30 ], [ %18, %27 ], [ %18, %25 ]
%43 = getelementptr inbounds double, double* %1, i64 2
store double %42, double* %43
br label %44
44: ; preds = %41, %2
ret void
}