#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 */
scalar_t__ ffloor(float);
void colormap(float n, int *color, float *fraction) {
  float scaled;
  if (n == 1.0) {
    scaled = 27 - 1;
  } else {
    scaled = ((n + 1) / 2.0) * 27;
  }
  *color = (int)ffloor(scaled);
  *fraction = scaled - *color;
}


x86 assembly (clang, -O0):
<colormap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeca(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1158 <colormap+0x48>
jp     1158 <colormap+0x48>
movss  0xece(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    118a <colormap+0x7a>
movss  0xeb8(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe8b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <ffloor@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2ssl (%rax),%xmm1
subss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colormap>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
ucomiss 0xee3(%rip),%xmm0
jne    112f <colormap+0x1f>
jp     112f <colormap+0x1f>
movss  0xed3(%rip),%xmm0
jmp    114f <colormap+0x3f>
addss  0xecd(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xec5(%rip),%xmm0
mulsd  0xec5(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <ffloor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    %eax,(%rbx)
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @colormap(float %0, i32* %1, float* %2) {
%4 = alloca float
%5 = alloca i32*
%6 = alloca float*
%7 = alloca float
store float %0, float* %4
store i32* %1, i32** %5
store float* %2, float** %6
%8 = load float, float* %4
%9 = fpext float %8 to double
%10 = fcmp oeq double %9, 1.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %3
store float 2.600000e+01, float* %7
br label %19
12: ; preds = %3
%13 = load float, float* %4
%14 = fadd float %13, 1.000000e+00
%15 = fpext float %14 to double
%16 = fdiv double %15, 2.000000e+00
%17 = fmul double %16, 2.700000e+01
%18 = fptrunc double %17 to float
store float %18, float* %7
br label %19
19: ; preds = %12, %11
%20 = load float, float* %7
%21 = call i64 @ffloor(float %20)
%22 = trunc i64 %21 to i32
%23 = load i32*, i32** %5
store i32 %22, i32* %23
%24 = load float, float* %7
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to float
%28 = fsub float %24, %27
%29 = load float*, float** %6
store float %28, float* %29
ret void
}

LLVM IR (-O2):
define void @colormap(float %0, i32* nocapture writeonly %1, float* nocapture writeonly %2) {
%4 = fcmp oeq float %0, 1.000000e+00
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = fadd float %0, 1.000000e+00
%7 = fpext float %6 to double
%8 = fmul double %7, 5.000000e-01
%9 = fmul double %8, 2.700000e+01
%10 = fptrunc double %9 to float
br label %11
11: ; preds = %3, %5
%12 = phi float [ %10, %5 ], [ 2.600000e+01, %3 ]
%13 = tail call i64 @ffloor(float %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %1
%15 = sitofp i32 %14 to float
%16 = fsub float %12, %15
store float %16, float* %2
ret void
}