// File: /workspace/github_cpp_makefile_star2_O3/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::scrypt(char const*, int, char const*, int, int, int, int, char*, int)
void scrypt(const char* pw, int pwlen,
            const char* salt, int saltlen,
            int n, int r, int p, char* buf, int buflen) {
  assert(r<=8);
  assert(n>0 && (n&(n-1))==0);  // power of 2?
  libzpaq::Array<char> b(p*r*128);
  pbkdf2(pw, pwlen, salt, saltlen, 1, &b[0], p*r*128);
  for (int i=0; i<p; ++i) smix(&b[i*r*128], r, n);
  pbkdf2(pw, pwlen, &b[0], p*r*128, 1, buf, buflen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %r9d, %r15d
movq %r8, 0x10(%rsp)
movl %ecx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, %ebx
movq %rdi, %rbp
movl 0x100(%rsp), %r12d
movl %r9d, %eax
shll $0x7, %eax
movl %eax, 0xc(%rsp)
imull %r12d, %eax
movl %eax, 0x28(%rsp)
movslq %eax, %r13
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %r14
movaps %xmm0, (%r14)
movl $0x0, 0x10(%r14)
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x33a16
movq (%r14), %r8
xorl %r14d, %r14d
movq %rbp, 0x68(%rsp)
movq %rbp, %rdi
movl %ebx, 0x2c(%rsp)
movl %ebx, %esi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movl %r13d, %r9d
callq 0x9576
testl %r12d, %r12d
jle 0x9508
movl %r15d, %ebp
shll $0x5, %ebp
movslq %ebp, %rdx
movl %edx, %eax
movq 0x10(%rsp), %rcx
imull %ecx, %eax
cltq
movq %rax, 0x90(%rsp)
movl 0xc(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r13d
movl $0x1, %ebx
cmovgel %eax, %ebx
cltq
movq %rax, 0x80(%rsp)
movl %ecx, %eax
movq %rax, 0x70(%rsp)
leal -0x10(%rdx), %eax
cltq
movq %rax, 0x20(%rsp)
leal 0x7ffffff(%rcx), %eax
movl %eax, 0x18(%rsp)
cmpl $0x2, %edx
movq %rdx, 0x98(%rsp)
cmovgel %edx, %r13d
movl %r12d, %eax
movq %rax, 0x88(%rsp)
leaq 0x30(%rsp), %r12
xorl %eax, %eax
movq %rbx, 0x78(%rsp)
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movl $0x0, 0x40(%rsp)
movq %r12, %rdi
movq 0x98(%rsp), %rsi
xorl %edx, %edx
callq 0x3378c
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movl $0x0, 0x60(%rsp)
leaq 0x50(%rsp), %rdi
movq 0x90(%rsp), %rsi
xorl %edx, %edx
callq 0x3378c
movq 0x10(%rsp), %r9
movslq %r14d, %r14
testl %r15d, %r15d
jle 0x93f0
movq 0x30(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%r14), %rdx
xorl %esi, %esi
xorl %edi, %edi
movzbl (%rdx,%rdi), %r8d
movl %esi, %ecx
andb $0x18, %cl
shll %cl, %r8d
movl %edi, %ecx
andl $-0x4, %ecx
addl %r8d, (%rax,%rcx)
incq %rdi
addl $0x8, %esi
cmpq %rdi, %rbx
jne 0x93cf
movq %r14, 0xa0(%rsp)
testl %r9d, %r9d
jle 0x9497
xorl %r14d, %r14d
movq 0x70(%rsp), %r12
movl %ebp, %ebx
movq 0x80(%rsp), %rbp
movslq %r14d, %r14
leaq (,%r14,4), %rdi
addq 0x50(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rbp, %rdx
callq 0x4140
movq 0x30(%rsp), %rdi
movl %r15d, %esi
callq 0x31051
addl %ebx, %r14d
decq %r12
jne 0x9413
xorl %r14d, %r14d
movq 0x10(%rsp), %r12
movl %ebx, %ebp
movq 0x78(%rsp), %rbx
movq 0x30(%rsp), %rdi
testl %r15d, %r15d
jle 0x9487
movq 0x20(%rsp), %rax
movl (%rdi,%rax,4), %ecx
andl 0x18(%rsp), %ecx
imull %ebp, %ecx
movq 0x50(%rsp), %rax
movl %ecx, %ecx
xorl %edx, %edx
leal (%rcx,%rdx), %esi
movl (%rax,%rsi,4), %esi
xorl %esi, (%rdi,%rdx,4)
incq %rdx
cmpq %rdx, %r13
jne 0x9476
movl %r15d, %esi
callq 0x31051
incl %r14d
cmpl %r12d, %r14d
jne 0x9454
testl %r15d, %r15d
movq 0xa0(%rsp), %r14
movq 0x48(%rsp), %r8
jle 0x94d3
movq 0x30(%rsp), %rax
addq %r14, %r8
xorl %edx, %edx
xorl %esi, %esi
movl %esi, %ecx
andl $-0x4, %ecx
movl (%rax,%rcx), %edi
movl %edx, %ecx
andb $0x18, %cl
shrl %cl, %edi
movb %dil, (%r8,%rsi)
incq %rsi
addl $0x8, %edx
cmpq %rsi, %rbx
jne 0x94b5
leaq 0x50(%rsp), %rdi
callq 0x33ae4
leaq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0x33ae4
movq 0xa8(%rsp), %rax
incq %rax
addl 0xc(%rsp), %r14d
cmpq 0x88(%rsp), %rax
jne 0x9355
movl 0x110(%rsp), %r9d
movq 0x108(%rsp), %r8
leaq 0xb0(%rsp), %rbx
movq (%rbx), %rdx
movq 0x68(%rsp), %rdi
movl 0x2c(%rsp), %esi
movl 0x28(%rsp), %ecx
callq 0x9576
movq %rbx, %rdi
callq 0x33778
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x33ae4
jmp 0x9561
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x33778
movq %rbx, %rdi
callq 0x4310