// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
movl %r9d, %r15d
movl %r8d, 0x4(%rsp)
movl %ecx, (%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, %ebx
movq %rdi, %rbp
movl 0xe0(%rsp), %r12d
movl %r9d, %r13d
shll $0x7, %r13d
movl %r13d, %eax
imull %r12d, %eax
movl %eax, 0x18(%rsp)
movslq %eax, %r14
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1c380
leaq 0x78(%rsp), %rax
movq (%rax), %r8
movq %rbp, 0x38(%rsp)
movq %rbp, %rdi
movl %ebx, 0x1c(%rsp)
movl %ebx, %esi
movl 0x4(%rsp), %ebx
movq 0x10(%rsp), %rdx
movl (%rsp), %ecx
movl %r14d, %r9d
callq 0x91a3
movl %r15d, (%rsp)
shll $0x5, %r15d
movslq %r15d, %rcx
movl %ecx, %eax
imull %ebx, %eax
cltq
movq %rax, 0x48(%rsp)
testl %r13d, %r13d
movl $0x0, %ebp
cmovgl %r13d, %ebp
movq %r13, 0x40(%rsp)
movslq %r13d, %rax
movq %rax, 0x70(%rsp)
testl %ebx, %ebx
movl $0x0, %eax
cmovgl %ebx, %eax
movq %rax, 0x10(%rsp)
addl $0x7ffffff, %ebx        # imm = 0x7FFFFFF
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
movq %rcx, 0x50(%rsp)
leal -0x10(%rcx), %eax
testl %r12d, %r12d
movl $0x0, %ecx
movq %rcx, 0x8(%rsp)
movl $0x0, %ecx
cmovlel %ecx, %r12d
movq %r12, 0x58(%rsp)
cltq
movq %rax, 0x68(%rsp)
leaq 0x20(%rsp), %r14
xorl %ecx, %ecx
movl %ebx, 0x4(%rsp)
cmpq 0x58(%rsp), %rcx
je 0x913b
movq %rcx, 0x60(%rsp)
movq 0x78(%rsp), %r12
movq %r14, %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq 0x1c600
leaq 0x90(%rsp), %rdi
movq 0x48(%rsp), %rsi
xorl %edx, %edx
callq 0x1c600
movslq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rsp)
addq %rcx, %r12
xorl %edx, %edx
xorl %esi, %esi
cmpq %rsi, %rbp
je 0x9052
movzbl (%r12,%rsi), %edi
movl %edx, %ecx
andb $0x18, %cl
shll %cl, %edi
movl %esi, %ecx
andl $-0x4, %ecx
addl %edi, (%rax,%rcx)
incq %rsi
addl $0x8, %edx
jmp 0x9031
xorl %r14d, %r14d
movq 0x10(%rsp), %rbx
subq $0x1, %rbx
jb 0x9094
movslq %r14d, %r14
leaq (,%r14,4), %rdi
addq 0x90(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x4140
movq 0x20(%rsp), %rdi
movl (%rsp), %esi
callq 0x1a5f4
addl %r15d, %r14d
jmp 0x905a
xorl %r14d, %r14d
movl 0x4(%rsp), %ebx
movq 0x20(%rsp), %rdi
cmpl 0x10(%rsp), %r14d
je 0x90df
movq 0x68(%rsp), %rax
movl (%rdi,%rax,4), %eax
andl %ebx, %eax
imull %r15d, %eax
movq 0x90(%rsp), %rcx
xorl %edx, %edx
cmpq %rdx, %r13
je 0x90d2
leal (%rax,%rdx), %esi
movl (%rcx,%rsi,4), %esi
xorl %esi, (%rdi,%rdx,4)
incq %rdx
jmp 0x90bf
movl (%rsp), %esi
callq 0x1a5f4
incl %r14d
jmp 0x909b
xorl %eax, %eax
xorl %edx, %edx
leaq 0x20(%rsp), %r14
cmpq %rdx, %rbp
je 0x9108
movl %edx, %ecx
andl $-0x4, %ecx
movl (%rdi,%rcx), %esi
movl %eax, %ecx
andb $0x18, %cl
shrl %cl, %esi
movb %sil, (%r12,%rdx)
incq %rdx
addl $0x8, %eax
jmp 0x90e8
leaq 0x90(%rsp), %rdi
callq 0x1c6ca
movq %r14, %rdi
callq 0x1c6ca
movq 0x60(%rsp), %rcx
incq %rcx
movq 0x40(%rsp), %rax
movq 0x8(%rsp), %rdx
addl %edx, %eax
movq %rax, 0x8(%rsp)
jmp 0x8fe3
leaq 0x78(%rsp), %rbx
movq (%rbx), %rdx
movq 0x38(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %ecx
movq 0xe8(%rsp), %r8
movl 0xf0(%rsp), %r9d
callq 0x91a3
movq %rbx, %rdi
callq 0x1c390
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x9191
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x1c6ca
leaq 0x78(%rsp), %rdi
callq 0x1c390
movq %rbx, %rdi
callq 0x4320