// File: /workspace/github_c_makefile_star2_O0/LoupVaillant[P]Monocypher-Utils/src/monocypher.c
// Function: ge_double_scalarmult_vartime
static void ge_double_scalarmult_vartime(ge *sum, const ge *P,
                                         u8 p[32], u8 b[32])
{
    static const fe X = { -14297830, -7645148, 16144683, -16471763, 27570974,
                          -2696100, -26142465, 8378389, 20764389, 8758491 };
    static const fe Y = { -26843541, -6710886, 13421773, -13421773, 26843546,
                          6710886, -13421773, 13421773, -26843546, -6710886 };
    ge B;
    fe_copy(B.X, X);
    fe_copy(B.Y, Y);
    fe_1   (B.Z);
    fe_mul (B.T, X, Y);

    // cached points for addition
    ge_cached cP[8];  ge_precompute(cP,  P);
    ge_cached cB[8];  ge_precompute(cB, &B);
    i8 p_adds[258];   slide(p_adds, p);
    i8 b_adds[258];   slide(b_adds, b);

    // Avoid the first doublings
    int i = 253;
    while (i >= 0         &&
           p_adds[i] == 0 &&
           b_adds[i] == 0) {
        i--;
    }

    // Merged double and add ladder
    ge_zero(sum);
    LUT_ADD(sum, cP, p_adds, i);
    LUT_ADD(sum, cB, b_adds, i);
    i--;
    while (i >= 0) {
        ge_double(sum, sum, &B); // B is no longer used, we can overwrite it
        LUT_ADD(sum, cP, p_adds, i);
        LUT_ADD(sum, cB, b_adds, i);
        i--;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xcf0, %rsp            # imm = 0xCF0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0xc0(%rbp), %rdi
leaq 0x7537(%rip), %rsi      # 0x13010
callq 0x8fe0
leaq -0xc0(%rbp), %rdi
addq $0x28, %rdi
leaq 0x7550(%rip), %rsi      # 0x13040
callq 0x8fe0
leaq -0xc0(%rbp), %rdi
addq $0x50, %rdi
callq 0x8f60
leaq -0xc0(%rbp), %rdi
addq $0x78, %rdi
leaq 0x74f9(%rip), %rsi      # 0x13010
leaq 0x7522(%rip), %rdx      # 0x13040
callq 0x9180
leaq -0x5c0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x103a0
leaq -0xac0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x103a0
leaq -0xbd0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x10460
leaq -0xce0(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x10460
movl $0xfd, -0xce4(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xce4(%rbp)
movb %al, -0xce5(%rbp)
jl 0xbbb8
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xce5(%rbp)
jne 0xbbb8
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0xce5(%rbp)
movb -0xce5(%rbp), %al
testb $0x1, %al
jne 0xbbc4
jmp 0xbbd5
movl -0xce4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xce4(%rbp)
jmp 0xbb70
movq -0x8(%rbp), %rdi
callq 0xf980
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
cmpl $0x0, %eax
jle 0xbc29
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0x5c0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x105e0
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
cmpl $0x0, %eax
jge 0xbc78
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0x5c0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x10760
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
cmpl $0x0, %eax
jle 0xbcc3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0xac0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x105e0
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
cmpl $0x0, %eax
jge 0xbd12
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0xac0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x10760
movl -0xce4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xce4(%rbp)
cmpl $0x0, -0xce4(%rbp)
jl 0xbe8a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0xf9d0
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
cmpl $0x0, %eax
jle 0xbd8d
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0x5c0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x105e0
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %eax
cmpl $0x0, %eax
jge 0xbddc
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xbd0(%rbp,%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0x5c0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x10760
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
cmpl $0x0, %eax
jle 0xbe27
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0xac0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x105e0
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %eax
cmpl $0x0, %eax
jge 0xbe76
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0xce4(%rbp), %rax
movsbl -0xce0(%rbp,%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cltq
leaq -0xac0(%rbp), %rdx
imulq $0xa0, %rax, %rax
addq %rax, %rdx
callq 0x10760
movl -0xce4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xce4(%rbp)
jmp 0xbd21
addq $0xcf0, %rsp            # imm = 0xCF0
popq %rbp
retq
nopw %cs:(%rax,%rax)