// File: /workspace/github_c_makefile_star2_O0/Seclabs-htc[P]slip39/gf256.c
// Function: shamir_interpolate
bool shamir_interpolate(uint8_t *result, uint8_t x,
                        const uint8_t *share_indices,
                        const uint8_t **share_values, uint8_t share_count,
                        size_t len)
{
    size_t i, j;

    if (len > SHAMIR_MAX_LEN)
        return false;

    for (i = 0; i < share_count; i++)
        for (j = 0; j < share_count; j++)
            if ((i != j) && (share_indices[i] == share_indices[j]))
                return false;

    for (i = 0; i < share_count; i++)
        if (x == share_indices[i])
        {
            memcpy(result, share_values[i], len);
            return true;
        }

    memzero(result, len);
    for (i = 0; i < share_count; i++)
    {
        uint8_t t;
        uint32_t d;

        d = 0;
        for (j = 0; j < share_count; j++)
        if (i != j)
        {
            d += LOG_TABLE[x ^ share_indices[j]];
            d += 255 - LOG_TABLE[share_indices[i] ^ share_indices[j]];
            d %= 255;
        }

        for (j = 0; j < len; j++)
        {
            t = share_values[i][j];
            result[j] ^= t ? EXP_TABLE[(LOG_TABLE[t] + d) % 255] : 0;
        }
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movb %sil, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movb %al, -0x29(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x20, -0x38(%rbp)
jbe 0xdd52
movb $0x0, -0x1(%rbp)
jmp 0xdf98
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
jae 0xddcb
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
jae 0xddbb
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xddab
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xddab
movb $0x0, -0x1(%rbp)
jmp 0xdf98
jmp 0xddad
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xdd6f
jmp 0xddbd
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xdd5a
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
jae 0xde26
movzbl -0x11(%rbp), %eax
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xde16
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x38(%rbp), %rdx
callq 0x8090
movb $0x1, -0x1(%rbp)
jmp 0xdf98
jmp 0xde18
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xddd3
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x81c0
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
jae 0xdf94
movl $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movzbl -0x29(%rbp), %ecx
cmpq %rcx, %rax
jae 0xdef3
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xdee0
movzbl -0x11(%rbp), %eax
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
movslq %eax, %rcx
leaq 0xa21e(%rip), %rax      # 0x180b0
movzbl (%rax,%rcx), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
movslq %eax, %rcx
leaq 0xa1f0(%rip), %rax      # 0x180b0
movzbl (%rax,%rcx), %ecx
movl $0xff, %eax
subl %ecx, %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl $0xff, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, -0x50(%rbp)
jmp 0xdee2
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xde5b
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0xdf81
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x48(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movzbl -0x49(%rbp), %eax
cmpl $0x0, %eax
je 0xdf55
movzbl -0x49(%rbp), %eax
movl %eax, %ecx
leaq 0xa17f(%rip), %rax      # 0x180b0
movzbl (%rax,%rcx), %eax
addl -0x50(%rbp), %eax
movl $0xff, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movl %eax, %ecx
leaq 0xa264(%rip), %rax      # 0x181b0
movzbl (%rax,%rcx), %eax
movl %eax, -0x54(%rbp)
jmp 0xdf5c
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0xdf5c
movl -0x54(%rbp), %esi
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xdefb
jmp 0xdf83
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xde3b
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)