// File: /workspace/github_cpp_makefile_star2_O3/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), %esi
testl %esi, %esi
js 0x984a
movl %esi, %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ecx
movl %esi, %ebx
andl $0x7, %ebx
xorl %r11d, %r11d
btl %ebx, %ecx
setb %r11b
jmp 0x9869
xorl %r11d, %r11d
cmpl $-0x20, %esi
jae 0x9869
xorl %r11d, %r11d
cmpl $-0x40, %esi
jae 0x9882
xorl %r11d, %r11d
movl $0x0, %ecx
cmpl $-0x60, %esi
jae 0x989b
jmp 0x98b2
leal 0x20(%rsi), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ebx
movl %esi, %ecx
andb $0x7, %cl
shrl %cl, %ebx
andl $0x1, %ebx
leal (%r11,%rbx,2), %r11d
leal 0x40(%rsi), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %ebx
movl %esi, %ecx
andb $0x7, %cl
shrl %cl, %ebx
andl $0x1, %ebx
leal (%r11,%rbx,4), %r11d
leal 0x60(%rsi), %ecx
shrl $0x3, %ecx
movzbl (%r9,%rcx), %r9d
andl $0x7, %esi
xorl %ecx, %ecx
btl %esi, %r9d
setb %cl
decl %ecx
movl %ecx, %esi
andl $0x7, %esi
xorl %r11d, %esi
xorl %r9d, %r9d
movl %esi, %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 0x98d6
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 0x98f8
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 0x991a
incq %r9
addq $0x78, %r8
cmpq $0x8, %r9
jne 0x98bf
xorl %esi, %esi
xorl %r8d, %r8d
subl 0x50(%rdx,%rsi,4), %r8d
movl %r8d, (%rax,%rsi,4)
incq %rsi
cmpq $0xa, %rsi
jne 0x994a
xorl %esi, %esi
movl 0x50(%rdx,%rsi,4), %r8d
movl (%rax,%rsi,4), %r9d
xorl %r8d, %r9d
andl %ecx, %r9d
xorl %r9d, %r8d
movl %r8d, 0x50(%rdx,%rsi,4)
xorl %r9d, (%rax,%rsi,4)
incq %rsi
cmpq $0xa, %rsi
jne 0x9961
xorl %esi, %esi
movl (%rdx,%rsi,4), %r8d
movl 0x28(%rdx,%rsi,4), %r9d
movl %r9d, %r11d
xorl %r8d, %r11d
andl %ecx, %r11d
xorl %r11d, %r8d
movl %r8d, (%rdx,%rsi,4)
xorl %r9d, %r11d
movl %r11d, 0x28(%rdx,%rsi,4)
incq %rsi
cmpq $0xa, %rsi
jne 0x9987
movq %rdi, %rsi
movq %rax, %rcx
movq %r10, %r8
popq %rbx
popq %r14
popq %rbp
jmp 0x7d29