#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 */
float abs(float);
int genRGB(int, int, int);
float log(float);
int genColor(float color, float dif) {
  static float const k1 = 0.5, k2 = 1.9;
  color = abs(color);
  if (color < 255.f * k1) {
    return genRGB((int)(log(color / k1 + 1.f) / log(255.f) * 255.f * 2.f), 0,
                  (int)(dif / 5.f));
  } else if (color <= 255.f * k2) {
    return genRGB(0, 0, (int)(log(color / k2 + 1.f) / log(255.f) * 255.f));
  } else {
    dif += 1000.f;
    if (dif > 2.0)
      dif = 2.0;
    return genRGB(0, (int)(log(color - 255.f + 1.f) / log(255.f) * 255.f),
                  50 + (int)(dif * 205.f / 2.f));
  }
}


x86 assembly (clang, -O0):
<genColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <abs@plt>
movss  %xmm0,-0x8(%rbp)
movss  0xea7(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11e3 <genColor+0xb3>
movss  -0x8(%rbp),%xmm0
movss  0xeb4(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe9c(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x10(%rbp)
movss  0xe82(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xe69(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe55(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
movss  -0xc(%rbp),%xmm0
movss  0xe54(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
xor    %esi,%esi
call   1050 <genRGB@plt>
mov    %eax,-0x4(%rbp)
jmp    130a <genColor+0x1da>
movss  0xe19(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1256 <genColor+0x126>
movss  -0x8(%rbp),%xmm0
movss  0xe1a(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe0a(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x14(%rbp)
movss  0xdf0(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xdd7(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
xor    %esi,%esi
mov    %esi,%edi
call   1050 <genRGB@plt>
mov    %eax,-0x4(%rbp)
jmp    130a <genColor+0x1da>
movss  0xdaa(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdaf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1290 <genColor+0x160>
movss  0xd81(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xd77(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xd6f(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x18(%rbp)
movss  0xd55(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xd3c(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
movss  0xd28(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  0xd17(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
add    $0x32,%edx
xor    %edi,%edi
call   1050 <genRGB@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genColor>:
push   %rax
movss  %xmm1,0x4(%rsp)
call   1030 <abs@plt>
movss  0xebc(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1189 <genColor+0x59>
addss  %xmm0,%xmm0
addss  0xeb7(%rip),%xmm0
call   1040 <log@plt>
divss  0xeae(%rip),%xmm0
mulss  0xeaa(%rip),%xmm0
addss  %xmm0,%xmm0
cvttss2si %xmm0,%edi
movss  0x4(%rsp),%xmm0
divss  0xeac(%rip),%xmm0
cvttss2si %xmm0,%edx
jmp    122f <genColor+0xff>
movss  0x4(%rsp),%xmm2
movss  0xe6d(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1204 <genColor+0xd4>
addss  0xe74(%rip),%xmm2
movss  0xe70(%rip),%xmm1
minss  %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
addss  0xe62(%rip),%xmm0
addss  0xe46(%rip),%xmm0
call   1040 <log@plt>
divss  0xe3d(%rip),%xmm0
mulss  0xe39(%rip),%xmm0
cvttss2si %xmm0,%esi
movss  0x4(%rsp),%xmm0
mulss  0xe37(%rip),%xmm0
mulss  0xe33(%rip),%xmm0
cvttss2si %xmm0,%edx
add    $0x32,%edx
xor    %edi,%edi
pop    %rax
jmp    1050 <genRGB@plt>
divss  0xdfc(%rip),%xmm0
addss  0xdf8(%rip),%xmm0
call   1040 <log@plt>
divss  0xdef(%rip),%xmm0
mulss  0xdeb(%rip),%xmm0
cvttss2si %xmm0,%edx
xor    %edi,%edi
xor    %esi,%esi
pop    %rax
jmp    1050 <genRGB@plt>

LLVM IR (-O0):
@genColor.k1 = internal constant float 5.000000e-01
@genColor.k2 = internal constant float 0x3FFE666660000000
define i32 @genColor(float %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %4
%7 = call float @abs(float %6)
store float %7, float* %4
%8 = load float, float* %4
%9 = fcmp olt float %8, 1.275000e+02
br i1 %9, label %10, label %24
10: ; preds = %2
%11 = load float, float* %4
%12 = fdiv float %11, 5.000000e-01
%13 = fadd float %12, 1.000000e+00
%14 = call float @log(float %13)
%15 = call float @log(float 2.550000e+02)
%16 = fdiv float %14, %15
%17 = fmul float %16, 2.550000e+02
%18 = fmul float %17, 2.000000e+00
%19 = fptosi float %18 to i32
%20 = load float, float* %5
%21 = fdiv float %20, 5.000000e+00
%22 = fptosi float %21 to i32
%23 = call i32 @genRGB(i32 %19, i32 0, i32 %22)
store i32 %23, i32* %3
br label %59
24: ; preds = %2
%25 = load float, float* %4
%26 = fcmp ole float %25, 4.845000e+02
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load float, float* %4
%29 = fdiv float %28, 0x3FFE666660000000
%30 = fadd float %29, 1.000000e+00
%31 = call float @log(float %30)
%32 = call float @log(float 2.550000e+02)
%33 = fdiv float %31, %32
%34 = fmul float %33, 2.550000e+02
%35 = fptosi float %34 to i32
%36 = call i32 @genRGB(i32 0, i32 0, i32 %35)
store i32 %36, i32* %3
br label %59
37: ; preds = %24
%38 = load float, float* %5
%39 = fadd float %38, 1.000000e+03
store float %39, float* %5
%40 = load float, float* %5
%41 = fpext float %40 to double
%42 = fcmp ogt double %41, 2.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %37
store float 2.000000e+00, float* %5
br label %44
44: ; preds = %43, %37
%45 = load float, float* %4
%46 = fsub float %45, 2.550000e+02
%47 = fadd float %46, 1.000000e+00
%48 = call float @log(float %47)
%49 = call float @log(float 2.550000e+02)
%50 = fdiv float %48, %49
%51 = fmul float %50, 2.550000e+02
%52 = fptosi float %51 to i32
%53 = load float, float* %5
%54 = fmul float %53, 2.050000e+02
%55 = fdiv float %54, 2.000000e+00
%56 = fptosi float %55 to i32
%57 = add nsw i32 50, %56
%58 = call i32 @genRGB(i32 0, i32 %52, i32 %57)
store i32 %58, i32* %3
br label %59
59: ; preds = %44, %27, %10
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
define i32 @genColor(float %0, float %1) {
%3 = tail call float @abs(float %0)
%4 = fcmp olt float %3, 1.275000e+02
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = fmul float %3, 2.000000e+00
%7 = fadd float %6, 1.000000e+00
%8 = tail call float @log(float %7)
%9 = fdiv float %8, 0x40162A4100000000
%10 = fmul float %9, 2.550000e+02
%11 = fmul float %10, 2.000000e+00
%12 = fptosi float %11 to i32
%13 = fdiv float %1, 5.000000e+00
%14 = fptosi float %13 to i32
%15 = tail call i32 @genRGB(i32 %12, i32 0, i32 %14)
br label %41
16: ; preds = %2
%17 = fcmp ugt float %3, 4.845000e+02
br i1 %17, label %26, label %18
18: ; preds = %16
%19 = fdiv float %3, 0x3FFE666660000000
%20 = fadd float %19, 1.000000e+00
%21 = tail call float @log(float %20)
%22 = fdiv float %21, 0x40162A4100000000
%23 = fmul float %22, 2.550000e+02
%24 = fptosi float %23 to i32
%25 = tail call i32 @genRGB(i32 0, i32 0, i32 %24)
br label %41
26: ; preds = %16
%27 = fadd float %1, 1.000000e+03
%28 = fcmp ogt float %27, 2.000000e+00
%29 = select i1 %28, float 2.000000e+00, float %27
%30 = fadd float %3, -2.550000e+02
%31 = fadd float %30, 1.000000e+00
%32 = tail call float @log(float %31)
%33 = fdiv float %32, 0x40162A4100000000
%34 = fmul float %33, 2.550000e+02
%35 = fptosi float %34 to i32
%36 = fmul float %29, 2.050000e+02
%37 = fmul float %36, 5.000000e-01
%38 = fptosi float %37 to i32
%39 = add nsw i32 %38, 50
%40 = tail call i32 @genRGB(i32 0, i32 %35, i32 %39)
br label %41
41: ; preds = %26, %18, %5
%42 = phi i32 [ %15, %5 ], [ %25, %18 ], [ %40, %26 ]
ret i32 %42
}