// File: dfrodriguezp[P]PiCM-cpp/functions.cc
// Function: boris(std::vector<std::valarray<double>, std::allocator<std::valarray<double>>>&, std::vector<double, std::allocator<double>> const&, std::vector<unsigned int, std::allocator<unsigned int>> const&, std::vector<std::valarray<double>, std::allocator<std::valarray<double>>> const&, std::valarray<double> const&, double const&, unsigned int const&)
void boris(VecArr &velocities,
           const std::vector<Real> &QoverM,
           const std::vector<Int> &moves,
           const VecArr &E, const Array &B,
           const Real &dt, const Int &N)
{
    Array t;
    Real t_2;
    Array s;
    Array v_minus;
    Array v_prime;
    Array v_plus;

    for (Int p = 0; p < N; ++p)
    {
        if (moves.at(p))
        {
            t = 0.5 * QoverM.at(p) * B * dt;
            t_2 = norm(t) * norm(t);
            s = (2.0 * t) / (1.0 + t_2);
            v_minus = velocities.at(p) + 0.5 * QoverM.at(p) * E[p] * dt;
            v_prime = v_minus + cross(v_minus, t);
            v_plus = v_minus + cross(v_prime, s);
            velocities.at(p) = v_plus + 0.5 * QoverM.at(p) * E[p] * dt;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11130
leaq -0x58(%rbp), %rdi
callq 0x11130
jmp 0xfdbb
leaq -0x78(%rbp), %rdi
callq 0x11130
jmp 0xfdc6
leaq -0x88(%rbp), %rdi
callq 0x11130
jmp 0xfdd4
leaq -0x98(%rbp), %rdi
callq 0x11130
jmp 0xfde2
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x10303
movq -0x18(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x110d0
movq %rax, -0x1f0(%rbp)
jmp 0xfe18
movq -0x1f0(%rbp), %rax
cmpl $0x0, (%rax)
je 0x102ed
movq -0x10(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x10c40
movq %rax, -0x1f8(%rbp)
jmp 0xfe42
movq -0x1f8(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x41c3(%rip), %xmm1     # 0x14018
mulsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x28(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x111a0
movq %rax, -0x208(%rbp)
movsd %xmm0, -0x200(%rbp)
jmp 0xfe82
movq -0x208(%rbp), %rax
movsd -0x200(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x11150
jmp 0xfeb9
leaq -0x40(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x111f0
jmp 0xfecb
leaq -0x40(%rbp), %rdi
callq 0xd9f0
movsd %xmm0, -0x210(%rbp)
jmp 0xfede
leaq -0x40(%rbp), %rdi
callq 0xd9f0
movsd %xmm0, -0x218(%rbp)
jmp 0xfef1
movsd -0x218(%rbp), %xmm1
movsd -0x210(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x111a0
movq %rax, -0x228(%rbp)
movsd %xmm0, -0x220(%rbp)
jmp 0xff3c
movq -0x228(%rbp), %rax
movsd -0x220(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
movsd -0x48(%rbp), %xmm0
movsd 0x40a9(%rip), %xmm1     # 0x14010
addsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x112f0
jmp 0xff8f
leaq -0x58(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x11340
jmp 0xffa1
movq -0x8(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x7c70
movq %rax, -0x230(%rbp)
jmp 0xffbb
movq -0x10(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x10c40
movq %rax, -0x238(%rbp)
jmp 0xffd5
movq -0x238(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x4030(%rip), %xmm1     # 0x14018
mulsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
movq -0x20(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x10cd0
movq %rax, %rsi
leaq -0x158(%rbp), %rdi
callq 0x111a0
movq %rax, -0x248(%rbp)
movsd %xmm0, -0x240(%rbp)
jmp 0x10025
movq -0x248(%rbp), %rax
movsd -0x240(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movq %rax, -0x148(%rbp)
movq -0x30(%rbp), %rdx
leaq -0x140(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x11150
jmp 0x1005c
movq -0x230(%rbp), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rdx
callq 0x11440
jmp 0x10078
leaq -0x78(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x11490
jmp 0x1008a
leaq -0x178(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x115e0
jmp 0x100a0
leaq -0x78(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x11590
movq %rdx, -0x258(%rbp)
movq %rax, -0x250(%rbp)
jmp 0x100c0
movq -0x258(%rbp), %rax
movq -0x250(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movq %rax, -0x160(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x117e0
jmp 0x100f1
leaq -0x178(%rbp), %rdi
callq 0x7340
leaq -0x198(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x115e0
jmp 0x10116
leaq -0x78(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x11590
movq %rdx, -0x268(%rbp)
movq %rax, -0x260(%rbp)
jmp 0x10136
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
movq %rcx, -0x188(%rbp)
movq %rax, -0x180(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x117e0
jmp 0x10167
leaq -0x198(%rbp), %rdi
callq 0x7340
movq -0x10(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x10c40
movq %rax, -0x270(%rbp)
jmp 0x1018d
movq -0x270(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x3e78(%rip), %xmm1     # 0x14018
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1e8(%rbp)
movq -0x20(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x10cd0
movq %rax, %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x111a0
movq %rax, -0x280(%rbp)
movsd %xmm0, -0x278(%rbp)
jmp 0x101dd
movq -0x280(%rbp), %rax
movsd -0x278(%rbp), %xmm0
movsd %xmm0, -0x1e0(%rbp)
movq %rax, -0x1d8(%rbp)
movq -0x30(%rbp), %rdx
leaq -0x1d0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x11150
jmp 0x10214
leaq -0x1b8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x11440
jmp 0x10230
movq -0x8(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x7c70
movq %rax, -0x288(%rbp)
jmp 0x1024a
movq -0x288(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x11490
jmp 0x1025f
jmp 0x102ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10360
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1034b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1033f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x7340
jmp 0x1033f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x7340
jmp 0x1033f
jmp 0x102ef
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0xfdec
leaq -0x98(%rbp), %rdi
callq 0x7340
leaq -0x88(%rbp), %rdi
callq 0x7340
leaq -0x78(%rbp), %rdi
callq 0x7340
leaq -0x58(%rbp), %rdi
callq 0x7340
leaq -0x40(%rbp), %rdi
callq 0x7340
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x98(%rbp), %rdi
callq 0x7340
leaq -0x88(%rbp), %rdi
callq 0x7340
leaq -0x78(%rbp), %rdi
callq 0x7340
leaq -0x58(%rbp), %rdi
callq 0x7340
leaq -0x40(%rbp), %rdi
callq 0x7340
movq -0x60(%rbp), %rdi
callq 0x3530
nopl (%rax,%rax)