#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 int uint8_t;
typedef int uint32_t;

/* Variables and functions */
uint32_t rainbowHue(uint8_t hue, uint8_t brightness) {
  hue = 255 - hue;
  if (hue < 85)
    return ((255 - hue * 3) * brightness / 256 << 16) +
           (hue * 3) * brightness / 256;
  if (hue < 170) {
    hue -= 85;
    return ((hue * 3) * brightness / 256 << 8) +
           (255 - hue * 3) * brightness / 256;
  }
  hue -= 170;
  return ((hue * 3) * brightness / 256 << 16) +
         ((255 - hue * 3) * brightness / 256 << 8);
}


x86 assembly (clang, -O0):
<rainbowHue>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0xff,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x55,-0x8(%rbp)
jge    115b <rainbowHue+0x5b>
imul   $0x3,-0x8(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
shl    $0x10,%eax
mov    %eax,-0x10(%rbp)
imul   $0x3,-0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11f2 <rainbowHue+0xf2>
cmpl   $0xaa,-0x8(%rbp)
jge    11ad <rainbowHue+0xad>
mov    -0x8(%rbp),%eax
sub    $0x55,%eax
mov    %eax,-0x8(%rbp)
imul   $0x3,-0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
imul   $0x3,-0x8(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11f2 <rainbowHue+0xf2>
mov    -0x8(%rbp),%eax
sub    $0xaa,%eax
mov    %eax,-0x8(%rbp)
imul   $0x3,-0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
shl    $0x10,%eax
mov    %eax,-0x18(%rbp)
imul   $0x3,-0x8(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
imul   -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rainbowHue>:
cmp    $0xab,%edi
jl     1132 <rainbowHue+0x32>
mov    $0xff,%eax
mov    $0xff,%ecx
sub    %edi,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
imul   %esi,%eax
lea    0xff(%rax),%edx
test   %eax,%eax
cmovns %eax,%edx
shl    $0x8,%edx
and    $0xffff0000,%edx
jmp    115e <rainbowHue+0x5e>
cmp    $0x56,%edi
jl     1172 <rainbowHue+0x72>
mov    $0xaa,%eax
sub    %edi,%eax
lea    (%rax,%rax,2),%eax
mov    %eax,%ecx
imul   %esi,%ecx
lea    0xff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
mov    $0xff,%ecx
sub    %eax,%ecx
imul   %esi,%ecx
lea    0xff(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x8,%eax
add    %edx,%eax
ret
mov    $0x55,%eax
sub    %edi,%eax
lea    (%rax,%rax,2),%eax
mov    %eax,%ecx
imul   %esi,%ecx
lea    0xff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
shl    $0x8,%edx
and    $0xffff0000,%edx
mov    $0xff,%ecx
sub    %eax,%ecx
imul   %esi,%ecx
lea    0xff(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xffffff00,%eax
add    %edx,%eax
ret

LLVM IR (-O0):
define i32 @rainbowHue(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = sub nsw i32 255, %6
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 85
br i1 %9, label %10, label %24
10: ; preds = %2
%11 = load i32, i32* %4
%12 = mul nsw i32 %11, 3
%13 = sub nsw i32 255, %12
%14 = load i32, i32* %5
%15 = mul nsw i32 %13, %14
%16 = sdiv i32 %15, 256
%17 = shl i32 %16, 16
%18 = load i32, i32* %4
%19 = mul nsw i32 %18, 3
%20 = load i32, i32* %5
%21 = mul nsw i32 %19, %20
%22 = sdiv i32 %21, 256
%23 = add nsw i32 %17, %22
store i32 %23, i32* %3
br label %60
24: ; preds = %2
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 170
br i1 %26, label %27, label %43
27: ; preds = %24
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 85
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = mul nsw i32 %30, 3
%32 = load i32, i32* %5
%33 = mul nsw i32 %31, %32
%34 = sdiv i32 %33, 256
%35 = shl i32 %34, 8
%36 = load i32, i32* %4
%37 = mul nsw i32 %36, 3
%38 = sub nsw i32 255, %37
%39 = load i32, i32* %5
%40 = mul nsw i32 %38, %39
%41 = sdiv i32 %40, 256
%42 = add nsw i32 %35, %41
store i32 %42, i32* %3
br label %60
43: ; preds = %24
%44 = load i32, i32* %4
%45 = sub nsw i32 %44, 170
store i32 %45, i32* %4
%46 = load i32, i32* %4
%47 = mul nsw i32 %46, 3
%48 = load i32, i32* %5
%49 = mul nsw i32 %47, %48
%50 = sdiv i32 %49, 256
%51 = shl i32 %50, 16
%52 = load i32, i32* %4
%53 = mul nsw i32 %52, 3
%54 = sub nsw i32 255, %53
%55 = load i32, i32* %5
%56 = mul nsw i32 %54, %55
%57 = sdiv i32 %56, 256
%58 = shl i32 %57, 8
%59 = add nsw i32 %51, %58
store i32 %59, i32* %3
br label %60
60: ; preds = %43, %27, %10
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
define i32 @rainbowHue(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 170
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = sub nsw i32 255, %0
%6 = mul nsw i32 %5, 3
%7 = sub nsw i32 255, %6
%8 = mul nsw i32 %7, %1
%9 = sdiv i32 %8, 256
%10 = shl i32 %9, 16
%11 = mul nsw i32 %6, %1
%12 = sdiv i32 %11, 256
%13 = add nsw i32 %10, %12
br label %37
14: ; preds = %2
%15 = icmp sgt i32 %0, 85
br i1 %15, label %16, label %26
16: ; preds = %14
%17 = sub nuw nsw i32 170, %0
%18 = mul nuw nsw i32 %17, 3
%19 = mul nsw i32 %18, %1
%20 = sdiv i32 %19, 256
%21 = shl nsw i32 %20, 8
%22 = sub nuw nsw i32 255, %18
%23 = mul nsw i32 %22, %1
%24 = sdiv i32 %23, 256
%25 = add nsw i32 %21, %24
br label %37
26: ; preds = %14
%27 = sub i32 85, %0
%28 = mul nsw i32 %27, 3
%29 = mul nsw i32 %28, %1
%30 = sdiv i32 %29, 256
%31 = shl i32 %30, 16
%32 = sub nsw i32 255, %28
%33 = mul nsw i32 %32, %1
%34 = sdiv i32 %33, 256
%35 = shl nsw i32 %34, 8
%36 = add nsw i32 %35, %31
br label %37
37: ; preds = %26, %16, %4
%38 = phi i32 [ %13, %4 ], [ %25, %16 ], [ %36, %26 ]
ret i32 %38
}