#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);
scalar_t__ floor(double);
void hsv_to_rgb(int rgb[], double h, double s, double v) {
  int i;
  double f, p, q, t, rr = 0, gg = 0, bb = 0;
  if (!(fabs(s) > 0))
    rgb[0] = rgb[1] = rgb[2] = (int)floor(255.999 * v);
  else {
    while (h >= 360.0)
      h -= 360.0;
    h /= 60.0;
    i = (int)h;
    f = h - i;
    p = v * (1.0 - s);
    q = v * (1.0 - (s * f));
    t = v * (1.0 - (s * (1.0 - f)));
    switch (i) {
    case 0:
      rr = v;
      gg = t;
      bb = p;
      break;
    case 1:
      rr = q;
      gg = v;
      bb = p;
      break;
    case 2:
      rr = p;
      gg = v;
      bb = t;
      break;
    case 3:
      rr = p;
      gg = q;
      bb = v;
      break;
    case 4:
      rr = t;
      gg = p;
      bb = v;
      break;
    case 5:
      rr = v;
      gg = p;
      bb = q;
      break;
    }
    rgb[0] = (rr < 0.0) ? 0 : (int)floor(rr * 255.999);
    rgb[1] = (gg < 0.0) ? 0 : (int)floor(gg * 255.999);
    rgb[2] = (bb < 0.0) ? 0 : (int)floor(bb * 255.999);
  }
}


x86 assembly (clang, -O0):
<hsv_to_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x0,%rax
jg     1197 <hsv_to_rgb+0x77>
movsd  0xe8e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1401 <hsv_to_rgb+0x2e1>
jmp    119c <hsv_to_rgb+0x7c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ce <hsv_to_rgb+0xae>
movsd  -0x10(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    119c <hsv_to_rgb+0x7c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe35(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
movsd  0xe07(%rip),%xmm1
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movaps %xmm1,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm4
movaps %xmm1,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%eax
mov    %rax,-0x68(%rbp)
sub    $0x5,%rax
ja     135d <hsv_to_rgb+0x23d>
mov    -0x68(%rbp),%rax
lea    0xd99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    135d <hsv_to_rgb+0x23d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    135d <hsv_to_rgb+0x23d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    135d <hsv_to_rgb+0x23d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    135d <hsv_to_rgb+0x23d>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    135d <hsv_to_rgb+0x23d>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1375 <hsv_to_rgb+0x255>
xor    %eax,%eax
mov    %eax,-0x6c(%rbp)
jmp    138a <hsv_to_rgb+0x26a>
movsd  0xc83(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    13ab <hsv_to_rgb+0x28b>
xor    %eax,%eax
mov    %eax,-0x70(%rbp)
jmp    13c0 <hsv_to_rgb+0x2a0>
movsd  0xc4d(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    13e2 <hsv_to_rgb+0x2c2>
xor    %eax,%eax
mov    %eax,-0x74(%rbp)
jmp    13f7 <hsv_to_rgb+0x2d7>
movsd  0xc16(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsv_to_rgb>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm2,0x8(%rsp)
movaps %xmm0,0x10(%rsp)
mov    %rdi,%r14
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm0
call   1030 <fabs@plt>
test   %rax,%rax
jle    120f <hsv_to_rgb+0xef>
movsd  0x8(%rsp),%xmm4
movapd 0x10(%rsp),%xmm6
ucomisd 0xea7(%rip),%xmm6
jb     118a <hsv_to_rgb+0x6a>
movsd  0xea5(%rip),%xmm0
movsd  0xe95(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  %xmm0,%xmm6
ucomisd %xmm1,%xmm6
jae    1180 <hsv_to_rgb+0x60>
divsd  0xe86(%rip),%xmm6
cvttsd2si %xmm6,%eax
cmp    $0x5,%eax
ja     1276 <hsv_to_rgb+0x156>
cvttpd2dq %xmm6,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm6
movsd  0xe6d(%rip),%xmm1
movapd %xmm1,%xmm3
movsd  0x20(%rsp),%xmm5
subsd  %xmm5,%xmm3
mulsd  %xmm4,%xmm3
movapd %xmm5,%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm4,%xmm2
movapd %xmm1,%xmm0
subsd  %xmm6,%xmm0
mulsd  %xmm5,%xmm0
subsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm1
lea    0xe34(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movapd %xmm4,%xmm0
movapd %xmm1,%xmm5
jmp    *%rax
movapd %xmm2,%xmm0
movapd %xmm4,%xmm5
jmp    1268 <hsv_to_rgb+0x148>
movsd  0x8(%rsp),%xmm0
mulsd  0xde3(%rip),%xmm0
call   1040 <floor@plt>
mov    %eax,0x8(%r14)
mov    %eax,0x4(%r14)
mov    %eax,(%r14)
jmp    12fe <hsv_to_rgb+0x1de>
movapd %xmm3,%xmm0
movapd %xmm4,%xmm5
movapd %xmm1,%xmm3
jmp    1268 <hsv_to_rgb+0x148>
movapd %xmm3,%xmm0
movapd %xmm2,%xmm5
movapd %xmm4,%xmm3
jmp    1268 <hsv_to_rgb+0x148>
movapd %xmm1,%xmm0
movapd %xmm3,%xmm5
movapd %xmm4,%xmm3
jmp    1268 <hsv_to_rgb+0x148>
movapd %xmm4,%xmm0
movapd %xmm3,%xmm5
movapd %xmm2,%xmm3
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1282 <hsv_to_rgb+0x162>
jmp    12a7 <hsv_to_rgb+0x187>
xorpd  %xmm3,%xmm3
xorpd  %xmm5,%xmm5
xorpd  %xmm0,%xmm0
movsd  %xmm5,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
mulsd  0xd6a(%rip),%xmm0
call   1040 <floor@plt>
movsd  0x10(%rsp),%xmm5
movsd  0x8(%rsp),%xmm3
mov    %eax,(%r14)
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
ucomisd %xmm5,%xmm0
mov    $0x0,%eax
ja     12dc <hsv_to_rgb+0x1bc>
mulsd  0xd3d(%rip),%xmm5
movapd %xmm5,%xmm0
movsd  %xmm3,0x8(%rsp)
call   1040 <floor@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm3
mov    %eax,0x4(%r14)
ucomisd %xmm3,%xmm0
ja     12fa <hsv_to_rgb+0x1da>
mulsd  0xd12(%rip),%xmm3
movapd %xmm3,%xmm0
call   1040 <floor@plt>
mov    %rax,%rbx
mov    %ebx,0x8(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @hsv_to_rgb(i32* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = tail call i64 @fabs(double %2)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = fcmp ult double %1, 3.600000e+02
br i1 %8, label %19, label %15
9: ; preds = %4
%10 = fmul double %3, 2.559990e+02
%11 = tail call i64 @floor(double %10)
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %12, i32* %13
%14 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %12, i32* %14
store i32 %12, i32* %0
br label %70
15: ; preds = %7, %15
%16 = phi double [ %17, %15 ], [ %1, %7 ]
%17 = fadd double %16, -3.600000e+02
%18 = fcmp ult double %17, 3.600000e+02
br i1 %18, label %19, label %15
19: ; preds = %15, %7
%20 = phi double [ %1, %7 ], [ %17, %15 ]
%21 = fdiv double %20, 6.000000e+01
%22 = fptosi double %21 to i32
%23 = sitofp i32 %22 to double
%24 = fsub double %21, %23
%25 = fsub double 1.000000e+00, %2
%26 = fmul double %25, %3
%27 = fneg double %2
%28 = tail call double @llvm.fmuladd.f64(double %27, double %24, double 1.000000e+00)
%29 = fmul double %28, %3
%30 = fsub double 1.000000e+00, %24
%31 = tail call double @llvm.fmuladd.f64(double %27, double %30, double 1.000000e+00)
%32 = fmul double %31, %3
switch i32 %22, label %43 [
i32 0, label %38
i32 1, label %33
i32 2, label %34
i32 3, label %35
i32 4, label %36
i32 5, label %37
]
33: ; preds = %19
br label %38
34: ; preds = %19
br label %38
35: ; preds = %19
br label %38
36: ; preds = %19
br label %38
37: ; preds = %19
br label %38
38: ; preds = %19, %37, %36, %35, %34, %33
%39 = phi double [ %3, %37 ], [ %32, %36 ], [ %26, %35 ], [ %26, %34 ], [ %29, %33 ], [ %3, %19 ]
%40 = phi double [ %26, %37 ], [ %26, %36 ], [ %29, %35 ], [ %3, %34 ], [ %3, %33 ], [ %32, %19 ]
%41 = phi double [ %29, %37 ], [ %3, %36 ], [ %3, %35 ], [ %32, %34 ], [ %26, %33 ], [ %26, %19 ]
%42 = fcmp olt double %39, 0.000000e+00
br i1 %42, label %50, label %43
43: ; preds = %19, %38
%44 = phi double [ %41, %38 ], [ 0.000000e+00, %19 ]
%45 = phi double [ %40, %38 ], [ 0.000000e+00, %19 ]
%46 = phi double [ %39, %38 ], [ 0.000000e+00, %19 ]
%47 = fmul double %46, 2.559990e+02
%48 = tail call i64 @floor(double %47)
%49 = trunc i64 %48 to i32
br label %50
50: ; preds = %38, %43
%51 = phi double [ %44, %43 ], [ %41, %38 ]
%52 = phi double [ %45, %43 ], [ %40, %38 ]
%53 = phi i32 [ %49, %43 ], [ 0, %38 ]
store i32 %53, i32* %0
%54 = fcmp olt double %52, 0.000000e+00
br i1 %54, label %59, label %55
55: ; preds = %50
%56 = fmul double %52, 2.559990e+02
%57 = tail call i64 @floor(double %56)
%58 = trunc i64 %57 to i32
br label %59
59: ; preds = %50, %55
%60 = phi i32 [ %58, %55 ], [ 0, %50 ]
%61 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %60, i32* %61
%62 = fcmp olt double %51, 0.000000e+00
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = fmul double %51, 2.559990e+02
%65 = tail call i64 @floor(double %64)
%66 = trunc i64 %65 to i32
br label %67
67: ; preds = %59, %63
%68 = phi i32 [ %66, %63 ], [ 0, %59 ]
%69 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %68, i32* %69
br label %70
70: ; preds = %67, %9
ret void
}