#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 /*<<< orphan*/ hsv(unsigned char *, double, double, double);
int /*<<< orphan*/ isfinite(double);
void rainbow(unsigned char *out, double v) {
  if (v <= 0 || !isfinite(v)) {
    out[0] = 0;
    out[1] = 0;
    out[2] = 0;
  } else {
    hsv(out, v, 0.8, 0.7);
  }
}


x86 assembly (clang, -O0):
<rainbow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1152 <rainbow+0x32>
movsd  -0x10(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%eax
jne    116e <rainbow+0x4e>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
jmp    118c <rainbow+0x6c>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
movsd  0xe81(%rip),%xmm2
call   1040 <hsv@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rainbow>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1164 <rainbow+0x44>
movsd  %xmm0,0x8(%rsp)
call   1030 <isfinite@plt>
movsd  0x8(%rsp),%xmm0
test   %eax,%eax
je     1164 <rainbow+0x44>
movsd  0xeb1(%rip),%xmm1
movsd  0xeb1(%rip),%xmm2
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <hsv@plt>
movw   $0x0,(%rbx)
movb   $0x0,0x2(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @rainbow(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%5 = load double, double* %4
%6 = fcmp ole double %5, 0.000000e+00
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load double, double* %4
%9 = call i32 @isfinite(double %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7, %2
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %15
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 2
store i8 0, i8* %17
br label %22
18: ; preds = %7
%19 = load i8*, i8** %3
%20 = load double, double* %4
%21 = call i32 @hsv(i8* %19, double %20, double 8.000000e-01, double 0x3FE6666666666666)
br label %22
22: ; preds = %18, %11
ret void
}

LLVM IR (-O2):
define void @rainbow(i8* %0, double %1) {
%3 = fcmp ugt double %1, 0.000000e+00
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @isfinite(double %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4, %2
store i8 0, i8* %0
%8 = getelementptr inbounds i8, i8* %0, i64 1
store i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %9
br label %12
10: ; preds = %4
%11 = tail call i32 @hsv(i8* %0, double %1, double 8.000000e-01, double 0x3FE6666666666666)
br label %12
12: ; preds = %10, %7
ret void
}