#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 */
double fabs(scalar_t__);
scalar_t__ fmod(double, double);
int hue_to_rgb(int hue) {
  hue = hue % 360;
  int x = (1.0 - fabs(fmod((double)hue / 60.0, 2.0) - 1.0)) * 0xff;
  if (hue < 60)
    return 0xff0000 + (x << 8);
  if (hue < 120)
    return (x << 16) + 0xff00;
  if (hue < 180)
    return 0xff00 + x;
  if (hue < 240)
    return (x << 8) + 0xff;
  if (hue < 300)
    return (x << 16) + 0xff;
  return 0xff0000 + x;
}


x86 assembly (clang, -O0):
<hue_to_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xed2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xebe(%rip),%xmm1
call   1030 <fmod@plt>
cvtsi2sd %rax,%xmm0
movsd  0xea4(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe8b(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe77(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3c,-0x8(%rbp)
jge    11b1 <hue_to_rgb+0x91>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
add    $0xff0000,%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <hue_to_rgb+0x116>
cmpl   $0x78,-0x8(%rbp)
jge    11ce <hue_to_rgb+0xae>
mov    -0xc(%rbp),%eax
shl    $0x10,%eax
add    $0xff00,%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <hue_to_rgb+0x116>
cmpl   $0xb4,-0x8(%rbp)
jge    11eb <hue_to_rgb+0xcb>
mov    -0xc(%rbp),%eax
add    $0xff00,%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <hue_to_rgb+0x116>
cmpl   $0xf0,-0x8(%rbp)
jge    120b <hue_to_rgb+0xeb>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
add    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <hue_to_rgb+0x116>
cmpl   $0x12c,-0x8(%rbp)
jge    122b <hue_to_rgb+0x10b>
mov    -0xc(%rbp),%eax
shl    $0x10,%eax
add    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <hue_to_rgb+0x116>
mov    -0xc(%rbp),%eax
add    $0xff0000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hue_to_rgb>:
push   %rbx
movslq %edi,%rbx
imul   $0xffffffffb60b60b7,%rbx,%rax
shr    $0x20,%rax
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
imul   $0x168,%eax,%eax
sub    %eax,%ebx
cvtsi2sd %ebx,%xmm0
divsd  0xeb1(%rip),%xmm0
movsd  0xeb1(%rip),%xmm1
call   1030 <fmod@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xea4(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movsd  0xe9a(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe96(%rip),%xmm1
cvttsd2si %xmm1,%eax
cmp    $0x3b,%ebx
jg     119d <hue_to_rgb+0x7d>
shl    $0x8,%eax
add    $0xff0000,%eax
pop    %rbx
ret
cmp    $0x77,%ebx
ja     11ac <hue_to_rgb+0x8c>
shl    $0x10,%eax
or     $0xff00,%eax
pop    %rbx
ret
cmp    $0xb3,%ebx
ja     11bb <hue_to_rgb+0x9b>
add    $0xff00,%eax
pop    %rbx
ret
cmp    $0xef,%ebx
ja     11c8 <hue_to_rgb+0xa8>
shl    $0x8,%eax
jmp    11d3 <hue_to_rgb+0xb3>
cmp    $0x12b,%ebx
ja     1196 <hue_to_rgb+0x76>
shl    $0x10,%eax
or     $0xff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @hue_to_rgb(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = srem i32 %5, 360
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = sitofp i32 %7 to double
%9 = fdiv double %8, 6.000000e+01
%10 = call i64 @fmod(double %9, double 2.000000e+00)
%11 = sitofp i64 %10 to double
%12 = fsub double %11, 1.000000e+00
%13 = fptosi double %12 to i64
%14 = call double @fabs(i64 %13)
%15 = fsub double 1.000000e+00, %14
%16 = fmul double %15, 2.550000e+02
%17 = fptosi double %16 to i32
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 60
br i1 %19, label %20, label %24
20: ; preds = %1
%21 = load i32, i32* %4
%22 = shl i32 %21, 8
%23 = add nsw i32 16711680, %22
store i32 %23, i32* %2
br label %54
24: ; preds = %1
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 120
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %4
%29 = shl i32 %28, 16
%30 = add nsw i32 %29, 65280
store i32 %30, i32* %2
br label %54
31: ; preds = %24
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 180
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %4
%36 = add nsw i32 65280, %35
store i32 %36, i32* %2
br label %54
37: ; preds = %31
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 240
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i32, i32* %4
%42 = shl i32 %41, 8
%43 = add nsw i32 %42, 255
store i32 %43, i32* %2
br label %54
44: ; preds = %37
%45 = load i32, i32* %3
%46 = icmp slt i32 %45, 300
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32, i32* %4
%49 = shl i32 %48, 16
%50 = add nsw i32 %49, 255
store i32 %50, i32* %2
br label %54
51: ; preds = %44
%52 = load i32, i32* %4
%53 = add nsw i32 16711680, %52
store i32 %53, i32* %2
br label %54
54: ; preds = %51, %47, %40, %34, %27, %20
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
define i32 @hue_to_rgb(i32 %0) {
%2 = srem i32 %0, 360
%3 = sitofp i32 %2 to double
%4 = fdiv double %3, 6.000000e+01
%5 = tail call i64 @fmod(double %4, double 2.000000e+00)
%6 = sitofp i64 %5 to double
%7 = fadd double %6, -1.000000e+00
%8 = fptosi double %7 to i64
%9 = tail call double @fabs(i64 %8)
%10 = fsub double 1.000000e+00, %9
%11 = fmul double %10, 2.550000e+02
%12 = fptosi double %11 to i32
%13 = icmp slt i32 %2, 60
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = shl i32 %12, 8
%16 = add nsw i32 %15, 16711680
br label %38
17: ; preds = %1
%18 = icmp ult i32 %2, 120
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = shl i32 %12, 16
%21 = or i32 %20, 65280
br label %38
22: ; preds = %17
%23 = icmp ult i32 %2, 180
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = add nsw i32 %12, 65280
br label %38
26: ; preds = %22
%27 = icmp ult i32 %2, 240
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = shl i32 %12, 8
%30 = or i32 %29, 255
br label %38
31: ; preds = %26
%32 = icmp ult i32 %2, 300
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = shl i32 %12, 16
%35 = or i32 %34, 255
br label %38
36: ; preds = %31
%37 = add nsw i32 %12, 16711680
br label %38
38: ; preds = %36, %33, %28, %24, %19, %14
%39 = phi i32 [ %16, %14 ], [ %21, %19 ], [ %25, %24 ], [ %30, %28 ], [ %35, %33 ], [ %37, %36 ]
ret i32 %39
}