#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*/ hsv2rgb(float *, float *, float *, int /*<<< orphan*/,
                           double, double);
int /*<<< orphan*/ modone(float);
int /*<<< orphan*/ set_all_leds(unsigned char *);
void sweep(float hue) {
  int i;
  float r, g, b;
  float sweep_range = 0.0833;
  unsigned char leds[18];
  for (i = 0; i < 6; i++) {
    hsv2rgb(&r, &g, &b, modone(hue + (sweep_range * i)), 1.0, 1.0);
    leds[i * 3] = (unsigned char)(b * 255);
    leds[i * 3 + 1] = (unsigned char)(g * 255);
    leds[i * 3 + 2] = (unsigned char)(r * 255);
  }
  set_all_leds(leds);
}


x86 assembly (clang, -O0):
<sweep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xebb(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1205 <sweep+0xd5>
movss  -0x4(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <modone@plt>
mov    %eax,%ecx
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
movsd  0xe7b(%rip),%xmm1
movaps %xmm1,%xmm0
call   1040 <hsv2rgb@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe62(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,%cl
mov    -0x8(%rbp),%edx
mov    %edx,%eax
lea    (%rax,%rax,2),%eax
cltq
mov    %cl,-0x30(%rbp,%rax,1)
movss  -0x10(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,%dl
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
cltq
lea    -0x30(%rbp),%rcx
mov    %dl,0x1(%rax,%rcx,1)
movss  -0xc(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,%cl
imul   $0x3,-0x8(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <sweep+0x21>
lea    -0x30(%rbp),%rdi
call   1050 <set_all_leds@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sweep>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movss  %xmm0,(%rsp)
lea    0x12(%rsp),%rbx
xor    %r13d,%r13d
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
mulss  0xe90(%rip),%xmm0
addss  (%rsp),%xmm0
call   1030 <modone@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %eax,%ecx
movsd  0xe7b(%rip),%xmm0
movaps %xmm0,%xmm1
call   1040 <hsv2rgb@plt>
movss  0x4(%rsp),%xmm0
movss  0xe61(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,-0x2(%rbx)
movss  0x8(%rsp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,-0x1(%rbx)
movss  0xc(%rsp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %al,(%rbx)
add    $0x1,%r13
add    $0x3,%rbx
cmp    $0x6,%r13
jne    1160 <sweep+0x30>
lea    0x10(%rsp),%rdi
call   1050 <set_all_leds@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sweep(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca [18 x i8]
store float %0, float* %2
store float 0x3FB5532620000000, float* %7
store i32 0, i32* %3
br label %9
9: ; preds = %43, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %46
12: ; preds = %9
%13 = load float, float* %2
%14 = load float, float* %7
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to float
%17 = call float @llvm.fmuladd.f32(float %14, float %16, float %13)
%18 = call i32 @modone(float %17)
%19 = call i32 @hsv2rgb(float* %4, float* %5, float* %6, i32 %18, double 1.000000e+00, double 1.000000e+00)
%20 = load float, float* %6
%21 = fmul float %20, 2.550000e+02
%22 = fptoui float %21 to i8
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [18 x i8], [18 x i8]* %8, i64 0, i64 %25
store i8 %22, i8* %26
%27 = load float, float* %5
%28 = fmul float %27, 2.550000e+02
%29 = fptoui float %28 to i8
%30 = load i32, i32* %3
%31 = mul nsw i32 %30, 3
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [18 x i8], [18 x i8]* %8, i64 0, i64 %33
store i8 %29, i8* %34
%35 = load float, float* %4
%36 = fmul float %35, 2.550000e+02
%37 = fptoui float %36 to i8
%38 = load i32, i32* %3
%39 = mul nsw i32 %38, 3
%40 = add nsw i32 %39, 2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [18 x i8], [18 x i8]* %8, i64 0, i64 %41
store i8 %37, i8* %42
br label %43
43: ; preds = %12
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %9
46: ; preds = %9
%47 = getelementptr inbounds [18 x i8], [18 x i8]* %8, i64 0, i64 0
%48 = call i32 @set_all_leds(i8* %47)
ret void
}

LLVM IR (-O2):
define void @sweep(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca [18 x i8]
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 0
br label %10
10: ; preds = %1, %10
%11 = phi i64 [ 0, %1 ], [ %32, %10 ]
%12 = trunc i64 %11 to i32
%13 = sitofp i32 %12 to float
%14 = call float @llvm.fmuladd.f32(float %13, float 0x3FB5532620000000, float %0)
%15 = call i32 @modone(float %14)
%16 = call i32 @hsv2rgb(float* %2, float* %3, float* %4, i32 %15, double 1.000000e+00, double 1.000000e+00)
%17 = load float, float* %4
%18 = fmul float %17, 2.550000e+02
%19 = fptoui float %18 to i8
%20 = mul nuw nsw i64 %11, 3
%21 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 %20
store i8 %19, i8* %21
%22 = load float, float* %3
%23 = fmul float %22, 2.550000e+02
%24 = fptoui float %23 to i8
%25 = add nuw nsw i64 %20, 1
%26 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 %25
store i8 %24, i8* %26
%27 = load float, float* %2
%28 = fmul float %27, 2.550000e+02
%29 = fptoui float %28 to i8
%30 = add nuw nsw i64 %20, 2
%31 = getelementptr inbounds [18 x i8], [18 x i8]* %5, i64 0, i64 %30
store i8 %29, i8* %31
%32 = add nuw nsw i64 %11, 1
%33 = icmp eq i64 %32, 6
br i1 %33, label %34, label %10
34: ; preds = %10
%35 = call i32 @set_all_leds(i8* %9)
ret void
}