#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 */
int /*<<< orphan*/ assert(int);
int calculate_cyclic_number(double _r, double _g, double _b, int mode) {
  int r = _r * 255;
  int g = _g * 255;
  int b = _b * 255;
  int color;
  int r_bits = 4 / 3;
  int g_bits = 4 / 3;
  int b_bits = 4 - (r_bits + g_bits);
  int r_mask = 1 << r_bits;
  int g_mask = 1 << g_bits;
  int b_mask = 1 << b_bits;
  color = ((r % r_mask) << (g_bits + b_bits)) + ((g % g_mask) << b_bits) +
          (b % b_mask);
  assert(color <= (1U << 4));
  return color;
}


x86 assembly (clang, -O0):
<calculate_cyclic_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  0xece(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
movsd  0xeba(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movsd  0xea6(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x30(%rbp),%ecx
add    -0x34(%rbp),%ecx
mov    $0x4,%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x3c(%rbp)
mov    -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
shl    %cl,%edx
mov    %edx,-0x4c(%rbp)
mov    -0x24(%rbp),%eax
cltd
idivl  -0x40(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x38(%rbp),%ecx
shl    %cl,%edx
add    %edx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%eax
cltd
idivl  -0x44(%rbp)
mov    -0x48(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x10,-0x2c(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x2c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_cyclic_number>:
push   %rbx
movsd  0xee7(%rip),%xmm3
mulsd  %xmm3,%xmm0
cvttsd2si %xmm0,%eax
mulsd  %xmm3,%xmm1
cvttsd2si %xmm1,%ecx
mulsd  %xmm3,%xmm2
cvttsd2si %xmm2,%ebx
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
and    $0x1ffffffe,%edx
sub    %edx,%eax
shl    $0x3,%eax
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
and    $0x3ffffffe,%edx
sub    %edx,%ecx
lea    (%rax,%rcx,4),%eax
lea    0x3(%rbx),%ecx
test   %ebx,%ebx
cmovns %ebx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%ebx
add    %eax,%ebx
xor    %edi,%edi
cmp    $0x11,%ebx
setb   %dil
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @calculate_cyclic_number(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
%19 = load double, double* %5
%20 = fmul double %19, 2.550000e+02
%21 = fptosi double %20 to i32
store i32 %21, i32* %9
%22 = load double, double* %6
%23 = fmul double %22, 2.550000e+02
%24 = fptosi double %23 to i32
store i32 %24, i32* %10
%25 = load double, double* %7
%26 = fmul double %25, 2.550000e+02
%27 = fptosi double %26 to i32
store i32 %27, i32* %11
store i32 1, i32* %13
store i32 1, i32* %14
%28 = load i32, i32* %13
%29 = load i32, i32* %14
%30 = add nsw i32 %28, %29
%31 = sub nsw i32 4, %30
store i32 %31, i32* %15
%32 = load i32, i32* %13
%33 = shl i32 1, %32
store i32 %33, i32* %16
%34 = load i32, i32* %14
%35 = shl i32 1, %34
store i32 %35, i32* %17
%36 = load i32, i32* %15
%37 = shl i32 1, %36
store i32 %37, i32* %18
%38 = load i32, i32* %9
%39 = load i32, i32* %16
%40 = srem i32 %38, %39
%41 = load i32, i32* %14
%42 = load i32, i32* %15
%43 = add nsw i32 %41, %42
%44 = shl i32 %40, %43
%45 = load i32, i32* %10
%46 = load i32, i32* %17
%47 = srem i32 %45, %46
%48 = load i32, i32* %15
%49 = shl i32 %47, %48
%50 = add nsw i32 %44, %49
%51 = load i32, i32* %11
%52 = load i32, i32* %18
%53 = srem i32 %51, %52
%54 = add nsw i32 %50, %53
store i32 %54, i32* %12
%55 = load i32, i32* %12
%56 = icmp ule i32 %55, 16
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i32, i32* %12
ret i32 %59
}

LLVM IR (-O2):
define i32 @calculate_cyclic_number(double %0, double %1, double %2, i32 %3) {
%5 = fmul double %0, 2.550000e+02
%6 = fptosi double %5 to i32
%7 = fmul double %1, 2.550000e+02
%8 = fptosi double %7 to i32
%9 = fmul double %2, 2.550000e+02
%10 = fptosi double %9 to i32
%11 = srem i32 %6, 2
%12 = shl nsw i32 %11, 3
%13 = srem i32 %8, 2
%14 = shl nsw i32 %13, 2
%15 = add nsw i32 %14, %12
%16 = srem i32 %10, 4
%17 = add nsw i32 %15, %16
%18 = icmp ult i32 %17, 17
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
ret i32 %17
}