// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]plasma/src/palette_plasma.c
// Function: InitPlasma
void InitPlasma(void) {
    double halfWidth = width / 2.0;
    double halfHeight = height / 2.0;

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            double color = 128.0 + (128.0 * sin(x / 16.0));
            color += 128.0 + (128.0 * sin(y / 8.0));
            color += 128.0 + (128.0 * sin((x + y) / 16.0));
            color += 128.0 +
                     (128.0 *
                      sin(sqrt((double)((x - halfWidth) * (x - halfWidth) +
                                        (y - halfHeight) * (y - halfHeight))) /
                          8.0));
            // Uncomment for some weird shit
            // color += 128.0 + (128.0 * sin((x * y) / 128.0));
            color += 128.0 + (128.0 * sin(sqrt((double)(x * x + y * y)) / 8.0));

            int index = Get1DArrayIndex(x, y, width);
            plasmaBuffer[index] = (Uint32)color / 8;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
cvtsi2sdl 0x29a8(%rip), %xmm0 # 0x4128
movsd 0x8d8(%rip), %xmm1      # 0x2060
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
cvtsi2sdl 0x2993(%rip), %xmm0 # 0x412c
movsd 0x8bf(%rip), %xmm1      # 0x2060
divsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x2972(%rip), %eax      # 0x412c
jge 0x1963
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x2958(%rip), %eax      # 0x4128
jge 0x1953
cvtsi2sdl -0x18(%rbp), %xmm0
movsd 0x885(%rip), %xmm1      # 0x2068
movsd %xmm1, -0x40(%rbp)
mulsd %xmm1, %xmm0
callq 0x1090
movsd 0x84f(%rip), %xmm1      # 0x2048
movsd %xmm1, -0x30(%rbp)
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x858(%rip), %xmm1      # 0x2070
movsd %xmm1, -0x38(%rbp)
mulsd %xmm1, %xmm0
callq 0x1090
movsd -0x40(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm2
addsd %xmm0, %xmm2
movsd -0x20(%rbp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd %xmm1, %xmm0
callq 0x1090
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
cvtsi2sdl -0x18(%rbp), %xmm0
movsd -0x8(%rbp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
movsd -0x10(%rbp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x1130
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x1090
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x18(%rbp), %eax
imull %eax, %eax
movl -0x14(%rbp), %ecx
imull %ecx, %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
callq 0x1130
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x1090
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x18(%rbp), %edi
movl -0x14(%rbp), %esi
movl 0x2804(%rip), %edx      # 0x4128
callq 0x1370
movl %eax, -0x24(%rbp)
cvttsd2si -0x20(%rbp), %rax
movl %eax, %edx
shrl $0x3, %edx
movq 0x2822(%rip), %rax      # 0x4160
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x17c7
jmp 0x1955
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x17b1
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)