// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/util.c
// Function: noise
float noise(float x, float y, float z) {
    int X = (int) (floor(x)) & 255,                  // FIND UNIT CUBE THAT
            Y = (int) (floor(y)) & 255,                  // CONTAINS POINT.
            Z = (int) (floor(z)) & 255;
    x -= floor(x);                                // FIND RELATIVE X,Y,Z
    y -= floor(y);                                // OF POINT IN CUBE.
    z -= floor(z);
    float u = fade(x),                                // COMPUTE FADE CURVES
            v = fade(y),                                // FOR EACH OF X,Y,Z.
            w = fade(z);
    int A = p_noise_arr[X] + Y;
    int AA = p_noise_arr[A] + Z;
    int AB = p_noise_arr[A + 1] + Z; // HASH COORDINATES OF
    int B = p_noise_arr[X + 1] + Y;
    int BA = p_noise_arr[B] + Z;
    int BB = p_noise_arr[B + 1] + Z; // THE 8 CUBE CORNERS,

    return lerp(w, lerp(v, lerp(u, grad(p_noise_arr[AA], x, y, z),  // AND ADD
                                grad(p_noise_arr[BA], x - 1, y, z)), // BLENDED
                        lerp(u, grad(p_noise_arr[AB], x, y - 1, z),  // RESULTS
                             grad(p_noise_arr[BB], x - 1, y - 1, z))),// FROM  8
                lerp(v, lerp(u, grad(p_noise_arr[AA + 1], x, y, z - 1),  // CORNERS
                             grad(p_noise_arr[BA + 1], x - 1, y, z - 1)), // OF CUBE
                     lerp(u, grad(p_noise_arr[AB + 1], x, y - 1, z - 1),
                          grad(p_noise_arr[BB + 1], x - 1, y - 1, z - 1))));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movss %xmm2, 0x20(%rsp)
movss %xmm1, 0x10(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x23f0
movsd %xmm0, 0x30(%rsp)
cvttsd2si %xmm0, %r14d
movl $0xff, %ebx
andl %ebx, %r14d
cvtss2sd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x23f0
movsd %xmm0, 0x18(%rsp)
cvttsd2si %xmm0, %r15d
andl %ebx, %r15d
cvtss2sd 0x20(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x23f0
cvttsd2si %xmm0, %eax
movsd 0x8(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm2
movsd 0x10(%rsp), %xmm1
subsd 0x18(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm6
movsd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm5
andl %ebx, %eax
movaps %xmm2, %xmm7
mulss %xmm2, %xmm7
mulss %xmm2, %xmm7
movss 0x8b6b(%rip), %xmm3     # 0x17b90
movaps %xmm2, %xmm4
mulss %xmm3, %xmm4
movss 0x8b60(%rip), %xmm1     # 0x17b94
addss %xmm1, %xmm4
mulss %xmm2, %xmm4
movaps %xmm2, %xmm0
movss %xmm2, 0x30(%rsp)
movss 0x7697(%rip), %xmm2     # 0x166e4
addss %xmm2, %xmm4
mulss %xmm7, %xmm4
movaps %xmm4, 0xb0(%rsp)
movaps %xmm6, %xmm4
mulss %xmm6, %xmm6
mulss %xmm4, %xmm6
movaps %xmm4, %xmm7
mulss %xmm3, %xmm4
addss %xmm1, %xmm4
mulss %xmm7, %xmm4
movss %xmm7, 0x20(%rsp)
addss %xmm2, %xmm4
mulss %xmm6, %xmm4
movaps %xmm4, 0x50(%rsp)
movaps %xmm5, %xmm4
mulss %xmm5, %xmm5
mulss %xmm4, %xmm5
mulss %xmm4, %xmm3
addss %xmm1, %xmm3
mulss %xmm4, %xmm3
movss %xmm4, 0x8(%rsp)
addss %xmm2, %xmm3
mulss %xmm5, %xmm3
movss %xmm3, 0x4c(%rsp)
movq 0x109fc(%rip), %rbx     # 0x1fab8
movslq (%rbx,%r14,4), %rcx
addq %r15, %rcx
movslq (%rbx,%rcx,4), %r13
addq %rax, %r13
movslq 0x4(%rbx,%rcx,4), %r12
addq %rax, %r12
movslq 0x4(%rbx,%r14,4), %rcx
addq %r15, %rcx
movslq (%rbx,%rcx,4), %r15
addq %rax, %r15
movslq 0x4(%rbx,%rcx,4), %r14
addq %rax, %r14
movl (%rbx,%r13,4), %edi
movaps %xmm7, %xmm1
movaps %xmm4, %xmm2
callq 0xf294
movaps %xmm0, 0xa0(%rsp)
movl (%rbx,%r15,4), %edi
movss 0x30(%rsp), %xmm0
addss 0x8a86(%rip), %xmm0     # 0x17b98
movss %xmm0, 0x10(%rsp)
movss 0x20(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps %xmm0, 0x80(%rsp)
movl (%rbx,%r12,4), %edi
movss 0x20(%rsp), %xmm1
addss 0x8a55(%rip), %xmm1     # 0x17b98
movss %xmm1, 0x18(%rsp)
movss 0x30(%rsp), %xmm0
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps %xmm0, 0x90(%rsp)
movl (%rbx,%r14,4), %edi
movss 0x10(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps %xmm0, 0x70(%rsp)
movl 0x4(%rbx,%r13,4), %edi
movss 0x8(%rsp), %xmm2
addss 0x8a03(%rip), %xmm2     # 0x17b98
movss %xmm2, 0x8(%rsp)
movss 0x30(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
callq 0xf294
movaps %xmm0, 0x60(%rsp)
movl 0x4(%rbx,%r15,4), %edi
movss 0x10(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps %xmm0, 0x20(%rsp)
movl 0x4(%rbx,%r12,4), %edi
movss 0x30(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps %xmm0, 0x30(%rsp)
movl 0x4(%rbx,%r14,4), %edi
movss 0x10(%rsp), %xmm0
movss 0x18(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
callq 0xf294
movaps 0x20(%rsp), %xmm2
unpcklps 0x80(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movaps 0x60(%rsp), %xmm1
unpcklps 0xa0(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subps %xmm1, %xmm2
movaps %xmm1, %xmm3
movaps 0xb0(%rsp), %xmm1
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm1, %xmm2
addps %xmm3, %xmm2
unpcklps 0x70(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps 0x30(%rsp), %xmm3
unpcklps 0x90(%rsp), %xmm3       # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subps %xmm3, %xmm0
mulps %xmm1, %xmm0
addps %xmm3, %xmm0
subps %xmm2, %xmm0
movaps 0x50(%rsp), %xmm1
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm1, %xmm0
addps %xmm2, %xmm0
movaps %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm1     # xmm1 = xmm1[1,1],xmm0[1,1]
subss %xmm1, %xmm0
mulss 0x4c(%rsp), %xmm0
addss %xmm1, %xmm0
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq