#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 double GLfloat;

/* Variables and functions */
void colorMap_jet(GLfloat fin, GLfloat *fcol) {
  int i;
  GLfloat xmin, xmax;
  GLfloat four_fin = 4.0 * fin;
  fcol[0] = ((four_fin - 0.5) < (-four_fin + 4.5) ? (four_fin - 0.5)
                                                  : (-four_fin + 4.5));
  fcol[1] = ((four_fin - 0.5) < (-four_fin + 3.5) ? (four_fin - 0.5)
                                                  : (-four_fin + 3.5));
  fcol[2] = ((four_fin + 0.5) < (-four_fin + 2.5) ? (four_fin + 0.5)
                                                  : (-four_fin + 2.5));
  for (i = 0; i < 3; i++) {
    xmin = ((fcol[i]) > (0.0) ? (fcol[i]) : (0.0));
    fcol[i] = ((xmin) < (1.0) ? (xmin) : (1.0));
  }
}


x86 assembly (clang, -O0):
<colorMap_jet>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xefb(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  0xedc(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xeac(%rip),%xmm2
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    117d <colorMap_jet+0x7d>
movsd  -0x30(%rbp),%xmm0
movsd  0xe99(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11aa <colorMap_jet+0xaa>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe5f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm1
movsd  0xe44(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe2c(%rip),%xmm2
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1215 <colorMap_jet+0x115>
movsd  -0x30(%rbp),%xmm0
movsd  0xe01(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1242 <colorMap_jet+0x142>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xddf(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  0xdb0(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd9f(%rip),%xmm2
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12a6 <colorMap_jet+0x1a6>
movsd  0xd71(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12d3 <colorMap_jet+0x1d3>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd56(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    138e <colorMap_jet+0x28e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1323 <colorMap_jet+0x223>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1330 <colorMap_jet+0x230>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1330 <colorMap_jet+0x230>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xce6(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    135c <colorMap_jet+0x25c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    136e <colorMap_jet+0x26e>
movsd  0xcc4(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    136e <colorMap_jet+0x26e>
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12e8 <colorMap_jet+0x1e8>
pop    %rbp
ret

x86 assembly (clang, -O2):
<colorMap_jet>:
mulsd  0xef8(%rip),%xmm0
movsd  0xef8(%rip),%xmm1
subsd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm0
movapd 0xf00(%rip),%xmm2
addpd  %xmm0,%xmm2
movapd %xmm2,%xmm3
minsd  %xmm1,%xmm3
movapd 0xefc(%rip),%xmm1
subpd  %xmm0,%xmm1
minpd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
maxsd  %xmm0,%xmm3
minsd  0xec4(%rip),%xmm3
movsd  %xmm3,(%rdi)
xorpd  %xmm0,%xmm0
maxpd  %xmm0,%xmm2
minpd  0xee0(%rip),%xmm2
movupd %xmm2,0x8(%rdi)
ret

LLVM IR (-O0):
define void @colorMap_jet(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double* %1, double** %4
%9 = load double, double* %3
%10 = fmul double 4.000000e+00, %9
store double %10, double* %8
%11 = load double, double* %8
%12 = fsub double %11, 5.000000e-01
%13 = load double, double* %8
%14 = fneg double %13
%15 = fadd double %14, 4.500000e+00
%16 = fcmp olt double %12, %15
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load double, double* %8
%19 = fsub double %18, 5.000000e-01
br label %24
20: ; preds = %2
%21 = load double, double* %8
%22 = fneg double %21
%23 = fadd double %22, 4.500000e+00
br label %24
24: ; preds = %20, %17
%25 = phi double [ %19, %17 ], [ %23, %20 ]
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 0
store double %25, double* %27
%28 = load double, double* %8
%29 = fsub double %28, 5.000000e-01
%30 = load double, double* %8
%31 = fneg double %30
%32 = fadd double %31, 3.500000e+00
%33 = fcmp olt double %29, %32
br i1 %33, label %34, label %37
34: ; preds = %24
%35 = load double, double* %8
%36 = fsub double %35, 5.000000e-01
br label %41
37: ; preds = %24
%38 = load double, double* %8
%39 = fneg double %38
%40 = fadd double %39, 3.500000e+00
br label %41
41: ; preds = %37, %34
%42 = phi double [ %36, %34 ], [ %40, %37 ]
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
%45 = load double, double* %8
%46 = fadd double %45, 5.000000e-01
%47 = load double, double* %8
%48 = fneg double %47
%49 = fadd double %48, 2.500000e+00
%50 = fcmp olt double %46, %49
br i1 %50, label %51, label %54
51: ; preds = %41
%52 = load double, double* %8
%53 = fadd double %52, 5.000000e-01
br label %58
54: ; preds = %41
%55 = load double, double* %8
%56 = fneg double %55
%57 = fadd double %56, 2.500000e+00
br label %58
58: ; preds = %54, %51
%59 = phi double [ %53, %51 ], [ %57, %54 ]
%60 = load double*, double** %4
%61 = getelementptr inbounds double, double* %60, i64 2
store double %59, double* %61
store i32 0, i32* %5
br label %62
62: ; preds = %92, %58
%63 = load i32, i32* %5
%64 = icmp slt i32 %63, 3
br i1 %64, label %65, label %95
65: ; preds = %62
%66 = load double*, double** %4
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fcmp ogt double %70, 0.000000e+00
br i1 %71, label %72, label %78
72: ; preds = %65
%73 = load double*, double** %4
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
br label %79
78: ; preds = %65
br label %79
79: ; preds = %78, %72
%80 = phi double [ %77, %72 ], [ 0.000000e+00, %78 ]
store double %80, double* %6
%81 = load double, double* %6
%82 = fcmp olt double %81, 1.000000e+00
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = load double, double* %6
br label %86
85: ; preds = %79
br label %86
86: ; preds = %85, %83
%87 = phi double [ %84, %83 ], [ 1.000000e+00, %85 ]
%88 = load double*, double** %4
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
store double %87, double* %91
br label %92
92: ; preds = %86
%93 = load i32, i32* %5
%94 = add nsw i32 %93, 1
store i32 %94, i32* %5
br label %62
95: ; preds = %62
ret void
}

LLVM IR (-O2):
define void @colorMap_jet(double %0, double* nocapture %1) {
%3 = fmul double %0, 4.000000e+00
%4 = fsub double 4.500000e+00, %3
%5 = insertelement <2 x double> poison, double %3, i64 0
%6 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> zeroinitializer
%7 = fadd <2 x double> %6, <double -5.000000e-01, double 5.000000e-01>
%8 = extractelement <2 x double> %7, i64 0
%9 = fcmp olt double %8, %4
%10 = select i1 %9, double %8, double %4
%11 = getelementptr inbounds double, double* %1, i64 1
%12 = fsub <2 x double> <double 3.500000e+00, double 2.500000e+00>, %6
%13 = fcmp olt <2 x double> %7, %12
%14 = select <2 x i1> %13, <2 x double> %7, <2 x double> %12
%15 = fcmp ogt double %10, 0.000000e+00
%16 = select i1 %15, double %10, double 0.000000e+00
%17 = fcmp olt double %16, 1.000000e+00
%18 = select i1 %17, double %16, double 1.000000e+00
store double %18, double* %1
%19 = fcmp ogt <2 x double> %14, zeroinitializer
%20 = select <2 x i1> %19, <2 x double> %14, <2 x double> zeroinitializer
%21 = fcmp olt <2 x double> %20, <double 1.000000e+00, double 1.000000e+00>
%22 = select <2 x i1> %21, <2 x double> %20, <2 x double> <double 1.000000e+00, double 1.000000e+00>
%23 = bitcast double* %11 to <2 x double>*
store <2 x double> %22, <2 x double>* %23
ret void
}