#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 M_PI;
int itrunc(double);
double sin(double);
void HSItoRGB(double H, double S, double I, int *r, int *g, int *b) {
  double T, Rv, Gv, Bv;
  Rv = 1 + S * sin(H - 2 * M_PI / 3);
  Gv = 1 + S * sin(H);
  Bv = 1 + S * sin(H + 2 * M_PI / 3);
  T = 255.999 * I / 2;
  *r = itrunc(Rv * T);
  *g = itrunc(Gv * T);
  *b = itrunc(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  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe0b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdf2(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <itrunc@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <itrunc@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <itrunc@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   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
addsd  0xe7d(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
addsd  0xe5f(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    (%rbx),%eax
add    %eax,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe22(%rip),%xmm1
addsd  0xe12(%rip),%xmm0
movsd  %xmm0,(%rsp)
mulsd  0xe15(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <itrunc@plt>
mov    %eax,(%r12)
movsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <itrunc@plt>
mov    %eax,(%r15)
movsd  0x8(%rsp),%xmm0
mulsd  (%rsp),%xmm0
call   1040 <itrunc@plt>
mov    %eax,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global i32 0
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* %8
%18 = load double, double* %7
%19 = load i32, i32* @M_PI
%20 = mul nsw i32 2, %19
%21 = sdiv i32 %20, 3
%22 = sitofp i32 %21 to double
%23 = fsub double %18, %22
%24 = call double @sin(double %23)
%25 = call double @llvm.fmuladd.f64(double %17, double %24, double 1.000000e+00)
store double %25, double* %14
%26 = load double, double* %8
%27 = load double, double* %7
%28 = call double @sin(double %27)
%29 = call double @llvm.fmuladd.f64(double %26, double %28, double 1.000000e+00)
store double %29, double* %15
%30 = load double, double* %8
%31 = load double, double* %7
%32 = load i32, i32* @M_PI
%33 = mul nsw i32 2, %32
%34 = sdiv i32 %33, 3
%35 = sitofp i32 %34 to double
%36 = fadd double %31, %35
%37 = call double @sin(double %36)
%38 = call double @llvm.fmuladd.f64(double %30, double %37, double 1.000000e+00)
store double %38, double* %16
%39 = load double, double* %9
%40 = fmul double 2.559990e+02, %39
%41 = fdiv double %40, 2.000000e+00
store double %41, double* %13
%42 = load double, double* %14
%43 = load double, double* %13
%44 = fmul double %42, %43
%45 = call i32 @itrunc(double %44)
%46 = load i32*, i32** %10
store i32 %45, i32* %46
%47 = load double, double* %15
%48 = load double, double* %13
%49 = fmul double %47, %48
%50 = call i32 @itrunc(double %49)
%51 = load i32*, i32** %11
store i32 %50, i32* %51
%52 = load double, double* %16
%53 = load double, double* %13
%54 = fmul double %52, %53
%55 = call i32 @itrunc(double %54)
%56 = load i32*, i32** %12
store i32 %55, i32* %56
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @HSItoRGB(double %0, double %1, double %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = load i32, i32* @M_PI
%8 = shl nsw i32 %7, 1
%9 = sdiv i32 %8, 3
%10 = sitofp i32 %9 to double
%11 = fsub double %0, %10
%12 = tail call double @sin(double %11)
%13 = tail call double @llvm.fmuladd.f64(double %1, double %12, double 1.000000e+00)
%14 = tail call double @sin(double %0)
%15 = tail call double @llvm.fmuladd.f64(double %1, double %14, double 1.000000e+00)
%16 = load i32, i32* @M_PI
%17 = shl nsw i32 %16, 1
%18 = sdiv i32 %17, 3
%19 = sitofp i32 %18 to double
%20 = fadd double %19, %0
%21 = tail call double @sin(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %1, double %21, double 1.000000e+00)
%23 = fmul double %2, 2.559990e+02
%24 = fmul double %23, 5.000000e-01
%25 = fmul double %24, %13
%26 = tail call i32 @itrunc(double %25)
store i32 %26, i32* %3
%27 = fmul double %24, %15
%28 = tail call i32 @itrunc(double %27)
store i32 %28, i32* %4
%29 = fmul double %24, %22
%30 = tail call i32 @itrunc(double %29)
store i32 %30, i32* %5
ret void
}