#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*/ floor(float);
int /*<<< orphan*/ hslimage_color(int, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/, float *, float *,
                                  float *);
int /*<<< orphan*/ putc(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main() {
  int x, y;
  float r, g, b;
  for (y = 0; y < 512; ++y) {
    for (x = 0; x < 512; ++x) {
      hslimage_color(x / 512.0, y / 512.0, 0, 0, &r, &g, &b);
      putc(floor(r * 255 + 0.5), stdout);
      putc(floor(g * 255 + 0.5), stdout);
      putc(floor(b * 255 + 0.5), stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x200,-0xc(%rbp)
jge    126d <main+0x13d>
movl   $0x0,-0x8(%rbp)
cmpl   $0x200,-0x8(%rbp)
jge    125a <main+0x12a>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
xor    %ecx,%ecx
lea    -0x10(%rbp),%r8
lea    -0x14(%rbp),%r9
lea    -0x18(%rbp),%rax
mov    %ecx,%edx
mov    %rax,(%rsp)
call   1040 <hslimage_color@plt>
movss  0xe5e(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <floor@plt>
mov    %eax,%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
movss  0xe28(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <floor@plt>
mov    %eax,%edi
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
movss  0xdf2(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <floor@plt>
mov    %eax,%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115a <main+0x2a>
jmp    125f <main+0x12f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
xorpd  %xmm0,%xmm0
movsd  0xeb4(%rip),%xmm1
lea    0xc(%rsp),%r12
lea    0x14(%rsp),%r14
lea    0x10(%rsp),%r13
mov    0x2e7e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
mov    $0x200,%r15d
xorpd  %xmm3,%xmm3
nopl   0x0(%rax)
movsd  %xmm3,0x20(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    %r12,(%rsp)
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r13,%r9
call   1040 <hslimage_color@plt>
movss  0x14(%rsp),%xmm0
movss  0xe4b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe43(%rip),%xmm1
addss  %xmm1,%xmm0
call   1050 <floor@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1030 <putc@plt>
movss  0x10(%rsp),%xmm0
mulss  0xe1f(%rip),%xmm0
addss  0xe1b(%rip),%xmm0
call   1050 <floor@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1030 <putc@plt>
movss  0xc(%rsp),%xmm0
mulss  0xdfb(%rip),%xmm0
addss  0xdf7(%rip),%xmm0
call   1050 <floor@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1030 <putc@plt>
movsd  0x20(%rsp),%xmm3
movsd  0xdcf(%rip),%xmm2
movsd  0xdbf(%rip),%xmm1
addsd  %xmm2,%xmm3
add    $0xffffffff,%r15d
jne    1190 <main+0x60>
movsd  0x18(%rsp),%xmm0
addsd  %xmm2,%xmm0
mov    0x8(%rsp),%eax
add    $0x1,%eax
cmp    $0x200,%eax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
br label %7
7: ; preds = %52, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 512
br i1 %9, label %10, label %55
10: ; preds = %7
store i32 0, i32* %2
br label %11
11: ; preds = %48, %10
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 512
br i1 %13, label %14, label %51
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 5.120000e+02
%18 = fptosi double %17 to i32
%19 = load i32, i32* %3
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 5.120000e+02
%22 = fptosi double %21 to i32
%23 = call i32 @hslimage_color(i32 %18, i32 %22, i32 0, i32 0, float* %4, float* %5, float* %6)
%24 = load float, float* %4
%25 = fmul float %24, 2.550000e+02
%26 = fpext float %25 to double
%27 = fadd double %26, 5.000000e-01
%28 = fptrunc double %27 to float
%29 = call i32 @floor(float %28)
%30 = load i32, i32* @stdout
%31 = call i32 @putc(i32 %29, i32 %30)
%32 = load float, float* %5
%33 = fmul float %32, 2.550000e+02
%34 = fpext float %33 to double
%35 = fadd double %34, 5.000000e-01
%36 = fptrunc double %35 to float
%37 = call i32 @floor(float %36)
%38 = load i32, i32* @stdout
%39 = call i32 @putc(i32 %37, i32 %38)
%40 = load float, float* %6
%41 = fmul float %40, 2.550000e+02
%42 = fpext float %41 to double
%43 = fadd double %42, 5.000000e-01
%44 = fptrunc double %43 to float
%45 = call i32 @floor(float %44)
%46 = load i32, i32* @stdout
%47 = call i32 @putc(i32 %45, i32 %46)
br label %48
48: ; preds = %14
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %11
51: ; preds = %11
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %7
55: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
br label %7
7: ; preds = %0, %38
%8 = phi i32 [ 0, %0 ], [ %39, %38 ]
%9 = sitofp i32 %8 to double
%10 = fmul double %9, 0x3F60000000000000
%11 = fptosi double %10 to i32
br label %12
12: ; preds = %7, %12
%13 = phi i32 [ 0, %7 ], [ %36, %12 ]
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 0x3F60000000000000
%16 = fptosi double %15 to i32
%17 = call i32 @hslimage_color(i32 %16, i32 %11, i32 0, i32 0, float* %1, float* %2, float* %3)
%18 = load float, float* %1
%19 = fmul float %18, 2.550000e+02
%20 = fadd float %19, 5.000000e-01
%21 = call i32 @floor(float %20)
%22 = load i32, i32* @stdout
%23 = call i32 @putc(i32 %21, i32 %22)
%24 = load float, float* %2
%25 = fmul float %24, 2.550000e+02
%26 = fadd float %25, 5.000000e-01
%27 = call i32 @floor(float %26)
%28 = load i32, i32* @stdout
%29 = call i32 @putc(i32 %27, i32 %28)
%30 = load float, float* %3
%31 = fmul float %30, 2.550000e+02
%32 = fadd float %31, 5.000000e-01
%33 = call i32 @floor(float %32)
%34 = load i32, i32* @stdout
%35 = call i32 @putc(i32 %33, i32 %34)
%36 = add nuw nsw i32 %13, 1
%37 = icmp eq i32 %36, 512
br i1 %37, label %38, label %12
38: ; preds = %12
%39 = add nuw nsw i32 %8, 1
%40 = icmp eq i32 %39, 512
br i1 %40, label %41, label %7
41: ; preds = %38
ret i32 0
}