// File: /workspace/github_cpp_makefile_star2_O1/occivink[P]pyct/monocypher.cpp
// Function: lookup_add(ge*, ge_precomp*, int*, int*, ge_precomp const*, unsigned char const*, int)
static void lookup_add(ge *p, ge_precomp *tmp_c, fe tmp_a, fe tmp_b,
                       const ge_precomp comb[8], const u8 scalar[32], int i)
{
    u8 teeth = (u8)((scalar_bit(scalar, i)          ) +
                    (scalar_bit(scalar, i + 32) << 1) +
                    (scalar_bit(scalar, i + 64) << 2) +
                    (scalar_bit(scalar, i + 96) << 3));
    u8 high  = teeth >> 3;
    u8 index = (teeth ^ (high - 1)) & 7;
    FOR (j, 0, 8) {
        i32 select = 1 & (((j ^ index) - 1) >> 8);
        fe_ccopy(tmp_c->Yp, comb[j].Yp, select);
        fe_ccopy(tmp_c->Ym, comb[j].Ym, select);
        fe_ccopy(tmp_c->T2, comb[j].T2, select);
    }
    fe_neg(tmp_a, tmp_c->T2);
    fe_cswap(tmp_c->T2, tmp_a    , high ^ 1);
    fe_cswap(tmp_c->Yp, tmp_c->Ym, high ^ 1);
    ge_madd(p, p, tmp_c, tmp_a, tmp_b);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rcx, %r10
movq %rdx, %rax
movq %rsi, %rdx
movl 0x20(%rsp), %ebx
xorl %r11d, %r11d
movl $0x0, %esi
testl %ebx, %ebx
js 0x966a
movl %ebx, %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ecx
movl %ebx, %ebp
andl $0x7, %ebp
xorl %esi, %esi
btl %ebp, %ecx
setb %sil
cmpl $-0x20, %ebx
jl 0x9689
leal 0x20(%rbx), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %r11d
movl %ebx, %ecx
andb $0x7, %cl
shrl %cl, %r11d
addl %r11d, %r11d
andl $0x2, %r11d
orl %esi, %r11d
xorl %esi, %esi
movl $0x0, %ebp
cmpl $-0x40, %ebx
jl 0x96b0
leal 0x40(%rbx), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ebp
movl %ebx, %ecx
andb $0x7, %cl
shrl %cl, %ebp
shll $0x2, %ebp
andl $0x4, %ebp
orl %ebp, %r11d
cmpl $-0x60, %ebx
jl 0x96cf
leal 0x60(%rbx), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ecx
andl $0x7, %ebx
xorl %esi, %esi
btl %ebx, %ecx
setb %sil
decl %esi
movl %esi, %ecx
andl $0x7, %ecx
xorl %r11d, %ecx
xorl %r9d, %r9d
movl %ecx, %r11d
xorl %r9d, %r11d
shll $0x17, %r11d
addl $0xff800000, %r11d      # imm = 0xFF800000
sarl $0x1f, %r11d
xorl %ebx, %ebx
movl (%rdx,%rbx,4), %ebp
movl (%r8,%rbx,4), %r14d
xorl %ebp, %r14d
andl %r11d, %r14d
xorl %ebp, %r14d
movl %r14d, (%rdx,%rbx,4)
incq %rbx
cmpq $0xa, %rbx
jne 0x96f3
movl $0xa, %ebx
movl (%rdx,%rbx,4), %ebp
movl (%r8,%rbx,4), %r14d
xorl %ebp, %r14d
andl %r11d, %r14d
xorl %ebp, %r14d
movl %r14d, (%rdx,%rbx,4)
incq %rbx
cmpq $0x14, %rbx
jne 0x9715
movl $0x14, %ebx
movl (%rdx,%rbx,4), %ebp
movl (%r8,%rbx,4), %r14d
xorl %ebp, %r14d
andl %r11d, %r14d
xorl %ebp, %r14d
movl %r14d, (%rdx,%rbx,4)
incq %rbx
cmpq $0x1e, %rbx
jne 0x9737
incq %r9
addq $0x78, %r8
cmpq $0x8, %r9
jne 0x96dc
xorl %ecx, %ecx
xorl %r8d, %r8d
subl 0x50(%rdx,%rcx,4), %r8d
movl %r8d, (%rax,%rcx,4)
incq %rcx
cmpq $0xa, %rcx
jne 0x9767
xorl %ecx, %ecx
movl 0x50(%rdx,%rcx,4), %r8d
movl (%rax,%rcx,4), %r9d
xorl %r8d, %r9d
andl %esi, %r9d
xorl %r9d, %r8d
movl %r8d, 0x50(%rdx,%rcx,4)
xorl %r9d, (%rax,%rcx,4)
incq %rcx
cmpq $0xa, %rcx
jne 0x977e
xorl %ecx, %ecx
movl (%rdx,%rcx,4), %r8d
movl 0x28(%rdx,%rcx,4), %r9d
movl %r9d, %r11d
xorl %r8d, %r11d
andl %esi, %r11d
xorl %r11d, %r8d
movl %r8d, (%rdx,%rcx,4)
xorl %r9d, %r11d
movl %r11d, 0x28(%rdx,%rcx,4)
incq %rcx
cmpq $0xa, %rcx
jne 0x97a4
movq %rdi, %rsi
movq %rax, %rcx
movq %r10, %r8
popq %rbx
popq %r14
popq %rbp
jmp 0x7b57