#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);
void draw_rgb(unsigned long g, unsigned long n, double *R, double *G,
              double *B) {
  double h, hx;
  h = 5.0 * ((double)g) / ((double)n);
  hx = 1.0 - fabs(fmod(h, 2.0) - 1.0);
  if (h < 1.0) {
    *R = 1.0;
    *G = hx;
    *B = 0.0;
  } else if (h < 2.0) {
    *R = hx;
    *G = 1.0;
    *B = 0.0;
  } else if (h < 3.0) {
    *R = 0.0;
    *G = 1.0;
    *B = hx;
  } else if (h < 4.0) {
    *R = 0.0;
    *G = hx;
    *B = 1.0;
  } else if (h < 5.0) {
    *R = hx;
    *G = 0.0;
    *B = 1.0;
  } else {
    *R = 1.0;
    *G = 0.0;
    *B = hx;
  }
}


x86 assembly (clang, -O0):
<draw_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movaps 0xeed(%rip),%xmm3
movq   -0x8(%rbp),%xmm0
punpckldq %xmm3,%xmm0
movapd 0xeec(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xea5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movq   -0x10(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
call   1030 <fmod@plt>
cvtsi2sd %rax,%xmm0
movsd  0xe51(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe38(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe27(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1211 <draw_rgb+0xf1>
mov    -0x18(%rbp),%rax
movsd  0xe10(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    134d <draw_rgb+0x22d>
movsd  0xdef(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1251 <draw_rgb+0x131>
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xdc3(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1348 <draw_rgb+0x228>
movsd  0xdbf(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1291 <draw_rgb+0x171>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xd85(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1343 <draw_rgb+0x223>
movsd  0xd87(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    12d1 <draw_rgb+0x1b1>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xd38(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    133e <draw_rgb+0x21e>
movsd  0xd37(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1311 <draw_rgb+0x1f1>
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xcf8(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1339 <draw_rgb+0x219>
mov    -0x18(%rbp),%rax
movsd  0xce3(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    133e <draw_rgb+0x21e>
jmp    1343 <draw_rgb+0x223>
jmp    1348 <draw_rgb+0x228>
jmp    134d <draw_rgb+0x22d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_rgb>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
movq   %rdi,%xmm0
movdqa 0xec1(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xec5(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
mulsd  0xebd(%rip),%xmm3
movq   %rsi,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
movapd %xmm3,(%rsp)
movsd  0xe9b(%rip),%xmm1
movapd %xmm3,%xmm0
call   1030 <fmod@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe8a(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movapd (%rsp),%xmm4
movsd  0xe7b(%rip),%xmm2
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm2
jbe    11d8 <draw_rgb+0xb8>
movapd %xmm1,%xmm3
jmp    125f <draw_rgb+0x13f>
movsd  0xe58(%rip),%xmm3
movsd  0xe40(%rip),%xmm2
ucomisd %xmm4,%xmm2
jbe    11f4 <draw_rgb+0xd4>
movapd %xmm1,%xmm2
jmp    125f <draw_rgb+0x13f>
xorpd  %xmm2,%xmm2
movsd  0xe40(%rip),%xmm0
ucomisd %xmm4,%xmm0
jbe    120c <draw_rgb+0xec>
movapd %xmm1,%xmm0
jmp    125f <draw_rgb+0x13f>
movsd  0xe34(%rip),%xmm0
ucomisd %xmm4,%xmm0
jbe    1228 <draw_rgb+0x108>
movsd  0xe16(%rip),%xmm0
movapd %xmm1,%xmm3
jmp    125f <draw_rgb+0x13f>
movsd  0xdf0(%rip),%xmm0
ucomisd %xmm4,%xmm0
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm2
andpd  %xmm1,%xmm2
movsd  0xdef(%rip),%xmm0
andnpd %xmm0,%xmm4
orpd   %xmm2,%xmm4
ja     1257 <draw_rgb+0x137>
movapd %xmm1,%xmm0
xorpd  %xmm3,%xmm3
movapd %xmm4,%xmm2
movsd  %xmm2,(%rbx)
movsd  %xmm3,(%r15)
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @draw_rgb(i64 %0, i64 %1, double* %2, double* %3, double* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
store i64 %0, i64* %6
store i64 %1, i64* %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%13 = load i64, i64* %6
%14 = uitofp i64 %13 to double
%15 = fmul double 5.000000e+00, %14
%16 = load i64, i64* %7
%17 = uitofp i64 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %11
%19 = load double, double* %11
%20 = call i64 @fmod(double %19, double 2.000000e+00)
%21 = sitofp i64 %20 to double
%22 = fsub double %21, 1.000000e+00
%23 = fptosi double %22 to i64
%24 = call double @fabs(i64 %23)
%25 = fsub double 1.000000e+00, %24
store double %25, double* %12
%26 = load double, double* %11
%27 = fcmp olt double %26, 1.000000e+00
br i1 %27, label %28, label %33
28: ; preds = %5
%29 = load double*, double** %8
store double 1.000000e+00, double* %29
%30 = load double, double* %12
%31 = load double*, double** %9
store double %30, double* %31
%32 = load double*, double** %10
store double 0.000000e+00, double* %32
br label %74
33: ; preds = %5
%34 = load double, double* %11
%35 = fcmp olt double %34, 2.000000e+00
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load double, double* %12
%38 = load double*, double** %8
store double %37, double* %38
%39 = load double*, double** %9
store double 1.000000e+00, double* %39
%40 = load double*, double** %10
store double 0.000000e+00, double* %40
br label %73
41: ; preds = %33
%42 = load double, double* %11
%43 = fcmp olt double %42, 3.000000e+00
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load double*, double** %8
store double 0.000000e+00, double* %45
%46 = load double*, double** %9
store double 1.000000e+00, double* %46
%47 = load double, double* %12
%48 = load double*, double** %10
store double %47, double* %48
br label %72
49: ; preds = %41
%50 = load double, double* %11
%51 = fcmp olt double %50, 4.000000e+00
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load double*, double** %8
store double 0.000000e+00, double* %53
%54 = load double, double* %12
%55 = load double*, double** %9
store double %54, double* %55
%56 = load double*, double** %10
store double 1.000000e+00, double* %56
br label %71
57: ; preds = %49
%58 = load double, double* %11
%59 = fcmp olt double %58, 5.000000e+00
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load double, double* %12
%62 = load double*, double** %8
store double %61, double* %62
%63 = load double*, double** %9
store double 0.000000e+00, double* %63
%64 = load double*, double** %10
store double 1.000000e+00, double* %64
br label %70
65: ; preds = %57
%66 = load double*, double** %8
store double 1.000000e+00, double* %66
%67 = load double*, double** %9
store double 0.000000e+00, double* %67
%68 = load double, double* %12
%69 = load double*, double** %10
store double %68, double* %69
br label %70
70: ; preds = %65, %60
br label %71
71: ; preds = %70, %52
br label %72
72: ; preds = %71, %44
br label %73
73: ; preds = %72, %36
br label %74
74: ; preds = %73, %28
ret void
}

LLVM IR (-O2):
define void @draw_rgb(i64 %0, i64 %1, double* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = uitofp i64 %0 to double
%7 = fmul double %6, 5.000000e+00
%8 = uitofp i64 %1 to double
%9 = fdiv double %7, %8
%10 = tail call i64 @fmod(double %9, double 2.000000e+00)
%11 = sitofp i64 %10 to double
%12 = fadd double %11, -1.000000e+00
%13 = fptosi double %12 to i64
%14 = tail call double @fabs(i64 %13)
%15 = fsub double 1.000000e+00, %14
%16 = fcmp olt double %9, 1.000000e+00
br i1 %16, label %27, label %17
17: ; preds = %5
%18 = fcmp olt double %9, 2.000000e+00
br i1 %18, label %27, label %19
19: ; preds = %17
%20 = fcmp olt double %9, 3.000000e+00
br i1 %20, label %27, label %21
21: ; preds = %19
%22 = fcmp olt double %9, 4.000000e+00
br i1 %22, label %27, label %23
23: ; preds = %21
%24 = fcmp olt double %9, 5.000000e+00
%25 = select i1 %24, double %15, double 1.000000e+00
%26 = select i1 %24, double 1.000000e+00, double %15
br label %27
27: ; preds = %23, %21, %19, %17, %5
%28 = phi double [ 1.000000e+00, %5 ], [ %15, %17 ], [ 0.000000e+00, %19 ], [ 0.000000e+00, %21 ], [ %25, %23 ]
%29 = phi double [ %15, %5 ], [ 1.000000e+00, %17 ], [ 1.000000e+00, %19 ], [ %15, %21 ], [ 0.000000e+00, %23 ]
%30 = phi double [ 0.000000e+00, %5 ], [ 0.000000e+00, %17 ], [ %15, %19 ], [ 1.000000e+00, %21 ], [ %26, %23 ]
store double %28, double* %2
store double %29, double* %3
store double %30, double* %4
ret void
}