#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ _set_rgba_from_hsv(int /*<<< orphan*/ *, float, float,
                                      float);
void fosphor_gl_cmap_waterfall(uint32_t *rgba, int N) {
  int i;
  for (i = 0; i < N; i++) {
    float p = (1.0f * i) / (N - 1);
    _set_rgba_from_hsv(&rgba[i], 0.75f - (p * 0.75f), 1.0f,
                       ((p * 0.95f) + 0.05f));
  }
}


x86 assembly (clang, -O0):
<fosphor_gl_cmap_waterfall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <fosphor_gl_cmap_waterfall+0xaf>
cvtsi2ssl -0x10(%rbp),%xmm1
movss  0xec1(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe8d(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm2
movss  0xe70(%rip),%xmm1
mulss  %xmm1,%xmm2
movss  0xe68(%rip),%xmm1
addss  %xmm1,%xmm2
movss  0xe54(%rip),%xmm1
call   1030 <_set_rgba_from_hsv@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <fosphor_gl_cmap_waterfall+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fosphor_gl_cmap_waterfall>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    118d <fosphor_gl_cmap_waterfall+0x7d>
mov    %rdi,%r15
lea    -0x1(%rsi),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %esi,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
divss  0xc(%rsp),%xmm2
movaps %xmm2,%xmm1
movss  0xea8(%rip),%xmm0
mulss  %xmm0,%xmm1
subss  %xmm1,%xmm0
mulss  0xe9c(%rip),%xmm2
addss  0xe98(%rip),%xmm2
mov    %r15,%rdi
movss  0xe91(%rip),%xmm1
call   1030 <_set_rgba_from_hsv@plt>
add    $0x1,%rbx
add    $0x4,%r15
cmp    %rbx,%r14
jne    1140 <fosphor_gl_cmap_waterfall+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @fosphor_gl_cmap_waterfall(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to float
%14 = fmul float 1.000000e+00, %13
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = sitofp i32 %16 to float
%18 = fdiv float %14, %17
store float %18, float* %6
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load float, float* %6
%24 = fneg float %23
%25 = call float @llvm.fmuladd.f32(float %24, float 7.500000e-01, float 7.500000e-01)
%26 = load float, float* %6
%27 = call float @llvm.fmuladd.f32(float %26, float 0x3FEE666660000000, float 0x3FA99999A0000000)
%28 = call i32 @_set_rgba_from_hsv(i32* %22, float %25, float 1.000000e+00, float %27)
br label %29
29: ; preds = %11
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %7
32: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @fosphor_gl_cmap_waterfall(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = sitofp i32 %5 to float
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %18, %8 ]
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to float
%12 = fdiv float %11, %6
%13 = getelementptr inbounds i32, i32* %0, i64 %9
%14 = fneg float %12
%15 = tail call float @llvm.fmuladd.f32(float %14, float 7.500000e-01, float 7.500000e-01)
%16 = tail call float @llvm.fmuladd.f32(float %12, float 0x3FEE666660000000, float 0x3FA99999A0000000)
%17 = tail call i32 @_set_rgba_from_hsv(i32* %13, float %15, float 1.000000e+00, float %16)
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %8, %2
ret void
}