// File: /workspace/github_cpp_makefile_star2_O1/dfrodriguezp[P]PiCM-cpp/functions.cc
// Function: fieldNodes(std::vector<std::valarray<double>, std::allocator<std::valarray<double>>> const&, double const&, double const&, unsigned int const&, unsigned int const&)
VecVecArr fieldNodes(const VecArr &phi, const Real &dx, const Real &dy,
                     const Int &Nx, const Int &Ny)
{
    VecVecArr E;
    Array zeros(0.0, 3);
    for (Int i = 0; i < Nx; ++i)
    {
        VecArr rows;
        for (Int j = 0; j < Ny; ++j)
        {
            rows.push_back(zeros);
        }
        E.push_back(rows);
    }

    for (Int j = 0; j < Ny; ++j)
    {
        for (Int i = 0; i < Nx; ++i)
        {
            Int nxt_i = Int(mod(Real(i + 1), Real(Nx)));
            Int prv_i = Int(mod(Real(i - 1), Real(Nx)));
            E[i][j][0] = (phi[prv_i][j] - phi[nxt_i][j]) / (dx * 2.0);
        }
    }

    for (Int i = 0; i < Nx; ++i)
    {
        for (Int j = 0; j < Ny; ++j)
        {
            Int nxt_j = Int(mod(Real(j + 1), Real(Ny)));
            Int prv_j = Int(mod(Real(j - 1), Real(Ny)));

            E[i][j][1] = (phi[i][prv_j] - phi[i][nxt_j]) / (dy * 2.0);
        }
    }

    return E;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rcx, 0x80(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdi, %r13
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq $0x3, 0x70(%rsp)
movl $0x18, %edi
callq 0x3290
movq %rax, 0x78(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rbx, 0x8(%rsp)
cmpl $0x0, (%rbx)
je 0x90a7
xorl %ebx, %ebx
leaq 0x50(%rsp), %r12
leaq 0x70(%rsp), %rbp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
cmpl $0x0, (%r14)
je 0x9089
xorl %r15d, %r15d
movq %r12, %rdi
movq %rbp, %rsi
callq 0x6ec4
incl %r15d
cmpl (%r14), %r15d
jb 0x9076
movq %r13, %rdi
movq %r12, %rsi
callq 0xa260
movq %r12, %rdi
callq 0x6ff6
incl %ebx
movq 0x8(%rsp), %rax
cmpl (%rax), %ebx
jb 0x905a
movq %r13, 0x30(%rsp)
cmpl $0x0, (%r14)
movq %r14, 0x48(%rsp)
je 0x91e9
xorl %r13d, %r13d
leaq 0x50(%rsp), %rbx
leaq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rbp
movq 0x8(%rsp), %rcx
movl (%rcx), %eax
testl %eax, %eax
je 0x91d5
movq %r13, %r9
shlq $0x4, %r9
movq %r9, 0x28(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq 0x1(%r12), %rcx
movq %rcx, 0x40(%rsp)
movl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x50(%rsp)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %rsi, %r14
callq 0x84e9
cvttsd2si %xmm0, %rax
movq %rax, 0x38(%rsp)
decl %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x8(%rsp), %rax
movl (%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x84e9
movq 0x68(%rsp), %rdi
cvttsd2si %xmm0, %rax
movq (%rdi), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq 0x8(%rcx,%rax), %rax
movl 0x38(%rsp), %edx
movsd (%rax,%r13,8), %xmm0
shlq $0x4, %rdx
movq 0x8(%rcx,%rdx), %rax
movq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r14, %rsi
subsd (%rax,%r13,8), %xmm0
movsd (%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movq (%rdx), %rax
movq (%rax,%r15), %rax
movq 0x28(%rsp), %r9
movq 0x8(%rax,%r9), %rax
movsd %xmm0, (%rax)
movl (%rcx), %eax
addq $0x18, %r15
movq 0x40(%rsp), %r9
movq %r9, %r12
cmpq %rax, %r9
jb 0x90ee
incq %r13
movq 0x48(%rsp), %r14
movl (%r14), %eax
cmpq %rax, %r13
jb 0x90cd
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
je 0x933e
movq $0x0, 0x18(%rsp)
leaq 0x50(%rsp), %rbx
leaq 0x10(%rsp), %r13
movq 0x80(%rsp), %rbp
movl (%r14), %eax
testl %eax, %eax
movq 0x30(%rsp), %rdx
je 0x9321
movl $0x8, %r15d
movq 0x18(%rsp), %rcx
movq %rcx, %r8
shlq $0x4, %r8
movq %r8, 0x28(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0x1(%r12), %rcx
movq %rcx, 0x40(%rsp)
movl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x50(%rsp)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rdx, %r14
callq 0x84e9
cvttsd2si %xmm0, %rax
movq %rax, 0x38(%rsp)
decl %r12d
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x48(%rsp), %rax
movl (%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x84e9
movq 0x68(%rsp), %rdi
movq %r14, %rdx
cvttsd2si %xmm0, %rax
movq (%rdi), %rcx
movq 0x28(%rsp), %r8
movq 0x8(%rcx,%r8), %rcx
movl %eax, %eax
movsd (%rcx,%rax,8), %xmm0
movl 0x38(%rsp), %eax
movq 0x48(%rsp), %r14
subsd (%rcx,%rax,8), %xmm0
movsd (%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movq (%rdx), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r15), %rax
movsd %xmm0, 0x8(%rax)
movl (%r14), %eax
addq $0x10, %r15
movq 0x40(%rsp), %rcx
movq %rcx, %r12
cmpq %rax, %rcx
jb 0x9245
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rax
movl (%rax), %eax
movq %rdx, 0x18(%rsp)
cmpq %rax, %rdx
jb 0x9212
movq 0x78(%rsp), %rdi
callq 0x3270
movq 0x30(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x937d
jmp 0x9366
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x6ff6
movq 0x78(%rsp), %rdi
callq 0x3270
movq %r13, %rdi
callq 0x7038
movq %r14, %rdi
callq 0x3460