#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 saturate(double);
double sin(double);
void HSItoRGB(double H, double S, double I, int *r, int *g, int *b) {
  double T, Rv, Gv, Bv;
  T = H;
  Rv = 1 + S * sin(T - 2 * 3.1415 / 3);
  Gv = 1 + S * sin(T);
  Bv = 1 + S * sin(T + 2 * 3.1415 / 3);
  T = 255.999 * I / 2;
  *r = saturate(Rv * T);
  *g = saturate(Gv * T);
  *b = saturate(Bv * T);
}


x86 assembly (clang, -O0):
<HSItoRGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xeb4(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe8f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe4b(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe0c(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <saturate@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <saturate@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <saturate@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HSItoRGB>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm1
movsd  %xmm0,0x18(%rsp)
movsd  0xeb0(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xea1(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe82(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  0xe76(%rip),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe65(%rip),%xmm1
addsd  0xe4d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe57(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <saturate@plt>
mov    %eax,(%rbx)
movsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1040 <saturate@plt>
mov    %eax,(%r15)
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <saturate@plt>
mov    %eax,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @HSItoRGB(double %0, double %1, double %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%17 = load double, double* %7
store double %17, double* %13
%18 = load double, double* %8
%19 = load double, double* %13
%20 = fsub double %19, 0x4000C131D5ACB6F5
%21 = call double @sin(double %20)
%22 = call double @llvm.fmuladd.f64(double %18, double %21, double 1.000000e+00)
store double %22, double* %14
%23 = load double, double* %8
%24 = load double, double* %13
%25 = call double @sin(double %24)
%26 = call double @llvm.fmuladd.f64(double %23, double %25, double 1.000000e+00)
store double %26, double* %15
%27 = load double, double* %8
%28 = load double, double* %13
%29 = fadd double %28, 0x4000C131D5ACB6F5
%30 = call double @sin(double %29)
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double 1.000000e+00)
store double %31, double* %16
%32 = load double, double* %9
%33 = fmul double 2.559990e+02, %32
%34 = fdiv double %33, 2.000000e+00
store double %34, double* %13
%35 = load double, double* %14
%36 = load double, double* %13
%37 = fmul double %35, %36
%38 = call i32 @saturate(double %37)
%39 = load i32*, i32** %10
store i32 %38, i32* %39
%40 = load double, double* %15
%41 = load double, double* %13
%42 = fmul double %40, %41
%43 = call i32 @saturate(double %42)
%44 = load i32*, i32** %11
store i32 %43, i32* %44
%45 = load double, double* %16
%46 = load double, double* %13
%47 = fmul double %45, %46
%48 = call i32 @saturate(double %47)
%49 = load i32*, i32** %12
store i32 %48, i32* %49
ret void
}

LLVM IR (-O2):
define void @HSItoRGB(double %0, double %1, double %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = fadd double %0, 0xC000C131D5ACB6F5
%8 = tail call double @sin(double %7)
%9 = tail call double @llvm.fmuladd.f64(double %1, double %8, double 1.000000e+00)
%10 = tail call double @sin(double %0)
%11 = tail call double @llvm.fmuladd.f64(double %1, double %10, double 1.000000e+00)
%12 = fadd double %0, 0x4000C131D5ACB6F5
%13 = tail call double @sin(double %12)
%14 = tail call double @llvm.fmuladd.f64(double %1, double %13, double 1.000000e+00)
%15 = fmul double %2, 2.559990e+02
%16 = fmul double %15, 5.000000e-01
%17 = fmul double %16, %9
%18 = tail call i32 @saturate(double %17)
store i32 %18, i32* %3
%19 = fmul double %16, %11
%20 = tail call i32 @saturate(double %19)
store i32 %20, i32* %4
%21 = fmul double %16, %14
%22 = tail call i32 @saturate(double %21)
store i32 %22, i32* %5
ret void
}