// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %rdx, 0x38(%rsp)
movaps 0x41d02(%rip), %xmm0    # 0x4b290
movups %xmm0, 0x60(%rsp)
movaps 0x41d06(%rip), %xmm0    # 0x4b2a0
movups %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 0x974b
movl %esi, %r12d
movq %rdi, %r13
addq $-0x20, 0x18(%rsp)
movl %esi, %r14d
movl 0x8(%rsp), %eax
movq %rax, 0x28(%rsp)
leal -0x40(%r12), %eax
movl %eax, 0xc(%rsp)
movl $0x20, %eax
movl $0x1, %r15d
leaq 0x60(%rsp), %rbp
movq %r12, 0x30(%rsp)
movq %rdi, 0x20(%rsp)
movl %eax, 0x14(%rsp)
testl %r12d, %r12d
jle 0x9642
xorl %ebx, %ebx
movsbl (%r13,%rbx), %esi
xorl $0x36, %esi
movq %rbp, %rdi
callq 0x4a002
incq %rbx
cmpq %rbx, %r14
jne 0x9629
movl 0xc(%rsp), %ebx
cmpl $0x3f, %r12d
jg 0x965d
movq %rbp, %rdi
movl $0x36, %esi
callq 0x4a002
incl %ebx
jne 0x964c
cmpl $0x0, 0x8(%rsp)
movq 0x38(%rsp), %r12
movq 0x28(%rsp), %r13
jle 0x9685
xorl %ebx, %ebx
movsbl (%r12,%rbx), %esi
movq %rbp, %rdi
callq 0x4a002
incq %rbx
cmpq %rbx, %r13
jne 0x9670
movl $0x18, %ebx
movq 0x20(%rsp), %r13
movl %r15d, %esi
movl %ebx, %ecx
shrl %cl, %esi
movq %rbp, %rdi
callq 0x4a002
addl $-0x8, %ebx
cmpl $-0x8, %ebx
jne 0x968f
movq %rbp, %rdi
callq 0x8882
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x40(%rsp)
movaps %xmm1, 0x50(%rsp)
movq 0x30(%rsp), %r12
testl %r12d, %r12d
jle 0x96e4
xorl %ebx, %ebx
movsbl (%r13,%rbx), %esi
xorl $0x5c, %esi
movq %rbp, %rdi
callq 0x4a002
incq %rbx
cmpq %rbx, %r14
jne 0x96cb
movl 0xc(%rsp), %ebx
cmpl $0x3f, %r12d
jg 0x96ff
movq %rbp, %rdi
movl $0x5c, %esi
callq 0x4a002
incl %ebx
jne 0x96ee
xorl %ebx, %ebx
movsbl 0x40(%rsp,%rbx), %esi
movq %rbp, %rdi
callq 0x4a002
incq %rbx
cmpq $0x20, %rbx
jne 0x9701
movl 0x14(%rsp), %ebx
movq %rbp, %rdi
callq 0x8882
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 0x961e
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq