#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 */
typedef int /*<<< orphan*/ u_char;

/* Variables and functions */
int /*<<< orphan*/ hsb2rgb(double, double, double, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
void hsbramp(double h1, double s1, double b1, double h2, double s2, double b2,
             int count, u_char *red, u_char *green, u_char *blue) {
  double dh;
  double ds;
  double db;
  dh = (h2 - h1) / count;
  ds = (s2 - s1) / count;
  db = (b2 - b1) / count;
  while (count--) {
    hsb2rgb(h1, s1, b1, red++, green++, blue++);
    h1 += dh;
    s1 += ds;
    b1 += db;
  }
}


x86 assembly (clang, -O0):
<hsbramp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %edi,-0x34(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
mov    %rcx,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x34(%rbp)
cmp    $0x0,%eax
je     121a <hsbramp+0x10a>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x40(%rbp)
mov    %eax,%edi
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
mov    %eax,%esi
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x50(%rbp)
mov    %eax,%edx
call   1030 <hsb2rgb@plt>
movsd  -0x58(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118d <hsbramp+0x7d>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsbramp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
test   %edi,%edi
je     11b0 <hsbramp+0xa0>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
movapd %xmm0,%xmm6
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
unpcklpd %xmm4,%xmm3
unpcklpd %xmm1,%xmm6
subpd  %xmm6,%xmm3
subsd  %xmm2,%xmm5
divsd  %xmm0,%xmm5
movsd  %xmm5,0x8(%rsp)
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm3
movapd %xmm3,0x10(%rsp)
movapd %xmm6,0x20(%rsp)
movsd  %xmm2,(%rsp)
movapd %xmm6,%xmm1
unpckhpd %xmm6,%xmm1
movapd %xmm6,%xmm0
movsd  (%rsp),%xmm2
mov    %ebx,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <hsb2rgb@plt>
movapd 0x20(%rsp),%xmm6
movsd  (%rsp),%xmm2
add    $0x4,%r14d
add    $0x4,%r15d
add    $0x4,%ebx
addpd  0x10(%rsp),%xmm6
addsd  0x8(%rsp),%xmm2
add    $0xffffffff,%ebp
jne    1160 <hsbramp+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hsbramp(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32* %7, i32* %8, i32* %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store i32 %6, i32* %17
store i32* %7, i32** %18
store i32* %8, i32** %19
store i32* %9, i32** %20
%24 = load double, double* %14
%25 = load double, double* %11
%26 = fsub double %24, %25
%27 = load i32, i32* %17
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
store double %29, double* %21
%30 = load double, double* %15
%31 = load double, double* %12
%32 = fsub double %30, %31
%33 = load i32, i32* %17
%34 = sitofp i32 %33 to double
%35 = fdiv double %32, %34
store double %35, double* %22
%36 = load double, double* %16
%37 = load double, double* %13
%38 = fsub double %36, %37
%39 = load i32, i32* %17
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
store double %41, double* %23
br label %42
42: ; preds = %46, %10
%43 = load i32, i32* %17
%44 = add nsw i32 %43, -1
store i32 %44, i32* %17
%45 = icmp ne i32 %43, 0
br i1 %45, label %46, label %69
46: ; preds = %42
%47 = load double, double* %11
%48 = load double, double* %12
%49 = load double, double* %13
%50 = load i32*, i32** %18
%51 = getelementptr inbounds i32, i32* %50, i32 1
store i32* %51, i32** %18
%52 = ptrtoint i32* %50 to i32
%53 = load i32*, i32** %19
%54 = getelementptr inbounds i32, i32* %53, i32 1
store i32* %54, i32** %19
%55 = ptrtoint i32* %53 to i32
%56 = load i32*, i32** %20
%57 = getelementptr inbounds i32, i32* %56, i32 1
store i32* %57, i32** %20
%58 = ptrtoint i32* %56 to i32
%59 = call i32 @hsb2rgb(double %47, double %48, double %49, i32 %52, i32 %55, i32 %58)
%60 = load double, double* %21
%61 = load double, double* %11
%62 = fadd double %61, %60
store double %62, double* %11
%63 = load double, double* %22
%64 = load double, double* %12
%65 = fadd double %64, %63
store double %65, double* %12
%66 = load double, double* %23
%67 = load double, double* %13
%68 = fadd double %67, %66
store double %68, double* %13
br label %42
69: ; preds = %42
ret void
}

LLVM IR (-O2):
define void @hsbramp(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32* %7, i32* %8, i32* %9) {
%11 = sitofp i32 %6 to double
%12 = insertelement <2 x double> poison, double %3, i64 0
%13 = insertelement <2 x double> %12, double %4, i64 1
%14 = insertelement <2 x double> poison, double %0, i64 0
%15 = insertelement <2 x double> %14, double %1, i64 1
%16 = fsub <2 x double> %13, %15
%17 = insertelement <2 x double> poison, double %11, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = fdiv <2 x double> %16, %18
%20 = fsub double %5, %2
%21 = fdiv double %20, %11
%22 = icmp eq i32 %6, 0
br i1 %22, label %46, label %23
23: ; preds = %10, %23
%24 = phi double [ %44, %23 ], [ %2, %10 ]
%25 = phi i32* [ %37, %23 ], [ %9, %10 ]
%26 = phi i32* [ %34, %23 ], [ %8, %10 ]
%27 = phi i32* [ %31, %23 ], [ %7, %10 ]
%28 = phi i32 [ %30, %23 ], [ %6, %10 ]
%29 = phi <2 x double> [ %43, %23 ], [ %15, %10 ]
%30 = add nsw i32 %28, -1
%31 = getelementptr inbounds i32, i32* %27, i64 1
%32 = ptrtoint i32* %27 to i64
%33 = trunc i64 %32 to i32
%34 = getelementptr inbounds i32, i32* %26, i64 1
%35 = ptrtoint i32* %26 to i64
%36 = trunc i64 %35 to i32
%37 = getelementptr inbounds i32, i32* %25, i64 1
%38 = ptrtoint i32* %25 to i64
%39 = trunc i64 %38 to i32
%40 = extractelement <2 x double> %29, i64 0
%41 = extractelement <2 x double> %29, i64 1
%42 = tail call i32 @hsb2rgb(double %40, double %41, double %24, i32 %33, i32 %36, i32 %39)
%43 = fadd <2 x double> %19, %29
%44 = fadd double %21, %24
%45 = icmp eq i32 %30, 0
br i1 %45, label %46, label %23
46: ; preds = %23, %10
ret void
}