#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__ fabs(double);
void hsv2rgb(double H, double S, double V, double *r, double *g, double *b) {
  double h_aux, f, p, q, t, v_aux;
  h_aux = ((int)fabs(H / 60.0)) % 6;
  f = (H / 60.0) - h_aux;
  v_aux = V;
  p = v_aux * (1 - S);
  q = v_aux * (1 - f * S);
  t = v_aux * (1 - (1 - f) * S);
  if (((int)h_aux) == 0) {
    *r = v_aux;
    *g = t;
    *b = p;
  } else if (((int)h_aux == 1)) {
    *r = q;
    *g = v_aux;
    *b = p;
  } else if (((int)h_aux == 2)) {
    *r = p;
    *g = v_aux;
    *b = t;
  } else if (((int)h_aux == 3)) {
    *r = p;
    *g = q;
    *b = v_aux;
  } else if (((int)h_aux == 4)) {
    *r = t;
    *g = p;
    *b = v_aux;
  } else if (((int)h_aux == 5)) {
    *r = v_aux;
    *g = p;
    *b = q;
  }
}


x86 assembly (clang, -O0):
<hsv2rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec8(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe34(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xded(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvttsd2si -0x38(%rbp),%eax
cmp    $0x0,%eax
jne    125a <hsv2rgb+0x14a>
movsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1390 <hsv2rgb+0x280>
cvttsd2si -0x38(%rbp),%eax
cmp    $0x1,%eax
jne    1294 <hsv2rgb+0x184>
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    138b <hsv2rgb+0x27b>
cvttsd2si -0x38(%rbp),%eax
cmp    $0x2,%eax
jne    12ce <hsv2rgb+0x1be>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1386 <hsv2rgb+0x276>
cvttsd2si -0x38(%rbp),%eax
cmp    $0x3,%eax
jne    1308 <hsv2rgb+0x1f8>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1381 <hsv2rgb+0x271>
cvttsd2si -0x38(%rbp),%eax
cmp    $0x4,%eax
jne    1342 <hsv2rgb+0x232>
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    137c <hsv2rgb+0x26c>
cvttsd2si -0x38(%rbp),%eax
cmp    $0x5,%eax
jne    1377 <hsv2rgb+0x267>
movsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    137c <hsv2rgb+0x26c>
jmp    1381 <hsv2rgb+0x271>
jmp    1386 <hsv2rgb+0x276>
jmp    138b <hsv2rgb+0x27b>
jmp    1390 <hsv2rgb+0x280>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsv2rgb>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
divsd  0xeca(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x5,%eax
ja     1222 <hsv2rgb+0x112>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm6
subsd  %xmm0,%xmm6
movsd  0xe88(%rip),%xmm1
movapd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm4
subsd  %xmm4,%xmm0
movsd  0x18(%rsp),%xmm5
mulsd  %xmm5,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm6,%xmm2
mulsd  %xmm4,%xmm6
movapd %xmm1,%xmm3
subsd  %xmm6,%xmm3
mulsd  %xmm5,%xmm3
mulsd  %xmm4,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm5,%xmm1
lea    0xe4d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movapd %xmm5,%xmm2
movapd %xmm1,%xmm4
jmp    *%rax
movapd %xmm3,%xmm2
movapd %xmm5,%xmm4
jmp    1214 <hsv2rgb+0x104>
movapd %xmm0,%xmm2
movapd %xmm5,%xmm4
movapd %xmm1,%xmm0
jmp    1214 <hsv2rgb+0x104>
movapd %xmm0,%xmm2
movapd %xmm3,%xmm4
movapd %xmm5,%xmm0
jmp    1214 <hsv2rgb+0x104>
movapd %xmm1,%xmm2
movapd %xmm0,%xmm4
movapd %xmm5,%xmm0
jmp    1214 <hsv2rgb+0x104>
movapd %xmm5,%xmm2
movapd %xmm0,%xmm4
movapd %xmm3,%xmm0
movsd  %xmm2,(%rbx)
movsd  %xmm4,(%r15)
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @hsv2rgb(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fdiv double %0, 6.000000e+01
%8 = tail call i64 @fabs(double %7)
%9 = trunc i64 %8 to i32
%10 = srem i32 %9, 6
%11 = sitofp i32 %10 to double
%12 = fsub double %7, %11
%13 = fsub double 1.000000e+00, %1
%14 = fmul double %13, %2
%15 = fneg double %12
%16 = tail call double @llvm.fmuladd.f64(double %15, double %1, double 1.000000e+00)
%17 = fmul double %16, %2
%18 = fsub double 1.000000e+00, %12
%19 = fneg double %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double %1, double 1.000000e+00)
%21 = fmul double %20, %2
switch i32 %10, label %31 [
i32 0, label %27
i32 1, label %22
i32 2, label %23
i32 3, label %24
i32 4, label %25
i32 5, label %26
]
22: ; preds = %6
br label %27
23: ; preds = %6
br label %27
24: ; preds = %6
br label %27
25: ; preds = %6
br label %27
26: ; preds = %6
br label %27
27: ; preds = %6, %23, %25, %26, %24, %22
%28 = phi double [ %17, %22 ], [ %14, %24 ], [ %2, %26 ], [ %21, %25 ], [ %14, %23 ], [ %2, %6 ]
%29 = phi double [ %2, %22 ], [ %17, %24 ], [ %14, %26 ], [ %14, %25 ], [ %2, %23 ], [ %21, %6 ]
%30 = phi double [ %14, %22 ], [ %2, %24 ], [ %17, %26 ], [ %2, %25 ], [ %21, %23 ], [ %14, %6 ]
store double %28, double* %3
store double %29, double* %4
store double %30, double* %5
br label %31
31: ; preds = %27, %6
ret void
}