void RGBtoHLS(red, green, blue, hue, lightness, saturation) double red, green,
    blue;
double *hue, *lightness, *saturation;
{
  double brgbr[5], s1, s2, max, min;
  int imax, i;
  static double base[3] = {0.0, 2.0, 4.0};
  {
    double val = red;
    (val) = (val) > (0.0) ? (val) : (0.0);
    (val) = (val) < (1.0) ? (val) : (1.0);
    brgbr[0 + 1] = val;
  };
  {
    double val = green;
    (val) = (val) > (0.0) ? (val) : (0.0);
    (val) = (val) < (1.0) ? (val) : (1.0);
    brgbr[1 + 1] = val;
  };
  {
    double val = blue;
    (val) = (val) > (0.0) ? (val) : (0.0);
    (val) = (val) < (1.0) ? (val) : (1.0);
    brgbr[2 + 1] = val;
  };
  brgbr[0] = brgbr[3];
  brgbr[4] = brgbr[1];
  max = brgbr[1];
  min = brgbr[1];
  imax = 1;
  for (i = 2; i <= 3; i++) {
    if (brgbr[i] > max) {
      max = brgbr[i];
      imax = i;
    } else if (brgbr[i] < min)
      min = brgbr[i];
  }
  (*lightness) = (brgbr[1] + brgbr[2] + brgbr[3]) / 3.0;
  if (max == min) {
    (*saturation) = 0.0;
    (*hue) = 0.0;
  } else {
    s1 = 1.0 - min / (*lightness);
    s2 = 1.0 - (1.0 - max) / (1.0 - (*lightness));
    (*saturation) = s1 > s2 ? s1 : s2;
    (*saturation) = (*saturation) > (0.0) ? (*saturation) : (0.0);
    (*saturation) = (*saturation) < (1.0) ? (*saturation) : (1.0);
    (*hue) = base[imax - 1] + (brgbr[imax + 1] - brgbr[imax - 1]) / (max - min);
    if ((*hue) < 0.0)
      (*hue) += 6.0;
  }
  (*hue) = (*hue) * 60.0;
}


x86 assembly (clang, -O0):
<RGBtoHLS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    115a <RGBtoHLS+0x5a>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    116a <RGBtoHLS+0x6a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    116a <RGBtoHLS+0x6a>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xe7e(%rip),%xmm0
ucomisd -0x90(%rbp),%xmm0
ff
jbe    11a5 <RGBtoHLS+0xa5>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    11ba <RGBtoHLS+0xba>
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    11ba <RGBtoHLS+0xba>
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    120e <RGBtoHLS+0x10e>
movsd  -0x98(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    121e <RGBtoHLS+0x11e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    121e <RGBtoHLS+0x11e>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xdca(%rip),%xmm0
ucomisd -0x98(%rbp),%xmm0
ff
jbe    1259 <RGBtoHLS+0x159>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    126e <RGBtoHLS+0x16e>
movsd  0xd9f(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    126e <RGBtoHLS+0x16e>
movsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12c2 <RGBtoHLS+0x1c2>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc8(%rbp)
ff
jmp    12d2 <RGBtoHLS+0x1d2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
jmp    12d2 <RGBtoHLS+0x1d2>
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xd16(%rip),%xmm0
ucomisd -0xa0(%rbp),%xmm0
ff
jbe    130d <RGBtoHLS+0x20d>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xd0(%rbp)
ff
jmp    1322 <RGBtoHLS+0x222>
movsd  0xceb(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
jmp    1322 <RGBtoHLS+0x222>
movsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x1,-0x84(%rbp)
movl   $0x2,-0x88(%rbp)
cmpl   $0x3,-0x88(%rbp)
jg     140f <RGBtoHLS+0x30f>
movslq -0x88(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    13c3 <RGBtoHLS+0x2c3>
movslq -0x88(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    13f6 <RGBtoHLS+0x2f6>
movslq -0x88(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm1
movsd  -0x80(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13f1 <RGBtoHLS+0x2f1>
movslq -0x88(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    13f6 <RGBtoHLS+0x2f6>
jmp    13fb <RGBtoHLS+0x2fb>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    137b <RGBtoHLS+0x27b>
movsd  -0x58(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xbe2(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jne    1463 <RGBtoHLS+0x363>
jp     1463 <RGBtoHLS+0x363>
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    160a <RGBtoHLS+0x50a>
movsd  -0x80(%rbp),%xmm1
mov    -0x28(%rbp),%rax
divsd  (%rax),%xmm1
movsd  0xb88(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xb77(%rip),%xmm1
subsd  -0x78(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movsd  0xb66(%rip),%xmm0
subsd  (%rax),%xmm0
divsd  %xmm0,%xmm1
movsd  0xb56(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    14d5 <RGBtoHLS+0x3d5>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
jmp    14e2 <RGBtoHLS+0x3e2>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    151c <RGBtoHLS+0x41c>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
jmp    152c <RGBtoHLS+0x42c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
jmp    152c <RGBtoHLS+0x42c>
movsd  -0xe0(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  0xab8(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    1567 <RGBtoHLS+0x467>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
jmp    157c <RGBtoHLS+0x47c>
movsd  0xa91(%rip),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
jmp    157c <RGBtoHLS+0x47c>
movsd  -0xe8(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x84(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2a91(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x84(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x60(%rbp,%rax,8),%xmm1
mov    -0x84(%rbp),%eax
sub    $0x1,%eax
cltq
subsd  -0x60(%rbp,%rax,8),%xmm1
movsd  -0x78(%rbp),%xmm2
subsd  -0x80(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1605 <RGBtoHLS+0x505>
mov    -0x20(%rbp),%rax
movsd  0xa13(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    160a <RGBtoHLS+0x50a>
mov    -0x20(%rbp),%rax
movsd  0xa02(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGBtoHLS>:
xorpd  %xmm4,%xmm4
maxsd  %xmm4,%xmm0
movsd  0xef0(%rip),%xmm3
minsd  %xmm3,%xmm0
movsd  %xmm0,-0x20(%rsp)
maxsd  %xmm4,%xmm1
minsd  %xmm3,%xmm1
movsd  %xmm1,-0x18(%rsp)
maxsd  %xmm4,%xmm2
minsd  %xmm3,%xmm2
movsd  %xmm2,-0x10(%rsp)
movsd  %xmm2,-0x28(%rsp)
movsd  %xmm0,-0x8(%rsp)
mov    $0x2,%eax
ucomisd %xmm0,%xmm1
movapd %xmm0,%xmm4
movapd %xmm1,%xmm5
jbe    1166 <RGBtoHLS+0x66>
ucomisd %xmm5,%xmm2
jbe    1185 <RGBtoHLS+0x85>
mov    $0x3,%eax
movapd %xmm2,%xmm5
jmp    118f <RGBtoHLS+0x8f>
mov    $0x1,%eax
ucomisd %xmm1,%xmm0
jbe    1177 <RGBtoHLS+0x77>
movapd %xmm1,%xmm4
jmp    117b <RGBtoHLS+0x7b>
movapd %xmm0,%xmm4
movapd %xmm0,%xmm5
ucomisd %xmm5,%xmm2
ja     115b <RGBtoHLS+0x5b>
ucomisd %xmm2,%xmm4
jbe    118f <RGBtoHLS+0x8f>
movapd %xmm2,%xmm4
addsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
divsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%rsi)
ucomisd %xmm4,%xmm5
jne    11b8 <RGBtoHLS+0xb8>
jp     11b8 <RGBtoHLS+0xb8>
movq   $0x0,(%rdx)
xorpd  %xmm0,%xmm0
jmp    1233 <RGBtoHLS+0x133>
movapd %xmm3,%xmm1
subsd  %xmm5,%xmm1
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
movapd %xmm4,%xmm6
unpcklpd %xmm1,%xmm6
unpcklpd %xmm2,%xmm0
divpd  %xmm0,%xmm6
movapd 0xe40(%rip),%xmm0
subpd  %xmm6,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
maxsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
maxsd  %xmm1,%xmm0
minsd  %xmm3,%xmm0
movsd  %xmm0,(%rdx)
lea    -0x1(%rax),%ecx
lea    0xe26(%rip),%rdx
mov    %eax,%eax
movsd  -0x20(%rsp,%rax,8),%xmm0
subsd  -0x28(%rsp,%rcx,8),%xmm0
subsd  %xmm4,%xmm5
divsd  %xmm5,%xmm0
addsd  (%rdx,%rcx,8),%xmm0
ucomisd %xmm0,%xmm1
jbe    1233 <RGBtoHLS+0x133>
addsd  0xddd(%rip),%xmm0
mulsd  0xddd(%rip),%xmm0
movsd  %xmm0,(%rdi)
ret

LLVM IR (-O0):
@RGBtoHLS.base = internal global [3 x double] [double 0.000000e+00, double 2.000000e+00, double 4.000000e+00]
define void @RGBtoHLS(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca [5 x double]
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%23 = load double, double* %7
store double %23, double* %20
%24 = load double, double* %20
%25 = fcmp ogt double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %6
%27 = load double, double* %20
br label %29
28: ; preds = %6
br label %29
29: ; preds = %28, %26
%30 = phi double [ %27, %26 ], [ 0.000000e+00, %28 ]
store double %30, double* %20
%31 = load double, double* %20
%32 = fcmp olt double %31, 1.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load double, double* %20
br label %36
35: ; preds = %29
br label %36
36: ; preds = %35, %33
%37 = phi double [ %34, %33 ], [ 1.000000e+00, %35 ]
store double %37, double* %20
%38 = load double, double* %20
%39 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 1
store double %38, double* %39
%40 = load double, double* %8
store double %40, double* %21
%41 = load double, double* %21
%42 = fcmp ogt double %41, 0.000000e+00
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = load double, double* %21
br label %46
45: ; preds = %36
br label %46
46: ; preds = %45, %43
%47 = phi double [ %44, %43 ], [ 0.000000e+00, %45 ]
store double %47, double* %21
%48 = load double, double* %21
%49 = fcmp olt double %48, 1.000000e+00
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load double, double* %21
br label %53
52: ; preds = %46
br label %53
53: ; preds = %52, %50
%54 = phi double [ %51, %50 ], [ 1.000000e+00, %52 ]
store double %54, double* %21
%55 = load double, double* %21
%56 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 2
store double %55, double* %56
%57 = load double, double* %9
store double %57, double* %22
%58 = load double, double* %22
%59 = fcmp ogt double %58, 0.000000e+00
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = load double, double* %22
br label %63
62: ; preds = %53
br label %63
63: ; preds = %62, %60
%64 = phi double [ %61, %60 ], [ 0.000000e+00, %62 ]
store double %64, double* %22
%65 = load double, double* %22
%66 = fcmp olt double %65, 1.000000e+00
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = load double, double* %22
br label %70
69: ; preds = %63
br label %70
70: ; preds = %69, %67
%71 = phi double [ %68, %67 ], [ 1.000000e+00, %69 ]
store double %71, double* %22
%72 = load double, double* %22
%73 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 3
store double %72, double* %73
%74 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 3
%75 = load double, double* %74
%76 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 0
store double %75, double* %76
%77 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 1
%78 = load double, double* %77
%79 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 4
store double %78, double* %79
%80 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 1
%81 = load double, double* %80
store double %81, double* %16
%82 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 1
%83 = load double, double* %82
store double %83, double* %17
store i32 1, i32* %18
store i32 2, i32* %19
br label %84
84: ; preds = %114, %70
%85 = load i32, i32* %19
%86 = icmp sle i32 %85, 3
br i1 %86, label %87, label %117
87: ; preds = %84
%88 = load i32, i32* %19
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %89
%91 = load double, double* %90
%92 = load double, double* %16
%93 = fcmp ogt double %91, %92
br i1 %93, label %94, label %100
94: ; preds = %87
%95 = load i32, i32* %19
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %96
%98 = load double, double* %97
store double %98, double* %16
%99 = load i32, i32* %19
store i32 %99, i32* %18
br label %113
100: ; preds = %87
%101 = load i32, i32* %19
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %102
%104 = load double, double* %103
%105 = load double, double* %17
%106 = fcmp olt double %104, %105
br i1 %106, label %107, label %112
107: ; preds = %100
%108 = load i32, i32* %19
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %109
%111 = load double, double* %110
store double %111, double* %17
br label %112
112: ; preds = %107, %100
br label %113
113: ; preds = %112, %94
br label %114
114: ; preds = %113
%115 = load i32, i32* %19
%116 = add nsw i32 %115, 1
store i32 %116, i32* %19
br label %84
117: ; preds = %84
%118 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 1
%119 = load double, double* %118
%120 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 2
%121 = load double, double* %120
%122 = fadd double %119, %121
%123 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 3
%124 = load double, double* %123
%125 = fadd double %122, %124
%126 = fdiv double %125, 3.000000e+00
%127 = load double*, double** %11
store double %126, double* %127
%128 = load double, double* %16
%129 = load double, double* %17
%130 = fcmp oeq double %128, %129
br i1 %130, label %131, label %134
131: ; preds = %117
%132 = load double*, double** %12
store double 0.000000e+00, double* %132
%133 = load double*, double** %10
store double 0.000000e+00, double* %133
br label %207
134: ; preds = %117
%135 = load double, double* %17
%136 = load double*, double** %11
%137 = load double, double* %136
%138 = fdiv double %135, %137
%139 = fsub double 1.000000e+00, %138
store double %139, double* %14
%140 = load double, double* %16
%141 = fsub double 1.000000e+00, %140
%142 = load double*, double** %11
%143 = load double, double* %142
%144 = fsub double 1.000000e+00, %143
%145 = fdiv double %141, %144
%146 = fsub double 1.000000e+00, %145
store double %146, double* %15
%147 = load double, double* %14
%148 = load double, double* %15
%149 = fcmp ogt double %147, %148
br i1 %149, label %150, label %152
150: ; preds = %134
%151 = load double, double* %14
br label %154
152: ; preds = %134
%153 = load double, double* %15
br label %154
154: ; preds = %152, %150
%155 = phi double [ %151, %150 ], [ %153, %152 ]
%156 = load double*, double** %12
store double %155, double* %156
%157 = load double*, double** %12
%158 = load double, double* %157
%159 = fcmp ogt double %158, 0.000000e+00
br i1 %159, label %160, label %163
160: ; preds = %154
%161 = load double*, double** %12
%162 = load double, double* %161
br label %164
163: ; preds = %154
br label %164
164: ; preds = %163, %160
%165 = phi double [ %162, %160 ], [ 0.000000e+00, %163 ]
%166 = load double*, double** %12
store double %165, double* %166
%167 = load double*, double** %12
%168 = load double, double* %167
%169 = fcmp olt double %168, 1.000000e+00
br i1 %169, label %170, label %173
170: ; preds = %164
%171 = load double*, double** %12
%172 = load double, double* %171
br label %174
173: ; preds = %164
br label %174
174: ; preds = %173, %170
%175 = phi double [ %172, %170 ], [ 1.000000e+00, %173 ]
%176 = load double*, double** %12
store double %175, double* %176
%177 = load i32, i32* %18
%178 = sub nsw i32 %177, 1
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds [3 x double], [3 x double]* @RGBtoHLS.base, i64 0, i64 %179
%181 = load double, double* %180
%182 = load i32, i32* %18
%183 = add nsw i32 %182, 1
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %184
%186 = load double, double* %185
%187 = load i32, i32* %18
%188 = sub nsw i32 %187, 1
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [5 x double], [5 x double]* %13, i64 0, i64 %189
%191 = load double, double* %190
%192 = fsub double %186, %191
%193 = load double, double* %16
%194 = load double, double* %17
%195 = fsub double %193, %194
%196 = fdiv double %192, %195
%197 = fadd double %181, %196
%198 = load double*, double** %10
store double %197, double* %198
%199 = load double*, double** %10
%200 = load double, double* %199
%201 = fcmp olt double %200, 0.000000e+00
br i1 %201, label %202, label %206
202: ; preds = %174
%203 = load double*, double** %10
%204 = load double, double* %203
%205 = fadd double %204, 6.000000e+00
store double %205, double* %203
br label %206
206: ; preds = %202, %174
br label %207
207: ; preds = %206, %131
%208 = load double*, double** %10
%209 = load double, double* %208
%210 = fmul double %209, 6.000000e+01
%211 = load double*, double** %10
store double %210, double* %211
ret void
}

LLVM IR (-O2):
@RGBtoHLS.base = internal unnamed_addr constant [3 x double] [double 0.000000e+00, double 2.000000e+00, double 4.000000e+00]
define void @RGBtoHLS(double %0, double %1, double %2, double* nocapture %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = alloca [5 x double]
%8 = bitcast [5 x double]* %7 to i8*
%9 = fcmp ogt double %0, 0.000000e+00
%10 = select i1 %9, double %0, double 0.000000e+00
%11 = fcmp olt double %10, 1.000000e+00
%12 = select i1 %11, double %10, double 1.000000e+00
%13 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 1
store double %12, double* %13
%14 = fcmp ogt double %1, 0.000000e+00
%15 = select i1 %14, double %1, double 0.000000e+00
%16 = fcmp olt double %15, 1.000000e+00
%17 = select i1 %16, double %15, double 1.000000e+00
%18 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 2
store double %17, double* %18
%19 = fcmp ogt double %2, 0.000000e+00
%20 = select i1 %19, double %2, double 0.000000e+00
%21 = fcmp olt double %20, 1.000000e+00
%22 = select i1 %21, double %20, double 1.000000e+00
%23 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 3
store double %22, double* %23
%24 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 0
store double %22, double* %24
%25 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 4
store double %12, double* %25
%26 = fcmp ogt double %17, %12
br i1 %26, label %30, label %27
27: ; preds = %6
%28 = fcmp olt double %17, %12
br i1 %28, label %29, label %30
29: ; preds = %27
br label %30
30: ; preds = %6, %29, %27
%31 = phi i32 [ 1, %29 ], [ 1, %27 ], [ 2, %6 ]
%32 = phi double [ %17, %29 ], [ %12, %27 ], [ %12, %6 ]
%33 = phi double [ %12, %29 ], [ %12, %27 ], [ %17, %6 ]
%34 = fcmp ogt double %22, %33
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = fcmp olt double %22, %32
br i1 %36, label %37, label %38
37: ; preds = %35
br label %38
38: ; preds = %37, %35, %30
%39 = phi i32 [ %31, %37 ], [ %31, %35 ], [ 3, %30 ]
%40 = phi double [ %22, %37 ], [ %32, %35 ], [ %32, %30 ]
%41 = phi double [ %33, %37 ], [ %33, %35 ], [ %22, %30 ]
%42 = fadd double %12, %17
%43 = fadd double %42, %22
%44 = fdiv double %43, 3.000000e+00
store double %44, double* %4
%45 = fcmp oeq double %41, %40
br i1 %45, label %46, label %47
46: ; preds = %38
store double 0.000000e+00, double* %5
br label %81
47: ; preds = %38
%48 = fsub double 1.000000e+00, %41
%49 = fsub double 1.000000e+00, %44
%50 = insertelement <2 x double> poison, double %40, i64 0
%51 = insertelement <2 x double> %50, double %48, i64 1
%52 = insertelement <2 x double> poison, double %44, i64 0
%53 = insertelement <2 x double> %52, double %49, i64 1
%54 = fdiv <2 x double> %51, %53
%55 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %54
%56 = extractelement <2 x double> %55, i64 0
%57 = extractelement <2 x double> %55, i64 1
%58 = fcmp ogt double %56, %57
%59 = select i1 %58, double %56, double %57
%60 = fcmp ogt double %59, 0.000000e+00
%61 = select i1 %60, double %59, double 0.000000e+00
%62 = fcmp olt double %61, 1.000000e+00
%63 = select i1 %62, double %61, double 1.000000e+00
store double %63, double* %5
%64 = add nsw i32 %39, -1
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [3 x double], [3 x double]* @RGBtoHLS.base, i64 0, i64 %65
%67 = load double, double* %66
%68 = add nuw nsw i32 %39, 1
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 %69
%71 = load double, double* %70
%72 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 %65
%73 = load double, double* %72
%74 = fsub double %71, %73
%75 = fsub double %41, %40
%76 = fdiv double %74, %75
%77 = fadd double %67, %76
%78 = fcmp olt double %77, 0.000000e+00
br i1 %78, label %79, label %81
79: ; preds = %47
%80 = fadd double %77, 6.000000e+00
br label %81
81: ; preds = %47, %79, %46
%82 = phi double [ %77, %47 ], [ %80, %79 ], [ 0.000000e+00, %46 ]
%83 = fmul double %82, 6.000000e+01
store double %83, double* %3
ret void
}