// File: sgielen[P]clife/./xxhash/xxhash.h
// Function: XXH3_generateSecret
XXH_PUBLIC_API XXH_errorcode
XXH3_generateSecret(void* secretBuffer, size_t secretSize, const void* customSeed, size_t customSeedSize)
{
#if (XXH_DEBUGLEVEL >= 1)
    XXH_ASSERT(secretBuffer != NULL);
    XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN);
#else
    /* production mode, assert() are disabled */
    if (secretBuffer == NULL) return XXH_ERROR;
    if (secretSize < XXH3_SECRET_SIZE_MIN) return XXH_ERROR;
#endif

    if (customSeedSize == 0) {
        customSeed = XXH3_kSecret;
        customSeedSize = XXH_SECRET_DEFAULT_SIZE;
    }
#if (XXH_DEBUGLEVEL >= 1)
    XXH_ASSERT(customSeed != NULL);
#else
    if (customSeed == NULL) return XXH_ERROR;
#endif

    /* Fill secretBuffer with a copy of customSeed - repeat as needed */
    {   size_t pos = 0;
        while (pos < secretSize) {
            size_t const toCopy = XXH_MIN((secretSize - pos), customSeedSize);
            memcpy((char*)secretBuffer + pos, customSeed, toCopy);
            pos += toCopy;
    }   }

    {   size_t const nbSeg16 = secretSize / 16;
        size_t n;
        XXH128_canonical_t scrambler;
        XXH128_canonicalFromHash(&scrambler, XXH128(customSeed, customSeedSize, 0));
        for (n=0; n<nbSeg16; n++) {
            XXH128_hash_t const h128 = XXH128(&scrambler, sizeof(scrambler), n);
            XXH3_combine16((char*)secretBuffer + n*16, h128);
        }
        /* last segment */
        XXH3_combine16((char*)secretBuffer + secretSize - 16, XXH128_hashFromCanonical(&scrambler));
    }
    return XXH_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x532e
movl $0x1, -0x4(%rbp)
jmp 0x54c8
cmpq $0x88, -0x18(%rbp)
jae 0x5344
movl $0x1, -0x4(%rbp)
jmp 0x54c8
cmpq $0x0, -0x28(%rbp)
jne 0x535e
leaq 0x5cee(%rip), %rax      # 0xb040
movq %rax, -0x20(%rbp)
movq $0xc0, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5371
movl $0x1, -0x4(%rbp)
jmp 0x54c8
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x53db
movq -0x18(%rbp), %rax
subq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x539e
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0x53ad
movq -0x18(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
addq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x2110
movq -0x38(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x5379
movq -0x18(%rbp), %rax
shrq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4ed0
movq %rax, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x5250
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x547d
movq -0x48(%rbp), %rdx
leaq -0x58(%rbp), %rdi
movl $0x10, %esi
callq 0x4ed0
movq %rax, -0x78(%rbp)
movq %rdx, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
callq 0x54e0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x5419
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
addq $-0x10, %rax
movq %rax, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x52c0
movq -0xa8(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x54e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)