// File: /workspace/github_cpp_makefile_star2_O3/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::pbkdf2(char const*, int, char const*, int, int, char*, int)
static void pbkdf2(const char* pw, int pwLen, const char* salt, int saltLen,
                   int c, char* buf, int dkLen) {
  assert(c==1);
  assert(dkLen%32==0);
  assert(pwLen<=64);

  libzpaq::SHA256 sha256;
  char b[32];
  for (int i=1; i*32<=dkLen; ++i) {
    for (int j=0; j<pwLen; ++j) sha256.put(pw[j]^0x36);
    for (int j=pwLen; j<64; ++j) sha256.put(0x36);
    for (int j=0; j<saltLen; ++j) sha256.put(salt[j]);
    for (int j=24; j>=0; j-=8) sha256.put(i>>j);
    memcpy(b, sha256.result(), 32);
    for (int j=0; j<pwLen; ++j) sha256.put(pw[j]^0x5c);
    for (int j=pwLen; j<64; ++j) sha256.put(0x5c);
    for (int j=0; j<32; ++j) sha256.put(b[j]);
    memcpy(buf+i*32-32, sha256.result(), 32);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %r8, 0x18(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdx, 0x38(%rsp)
movaps 0x2bcf4(%rip), %xmm0    # 0x35290
movaps %xmm0, 0x60(%rsp)
movaps 0x2bcf8(%rip), %xmm0    # 0x352a0
movaps %xmm0, 0x70(%rsp)
movabsq $0x5be0cd191f83d9ab, %rax # imm = 0x5BE0CD191F83D9AB
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rsp)
movups %xmm0, 0x98(%rsp)
movups %xmm0, 0xa8(%rsp)
movups %xmm0, 0xb8(%rsp)
movl %r9d, 0x10(%rsp)
cmpl $0x20, %r9d
jl 0x9761
movl %esi, %r12d
movq %rdi, %r13
addq $-0x20, 0x18(%rsp)
movl %esi, %r14d
movl 0xc(%rsp), %eax
movq %rax, 0x28(%rsp)
leal -0x40(%r12), %eax
movl %eax, 0x8(%rsp)
movl $0x20, %eax
movl $0x1, %r15d
leaq 0x60(%rsp), %rbp
movq %r12, 0x30(%rsp)
movq %rdi, 0x20(%rsp)
movl %eax, 0x14(%rsp)
movl 0x8(%rsp), %ebx
testl %r12d, %r12d
jle 0x965e
xorl %ebx, %ebx
movsbl (%r13,%rbx), %esi
xorl $0x36, %esi
movq %rbp, %rdi
callq 0x33742
incq %rbx
cmpq %rbx, %r14
jne 0x963b
movl 0x8(%rsp), %ebx
cmpl $0x3f, %r12d
jg 0x966f
movq %rbp, %rdi
movl $0x36, %esi
callq 0x33742
incl %ebx
jne 0x965e
cmpl $0x0, 0xc(%rsp)
movq 0x38(%rsp), %r12
movq 0x28(%rsp), %r13
jle 0x9697
xorl %ebx, %ebx
movsbl (%r12,%rbx), %esi
movq %rbp, %rdi
callq 0x33742
incq %rbx
cmpq %rbx, %r13
jne 0x9682
movl $0x18, %ebx
movl %r15d, %esi
movl %ebx, %ecx
shrl %cl, %esi
movq %rbp, %rdi
callq 0x33742
addl $-0x8, %ebx
cmpl $-0x8, %ebx
jne 0x969c
movq %rbp, %rdi
callq 0x8848
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x40(%rsp)
movaps %xmm1, 0x50(%rsp)
movl 0x8(%rsp), %ebx
movq 0x30(%rsp), %r12
testl %r12d, %r12d
movq 0x20(%rsp), %r13
jle 0x9704
xorl %ebx, %ebx
movsbl (%r13,%rbx), %esi
xorl $0x5c, %esi
movq %rbp, %rdi
callq 0x33742
incq %rbx
cmpq %rbx, %r14
jne 0x96e1
movl 0x8(%rsp), %ebx
cmpl $0x3f, %r12d
jg 0x9715
movq %rbp, %rdi
movl $0x5c, %esi
callq 0x33742
incl %ebx
jne 0x9704
xorl %ebx, %ebx
movsbl 0x40(%rsp,%rbx), %esi
movq %rbp, %rdi
callq 0x33742
incq %rbx
cmpq $0x20, %rbx
jne 0x9717
movl 0x14(%rsp), %ebx
movq %rbp, %rdi
callq 0x8848
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movq 0x18(%rsp), %rax
movups %xmm0, (%rax,%rbx)
movups %xmm1, 0x10(%rax,%rbx)
incq %r15
movl %r15d, %eax
shll $0x5, %eax
cmpl 0x10(%rsp), %eax
jle 0x962c
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq