// File: /workspace/github_cpp_makefile_star2_O1/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
movl %r8d, %ebp
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movl %esi, %r14d
movq %rdi, %r12
movl %r9d, %eax
imull 0x100(%rsp), %eax
shll $0x7, %eax
movl %eax, 0x10(%rsp)
movslq %eax, %r13
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rbx
movaps %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x4a2d2
movq (%rbx), %r8
movq %rbp, %rbx
xorl %ebp, %ebp
movq %r12, 0x60(%rsp)
movq %r12, %rdi
movl %r14d, 0x14(%rsp)
movl %r14d, %esi
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %ecx
movl %r13d, %r9d
callq 0x9568
movl 0x100(%rsp), %edx
testl %edx, %edx
jle 0x94fa
movl %r15d, %eax
shll $0x5, %eax
movl %eax, 0x4(%rsp)
movslq %eax, %rcx
movl %ecx, %eax
imull %ebx, %eax
cltq
movq %rax, 0x90(%rsp)
movl %r15d, %eax
shll $0x7, %eax
cmpl $0x2, %eax
movl $0x1, %r13d
movl $0x1, %r12d
cmovgel %eax, %r12d
movl %eax, 0x18(%rsp)
cltq
movq %rax, 0x68(%rsp)
movl %ebx, %eax
movq %rax, 0x70(%rsp)
leal -0x10(%rcx), %eax
cltq
movq %rax, 0x8(%rsp)
leal 0x7ffffff(%rbx), %eax
movl %eax, 0x1c(%rsp)
cmpl $0x2, %ecx
movq %rcx, 0x98(%rsp)
cmovgel %ecx, %r13d
movl %edx, %eax
movq %rax, 0x88(%rsp)
leaq 0x20(%rsp), %r14
xorl %eax, %eax
movq %rbx, 0x80(%rsp)
movq %r12, 0x78(%rsp)
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movl $0x0, 0x30(%rsp)
movq %r14, %rdi
movq 0x98(%rsp), %rsi
xorl %edx, %edx
callq 0x4a048
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x0, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
movq 0x90(%rsp), %rsi
xorl %edx, %edx
callq 0x4a048
movslq %ebp, %rbp
testl %r15d, %r15d
jle 0x93db
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rbp), %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, %r12
jne 0x93ba
movq %rbp, 0xa0(%rsp)
testl %ebx, %ebx
jle 0x948a
xorl %r14d, %r14d
movq 0x70(%rsp), %rbx
movq 0x68(%rsp), %rbp
movl 0x4(%rsp), %r12d
movslq %r14d, %r14
leaq (,%r14,4), %rdi
addq 0x40(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rbp, %rdx
callq 0x4140
movq 0x20(%rsp), %rdi
movl %r15d, %esi
callq 0x47a98
addl %r12d, %r14d
decq %rbx
jne 0x93fd
movq 0x80(%rsp), %rbx
testl %ebx, %ebx
movq 0x78(%rsp), %r12
jle 0x948a
xorl %r14d, %r14d
movq 0x20(%rsp), %rdi
testl %r15d, %r15d
movl 0x4(%rsp), %eax
jle 0x947a
movq 0x8(%rsp), %rcx
movl (%rdi,%rcx,4), %ecx
andl 0x1c(%rsp), %ecx
imull %eax, %ecx
movq 0x40(%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 0x9469
movl %r15d, %esi
callq 0x47a98
incl %r14d
cmpl %ebx, %r14d
jne 0x9443
testl %r15d, %r15d
movq 0xa0(%rsp), %rbp
movq 0x38(%rsp), %r8
jle 0x94c6
movq 0x20(%rsp), %rax
addq %rbp, %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, %r12
jne 0x94a8
leaq 0x40(%rsp), %rdi
callq 0x4a3a0
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x4a3a0
movq 0xa8(%rsp), %rax
incq %rax
addl 0x18(%rsp), %ebp
cmpq 0x88(%rsp), %rax
jne 0x9345
movl 0x110(%rsp), %r9d
movq 0x108(%rsp), %r8
leaq 0xb0(%rsp), %rbx
movq (%rbx), %rdx
movq 0x60(%rsp), %rdi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %ecx
callq 0x9568
movq %rbx, %rdi
callq 0x4a034
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4a3a0
jmp 0x9553
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x4a034
movq %rbx, %rdi
callq 0x4310