#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 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  -0x8(%rbp),%xmm1
movss  0xea2(%rip),%xmm0
mulss  0x2ed2(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    11eb <genColor+0xbb>
movss  -0x8(%rbp),%xmm0
divss  0x2ebc(%rip),%xmm0
movss  0xe8c(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x10(%rbp)
movss  0xe66(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xe4d(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe49(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
movss  -0xc(%rbp),%xmm0
movss  0xe40(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
xor    %esi,%esi
call   1050 <genRGB@plt>
mov    %eax,-0x4(%rbp)
jmp    131a <genColor+0x1ea>
movss  -0x8(%rbp),%xmm1
movss  0xe08(%rip),%xmm0
mulss  0x2e3c(%rip),%xmm0
ucomiss %xmm1,%xmm0
jb     1266 <genColor+0x136>
movss  -0x8(%rbp),%xmm0
divss  0x2e26(%rip),%xmm0
movss  0xdf2(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x14(%rbp)
movss  0xdcc(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xdb3(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
xor    %esi,%esi
mov    %esi,%edi
call   1050 <genRGB@plt>
mov    %eax,-0x4(%rbp)
jmp    131a <genColor+0x1ea>
movss  0xd96(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd8f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a0 <genColor+0x170>
movss  0xd6d(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xd53(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xd57(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <log@plt>
movss  %xmm0,-0x18(%rbp)
movss  0xd31(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  0xd18(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
movss  0xd14(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  0xd03(%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 global float 5.000000e-01
@genColor.k2 = internal global 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 = load float, float* @genColor.k1
%10 = fmul float 2.550000e+02, %9
%11 = fcmp olt float %8, %10
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = load float, float* %4
%14 = load float, float* @genColor.k1
%15 = fdiv float %13, %14
%16 = fadd float %15, 1.000000e+00
%17 = call float @log(float %16)
%18 = call float @log(float 2.550000e+02)
%19 = fdiv float %17, %18
%20 = fmul float %19, 2.550000e+02
%21 = fmul float %20, 2.000000e+00
%22 = fptosi float %21 to i32
%23 = load float, float* %5
%24 = fdiv float %23, 5.000000e+00
%25 = fptosi float %24 to i32
%26 = call i32 @genRGB(i32 %22, i32 0, i32 %25)
store i32 %26, i32* %3
br label %65
27: ; preds = %2
%28 = load float, float* %4
%29 = load float, float* @genColor.k2
%30 = fmul float 2.550000e+02, %29
%31 = fcmp ole float %28, %30
br i1 %31, label %32, label %43
32: ; preds = %27
%33 = load float, float* %4
%34 = load float, float* @genColor.k2
%35 = fdiv float %33, %34
%36 = fadd float %35, 1.000000e+00
%37 = call float @log(float %36)
%38 = call float @log(float 2.550000e+02)
%39 = fdiv float %37, %38
%40 = fmul float %39, 2.550000e+02
%41 = fptosi float %40 to i32
%42 = call i32 @genRGB(i32 0, i32 0, i32 %41)
store i32 %42, i32* %3
br label %65
43: ; preds = %27
%44 = load float, float* %5
%45 = fadd float %44, 1.000000e+03
store float %45, float* %5
%46 = load float, float* %5
%47 = fpext float %46 to double
%48 = fcmp ogt double %47, 2.000000e+00
br i1 %48, label %49, label %50
49: ; preds = %43
store float 2.000000e+00, float* %5
br label %50
50: ; preds = %49, %43
%51 = load float, float* %4
%52 = fsub float %51, 2.550000e+02
%53 = fadd float %52, 1.000000e+00
%54 = call float @log(float %53)
%55 = call float @log(float 2.550000e+02)
%56 = fdiv float %54, %55
%57 = fmul float %56, 2.550000e+02
%58 = fptosi float %57 to i32
%59 = load float, float* %5
%60 = fmul float %59, 2.050000e+02
%61 = fdiv float %60, 2.000000e+00
%62 = fptosi float %61 to i32
%63 = add nsw i32 50, %62
%64 = call i32 @genRGB(i32 0, i32 %58, i32 %63)
store i32 %64, i32* %3
br label %65
65: ; preds = %50, %32, %12
%66 = load i32, i32* %3
ret i32 %66
}

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
}