#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ neoscrypt_blake2s(unsigned char *, unsigned int const,
                                     unsigned char *, unsigned int const,
                                     unsigned char *, unsigned int const);
int /*<<< orphan*/ neoscrypt_copy(unsigned char *, unsigned char const *,
                                  unsigned int const);
int /*<<< orphan*/ neoscrypt_xor(unsigned char *, unsigned char *,
                                 unsigned int const);
void neoscrypt_fastkdf(const unsigned char *password, unsigned int password_len,
                       const unsigned char *salt, unsigned int salt_len,
                       unsigned int N, unsigned char *output,
                       unsigned int output_len) {
  const size_t stack_align = 0x40;
  const unsigned int kdf_buf_size = 256U, prf_input_size = 64,
                     prf_key_size = 32, prf_output_size = 32;
  unsigned int bufptr, a, b, i, j;
  unsigned char *A, *B, *prf_input, *prf_key, *prf_output;
  unsigned char stack[2 * kdf_buf_size + prf_input_size + prf_key_size +
                      prf_output_size + stack_align];
  A = (unsigned char *)(((size_t)stack & ~(stack_align - 1)) + stack_align);
  B = &A[kdf_buf_size + prf_input_size];
  prf_output = &A[2 * kdf_buf_size + prf_input_size + prf_key_size];
  if (password_len > kdf_buf_size)
    password_len = kdf_buf_size;
  a = kdf_buf_size / password_len;
  for (i = 0; i < a; i++)
    neoscrypt_copy(&A[i * password_len], &password[0], password_len);
  b = kdf_buf_size - a * password_len;
  if (b)
    neoscrypt_copy(&A[a * password_len], &password[0], b);
  neoscrypt_copy(&A[kdf_buf_size], &password[0], prf_input_size);
  if (salt_len > kdf_buf_size)
    salt_len = kdf_buf_size;
  a = kdf_buf_size / salt_len;
  for (i = 0; i < a; i++)
    neoscrypt_copy(&B[i * salt_len], &salt[0], salt_len);
  b = kdf_buf_size - a * salt_len;
  if (b)
    neoscrypt_copy(&B[a * salt_len], &salt[0], b);
  neoscrypt_copy(&B[kdf_buf_size], &salt[0], prf_key_size);
  for (i = 0, bufptr = 0; i < N; i++) {
    prf_input = &A[bufptr];
    prf_key = &B[bufptr];
    neoscrypt_blake2s(prf_input, prf_input_size, prf_key, prf_key_size,
                      prf_output, prf_output_size);
    for (j = 0, bufptr = 0; j < prf_output_size; j++)
      bufptr += prf_output[j];
    bufptr &= (kdf_buf_size - 1);
    neoscrypt_xor(&B[bufptr], &prf_output[0], prf_output_size);
    if (bufptr < prf_key_size)
      neoscrypt_copy(&B[kdf_buf_size + bufptr], &B[bufptr],
                     ((prf_output_size) < (prf_key_size - bufptr)
                          ? prf_output_size
                          : prf_key_size - bufptr));
    else if ((kdf_buf_size - bufptr) < prf_output_size)
      neoscrypt_copy(&B[0], &B[kdf_buf_size],
                     prf_output_size - (kdf_buf_size - bufptr));
  }
  if (output_len > kdf_buf_size)
    output_len = kdf_buf_size;
  a = kdf_buf_size - bufptr;
  if (a >= output_len) {
    neoscrypt_xor(&B[bufptr], &A[0], output_len);
    neoscrypt_copy(&output[0], &B[bufptr], output_len);
  } else {
    neoscrypt_xor(&B[bufptr], &A[0], a);
    neoscrypt_xor(&B[0], &A[a], output_len - a);
    neoscrypt_copy(&output[0], &B[bufptr], a);
    neoscrypt_copy(&output[a], &B[0], output_len - a);
  }
}


x86 assembly (clang, -O0):
<neoscrypt_fastkdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movq   $0x40,-0x30(%rbp)
movl   $0x100,-0x34(%rbp)
movl   $0x40,-0x38(%rbp)
movl   $0x20,-0x3c(%rbp)
movl   $0x20,-0x40(%rbp)
mov    %rsp,%rax
mov    %rax,-0x88(%rbp)
lea    -0x350(%rbp),%rax
and    $0xffffffffffffffc0,%rax
add    $0x40,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
add    $0x140,%rax
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rax
add    $0x260,%rax
mov    %rax,-0x80(%rbp)
cmpl   $0x100,-0xc(%rbp)
jbe    11c5 <neoscrypt_fastkdf+0x95>
movl   $0x100,-0xc(%rbp)
mov    $0x100,%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x48(%rbp),%eax
jae    120f <neoscrypt_fastkdf+0xdf>
mov    -0x60(%rbp),%rdi
mov    -0x50(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11d9 <neoscrypt_fastkdf+0xa9>
mov    -0x48(%rbp),%ecx
imul   -0xc(%rbp),%ecx
mov    $0x100,%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1246 <neoscrypt_fastkdf+0x116>
mov    -0x60(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x60(%rbp),%rdi
add    $0x100,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x40,%edx
call   1040 <neoscrypt_copy@plt>
cmpl   $0x100,-0x1c(%rbp)
jbe    1273 <neoscrypt_fastkdf+0x143>
movl   $0x100,-0x1c(%rbp)
mov    $0x100,%eax
xor    %edx,%edx
divl   -0x1c(%rbp)
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x48(%rbp),%eax
jae    12bd <neoscrypt_fastkdf+0x18d>
mov    -0x68(%rbp),%rdi
mov    -0x50(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1287 <neoscrypt_fastkdf+0x157>
mov    -0x48(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    $0x100,%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     12f4 <neoscrypt_fastkdf+0x1c4>
mov    -0x68(%rbp),%rdi
mov    -0x48(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x68(%rbp),%rdi
add    $0x100,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x20,%edx
call   1040 <neoscrypt_copy@plt>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    148d <neoscrypt_fastkdf+0x35d>
mov    -0x60(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    -0x80(%rbp),%r8
mov    $0x40,%esi
mov    $0x20,%r9d
mov    %r9d,%ecx
call   1050 <neoscrypt_blake2s@plt>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x20,-0x54(%rbp)
jae    1399 <neoscrypt_fastkdf+0x269>
mov    -0x80(%rbp),%rax
mov    -0x54(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1370 <neoscrypt_fastkdf+0x240>
mov    -0x44(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x44(%rbp),%eax
add    %rax,%rdi
mov    -0x80(%rbp),%rsi
mov    $0x20,%edx
call   1030 <neoscrypt_xor@plt>
cmpl   $0x20,-0x44(%rbp)
jae    1441 <neoscrypt_fastkdf+0x311>
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    $0x100,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x360(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x358(%rbp)
mov    $0x20,%ecx
sub    -0x44(%rbp),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jae    1415 <neoscrypt_fastkdf+0x2e5>
mov    $0x20,%eax
mov    %eax,-0x364(%rbp)
jmp    1423 <neoscrypt_fastkdf+0x2f3>
mov    $0x20,%eax
sub    -0x44(%rbp),%eax
mov    %eax,-0x364(%rbp)
mov    -0x358(%rbp),%rsi
mov    -0x360(%rbp),%rdi
mov    -0x364(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
jmp    147a <neoscrypt_fastkdf+0x34a>
mov    $0x100,%eax
sub    -0x44(%rbp),%eax
cmp    $0x20,%eax
jae    1475 <neoscrypt_fastkdf+0x345>
mov    -0x68(%rbp),%rdi
mov    -0x68(%rbp),%rsi
add    $0x100,%rsi
mov    $0x100,%eax
sub    -0x44(%rbp),%eax
mov    $0x20,%edx
sub    %eax,%edx
call   1040 <neoscrypt_copy@plt>
jmp    147a <neoscrypt_fastkdf+0x34a>
jmp    147f <neoscrypt_fastkdf+0x34f>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    131b <neoscrypt_fastkdf+0x1eb>
cmpl   $0x100,0x10(%rbp)
jbe    14a1 <neoscrypt_fastkdf+0x371>
movl   $0x100,0x10(%rbp)
mov    $0x100,%eax
sub    -0x44(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    0x10(%rbp),%eax
jb     14e9 <neoscrypt_fastkdf+0x3b9>
mov    -0x68(%rbp),%rdi
mov    -0x44(%rbp),%eax
add    %rax,%rdi
mov    -0x60(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1030 <neoscrypt_xor@plt>
mov    -0x28(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x44(%rbp),%eax
add    %rax,%rsi
mov    0x10(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
jmp    1547 <neoscrypt_fastkdf+0x417>
mov    -0x68(%rbp),%rdi
mov    -0x44(%rbp),%eax
add    %rax,%rdi
mov    -0x60(%rbp),%rsi
mov    -0x48(%rbp),%edx
call   1030 <neoscrypt_xor@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x48(%rbp),%eax
add    %rax,%rsi
mov    0x10(%rbp),%edx
sub    -0x48(%rbp),%edx
call   1030 <neoscrypt_xor@plt>
mov    -0x28(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x44(%rbp),%eax
add    %rax,%rsi
mov    -0x48(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%eax
add    %rax,%rdi
mov    -0x68(%rbp),%rsi
mov    0x10(%rbp),%edx
sub    -0x48(%rbp),%edx
call   1040 <neoscrypt_copy@plt>
mov    -0x88(%rbp),%rax
mov    %rax,%rsp
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neoscrypt_fastkdf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2f8,%rsp
mov    %r9,0x20(%rsp)
mov    %r8d,%r15d
mov    %ecx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rdi,%rcx
lea    0x70(%rsp),%rbp
and    $0xffffffffffffffc0,%rbp
lea    0x140(%rbp),%rax
mov    %rax,(%rsp)
lea    0x260(%rbp),%rax
mov    %rax,0x28(%rsp)
cmp    $0x100,%esi
mov    $0x100,%r13d
cmovb  %esi,%r13d
xor    %ebx,%ebx
mov    $0x100,%ax
xor    %edx,%edx
div    %r13w
movzwl %ax,%r14d
mov    %rbp,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rcx,%rsi
mov    %r13d,%edx
mov    %rcx,%r12
call   1040 <neoscrypt_copy@plt>
mov    %r12,%rcx
add    $0x1,%rbx
add    %r13,%rbp
cmp    %r14,%rbx
jne    11a0 <neoscrypt_fastkdf+0x70>
imul   %r14d,%r13d
cmp    $0x100,%r13d
mov    0x8(%rsp),%rbx
je     11eb <neoscrypt_fastkdf+0xbb>
mov    $0x100,%edx
sub    %r13d,%edx
mov    %r13d,%edi
add    %rbx,%rdi
mov    %rcx,%rsi
call   1040 <neoscrypt_copy@plt>
mov    %r12,%rcx
lea    0x100(%rbx),%rdi
mov    %rcx,%rsi
mov    $0x40,%edx
call   1040 <neoscrypt_copy@plt>
mov    0x18(%rsp),%eax
cmp    $0x100,%eax
mov    $0x100,%r14d
cmovb  %eax,%r14d
xor    %ebp,%ebp
mov    $0x100,%ax
xor    %edx,%edx
div    %r14w
movzwl %ax,%r13d
mov    (%rsp),%rbx
mov    0x10(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1040 <neoscrypt_copy@plt>
add    $0x1,%rbp
add    %r14,%rbx
cmp    %r13,%rbp
jne    1230 <neoscrypt_fastkdf+0x100>
imul   %r13d,%r14d
cmp    $0x100,%r14d
je     126e <neoscrypt_fastkdf+0x13e>
mov    $0x100,%edx
sub    %r14d,%edx
mov    %r14d,%edi
add    (%rsp),%rdi
mov    %r12,%rsi
call   1040 <neoscrypt_copy@plt>
mov    0x8(%rsp),%rax
lea    0x240(%rax),%rdi
mov    %rdi,0x18(%rsp)
mov    %r12,%rsi
mov    $0x20,%edx
call   1040 <neoscrypt_copy@plt>
xor    %r13d,%r13d
test   %r15d,%r15d
je     143f <neoscrypt_fastkdf+0x30f>
mov    0x8(%rsp),%r12
mov    (%rsp),%r14
jmp    12d9 <neoscrypt_fastkdf+0x1a9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x100(%r13),%edi
add    %r14,%rdi
mov    $0x20,%edx
sub    %r13d,%edx
mov    %rbx,%rsi
call   1040 <neoscrypt_copy@plt>
mov    0x10(%rsp),%r15d
add    $0xffffffff,%r15d
je     1444 <neoscrypt_fastkdf+0x314>
mov    %r15d,0x10(%rsp)
mov    %r13d,%edx
lea    (%r12,%rdx,1),%rdi
add    %r14,%rdx
mov    $0x40,%esi
mov    $0x20,%ecx
mov    0x28(%rsp),%r15
mov    %r15,%r8
mov    $0x20,%r9d
call   1050 <neoscrypt_blake2s@plt>
movdqa 0x260(%r12),%xmm0
movdqa %xmm0,%xmm1
pxor   %xmm4,%xmm4
punpckhbw %xmm4,%xmm1
movdqa %xmm1,%xmm2
punpcklwd %xmm4,%xmm2
punpcklbw %xmm4,%xmm0
movdqa %xmm0,%xmm3
punpcklwd %xmm4,%xmm3
paddd  %xmm2,%xmm3
punpckhwd %xmm4,%xmm1
punpckhwd %xmm4,%xmm0
paddd  %xmm1,%xmm0
paddd  %xmm3,%xmm0
movq   0x270(%r12),%xmm1
punpcklbw %xmm4,%xmm1
movdqa %xmm1,%xmm2
punpckhwd %xmm4,%xmm2
punpcklwd %xmm4,%xmm1
paddd  %xmm2,%xmm1
movq   0x278(%r12),%xmm2
punpcklbw %xmm4,%xmm2
punpcklwd %xmm4,%xmm2
movzbl 0x27c(%r12),%eax
movzbl 0x27d(%r12),%ecx
movzbl 0x27e(%r12),%edx
pshufd $0xee,%xmm0,%xmm3
paddd  %xmm0,%xmm3
pshufd $0x55,%xmm3,%xmm0
paddd  %xmm3,%xmm0
movd   %xmm0,%esi
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edi
add    %rsi,%rdi
pshufd $0xee,%xmm2,%xmm0
paddd  %xmm2,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
add    %rdi,%rsi
add    %rax,%rsi
add    %rcx,%rsi
add    %rdx,%rsi
movzbl 0x27f(%r12),%ebp
add    %rsi,%rbp
movzbl %bpl,%r13d
mov    %r13,%rbx
add    %r14,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x20,%edx
call   1030 <neoscrypt_xor@plt>
cmp    $0x1f,%r13d
jbe    12b0 <neoscrypt_fastkdf+0x180>
cmp    $0xe1,%r13d
mov    0x10(%rsp),%r15d
jb     12cf <neoscrypt_fastkdf+0x19f>
or     $0xffffff00,%ebp
add    $0x20,%ebp
mov    (%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebp,%edx
call   1040 <neoscrypt_copy@plt>
jmp    12cf <neoscrypt_fastkdf+0x19f>
mov    0x8(%rsp),%r12
mov    0x330(%rsp),%ebx
cmp    $0x100,%ebx
mov    $0x100,%ebp
cmovae %ebp,%ebx
sub    %r13d,%ebp
mov    %r13d,%r14d
mov    (%rsp),%rax
add    %rax,%r14
mov    %ebx,%r15d
sub    %ebp,%r15d
jbe    14b3 <neoscrypt_fastkdf+0x383>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <neoscrypt_xor@plt>
mov    %ebp,%r13d
add    %r13,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <neoscrypt_xor@plt>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <neoscrypt_copy@plt>
add    %r13,%rbx
mov    %rbx,%rdi
mov    (%rsp),%rsi
mov    %r15d,%edx
jmp    14ca <neoscrypt_fastkdf+0x39a>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <neoscrypt_xor@plt>
mov    0x20(%rsp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <neoscrypt_copy@plt>
add    $0x2f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @neoscrypt_fastkdf(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8* %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca i8*
%29 = alloca i8*
%30 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i32 %6, i32* %14
store i64 64, i64* %15
store i32 256, i32* %16
store i32 64, i32* %17
store i32 32, i32* %18
store i32 32, i32* %19
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %30
%32 = alloca i8, i64 704
%33 = ptrtoint i8* %32 to i64
%34 = and i64 %33, -64
%35 = add i64 %34, 64
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %25
%37 = load i8*, i8** %25
%38 = getelementptr inbounds i8, i8* %37, i64 320
store i8* %38, i8** %26
%39 = load i8*, i8** %25
%40 = getelementptr inbounds i8, i8* %39, i64 608
store i8* %40, i8** %29
%41 = load i32, i32* %9
%42 = icmp ugt i32 %41, 256
br i1 %42, label %43, label %44
43: ; preds = %7
store i32 256, i32* %9
br label %44
44: ; preds = %43, %7
%45 = load i32, i32* %9
%46 = udiv i32 256, %45
store i32 %46, i32* %21
store i32 0, i32* %23
br label %47
47: ; preds = %62, %44
%48 = load i32, i32* %23
%49 = load i32, i32* %21
%50 = icmp ult i32 %48, %49
br i1 %50, label %51, label %65
51: ; preds = %47
%52 = load i8*, i8** %25
%53 = load i32, i32* %23
%54 = load i32, i32* %9
%55 = mul i32 %53, %54
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %52, i64 %56
%58 = load i8*, i8** %8
%59 = getelementptr inbounds i8, i8* %58, i64 0
%60 = load i32, i32* %9
%61 = call i32 @neoscrypt_copy(i8* %57, i8* %59, i32 %60)
br label %62
62: ; preds = %51
%63 = load i32, i32* %23
%64 = add i32 %63, 1
store i32 %64, i32* %23
br label %47
65: ; preds = %47
%66 = load i32, i32* %21
%67 = load i32, i32* %9
%68 = mul i32 %66, %67
%69 = sub i32 256, %68
store i32 %69, i32* %22
%70 = load i32, i32* %22
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %83
72: ; preds = %65
%73 = load i8*, i8** %25
%74 = load i32, i32* %21
%75 = load i32, i32* %9
%76 = mul i32 %74, %75
%77 = zext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %73, i64 %77
%79 = load i8*, i8** %8
%80 = getelementptr inbounds i8, i8* %79, i64 0
%81 = load i32, i32* %22
%82 = call i32 @neoscrypt_copy(i8* %78, i8* %80, i32 %81)
br label %83
83: ; preds = %72, %65
%84 = load i8*, i8** %25
%85 = getelementptr inbounds i8, i8* %84, i64 256
%86 = load i8*, i8** %8
%87 = getelementptr inbounds i8, i8* %86, i64 0
%88 = call i32 @neoscrypt_copy(i8* %85, i8* %87, i32 64)
%89 = load i32, i32* %11
%90 = icmp ugt i32 %89, 256
br i1 %90, label %91, label %92
91: ; preds = %83
store i32 256, i32* %11
br label %92
92: ; preds = %91, %83
%93 = load i32, i32* %11
%94 = udiv i32 256, %93
store i32 %94, i32* %21
store i32 0, i32* %23
br label %95
95: ; preds = %110, %92
%96 = load i32, i32* %23
%97 = load i32, i32* %21
%98 = icmp ult i32 %96, %97
br i1 %98, label %99, label %113
99: ; preds = %95
%100 = load i8*, i8** %26
%101 = load i32, i32* %23
%102 = load i32, i32* %11
%103 = mul i32 %101, %102
%104 = zext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %100, i64 %104
%106 = load i8*, i8** %10
%107 = getelementptr inbounds i8, i8* %106, i64 0
%108 = load i32, i32* %11
%109 = call i32 @neoscrypt_copy(i8* %105, i8* %107, i32 %108)
br label %110
110: ; preds = %99
%111 = load i32, i32* %23
%112 = add i32 %111, 1
store i32 %112, i32* %23
br label %95
113: ; preds = %95
%114 = load i32, i32* %21
%115 = load i32, i32* %11
%116 = mul i32 %114, %115
%117 = sub i32 256, %116
store i32 %117, i32* %22
%118 = load i32, i32* %22
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %131
120: ; preds = %113
%121 = load i8*, i8** %26
%122 = load i32, i32* %21
%123 = load i32, i32* %11
%124 = mul i32 %122, %123
%125 = zext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %121, i64 %125
%127 = load i8*, i8** %10
%128 = getelementptr inbounds i8, i8* %127, i64 0
%129 = load i32, i32* %22
%130 = call i32 @neoscrypt_copy(i8* %126, i8* %128, i32 %129)
br label %131
131: ; preds = %120, %113
%132 = load i8*, i8** %26
%133 = getelementptr inbounds i8, i8* %132, i64 256
%134 = load i8*, i8** %10
%135 = getelementptr inbounds i8, i8* %134, i64 0
%136 = call i32 @neoscrypt_copy(i8* %133, i8* %135, i32 32)
store i32 0, i32* %23
store i32 0, i32* %20
br label %137
137: ; preds = %216, %131
%138 = load i32, i32* %23
%139 = load i32, i32* %12
%140 = icmp ult i32 %138, %139
br i1 %140, label %141, label %219
141: ; preds = %137
%142 = load i8*, i8** %25
%143 = load i32, i32* %20
%144 = zext i32 %143 to i64
%145 = getelementptr inbounds i8, i8* %142, i64 %144
store i8* %145, i8** %27
%146 = load i8*, i8** %26
%147 = load i32, i32* %20
%148 = zext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %146, i64 %148
store i8* %149, i8** %28
%150 = load i8*, i8** %27
%151 = load i8*, i8** %28
%152 = load i8*, i8** %29
%153 = call i32 @neoscrypt_blake2s(i8* %150, i32 64, i8* %151, i32 32, i8* %152, i32 32)
store i32 0, i32* %24
store i32 0, i32* %20
br label %154
154: ; preds = %166, %141
%155 = load i32, i32* %24
%156 = icmp ult i32 %155, 32
br i1 %156, label %157, label %169
157: ; preds = %154
%158 = load i8*, i8** %29
%159 = load i32, i32* %24
%160 = zext i32 %159 to i64
%161 = getelementptr inbounds i8, i8* %158, i64 %160
%162 = load i8, i8* %161
%163 = zext i8 %162 to i32
%164 = load i32, i32* %20
%165 = add i32 %164, %163
store i32 %165, i32* %20
br label %166
166: ; preds = %157
%167 = load i32, i32* %24
%168 = add i32 %167, 1
store i32 %168, i32* %24
br label %154
169: ; preds = %154
%170 = load i32, i32* %20
%171 = and i32 %170, 255
store i32 %171, i32* %20
%172 = load i8*, i8** %26
%173 = load i32, i32* %20
%174 = zext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %172, i64 %174
%176 = load i8*, i8** %29
%177 = getelementptr inbounds i8, i8* %176, i64 0
%178 = call i32 @neoscrypt_xor(i8* %175, i8* %177, i32 32)
%179 = load i32, i32* %20
%180 = icmp ult i32 %179, 32
br i1 %180, label %181, label %201
181: ; preds = %169
%182 = load i8*, i8** %26
%183 = load i32, i32* %20
%184 = add i32 256, %183
%185 = zext i32 %184 to i64
%186 = getelementptr inbounds i8, i8* %182, i64 %185
%187 = load i8*, i8** %26
%188 = load i32, i32* %20
%189 = zext i32 %188 to i64
%190 = getelementptr inbounds i8, i8* %187, i64 %189
%191 = load i32, i32* %20
%192 = sub i32 32, %191
%193 = icmp ult i32 32, %192
br i1 %193, label %194, label %195
194: ; preds = %181
br label %198
195: ; preds = %181
%196 = load i32, i32* %20
%197 = sub i32 32, %196
br label %198
198: ; preds = %195, %194
%199 = phi i32 [ 32, %194 ], [ %197, %195 ]
%200 = call i32 @neoscrypt_copy(i8* %186, i8* %190, i32 %199)
br label %215
201: ; preds = %169
%202 = load i32, i32* %20
%203 = sub i32 256, %202
%204 = icmp ult i32 %203, 32
br i1 %204, label %205, label %214
205: ; preds = %201
%206 = load i8*, i8** %26
%207 = getelementptr inbounds i8, i8* %206, i64 0
%208 = load i8*, i8** %26
%209 = getelementptr inbounds i8, i8* %208, i64 256
%210 = load i32, i32* %20
%211 = sub i32 256, %210
%212 = sub i32 32, %211
%213 = call i32 @neoscrypt_copy(i8* %207, i8* %209, i32 %212)
br label %214
214: ; preds = %205, %201
br label %215
215: ; preds = %214, %198
br label %216
216: ; preds = %215
%217 = load i32, i32* %23
%218 = add i32 %217, 1
store i32 %218, i32* %23
br label %137
219: ; preds = %137
%220 = load i32, i32* %14
%221 = icmp ugt i32 %220, 256
br i1 %221, label %222, label %223
222: ; preds = %219
store i32 256, i32* %14
br label %223
223: ; preds = %222, %219
%224 = load i32, i32* %20
%225 = sub i32 256, %224
store i32 %225, i32* %21
%226 = load i32, i32* %21
%227 = load i32, i32* %14
%228 = icmp uge i32 %226, %227
br i1 %228, label %229, label %246
229: ; preds = %223
%230 = load i8*, i8** %26
%231 = load i32, i32* %20
%232 = zext i32 %231 to i64
%233 = getelementptr inbounds i8, i8* %230, i64 %232
%234 = load i8*, i8** %25
%235 = getelementptr inbounds i8, i8* %234, i64 0
%236 = load i32, i32* %14
%237 = call i32 @neoscrypt_xor(i8* %233, i8* %235, i32 %236)
%238 = load i8*, i8** %13
%239 = getelementptr inbounds i8, i8* %238, i64 0
%240 = load i8*, i8** %26
%241 = load i32, i32* %20
%242 = zext i32 %241 to i64
%243 = getelementptr inbounds i8, i8* %240, i64 %242
%244 = load i32, i32* %14
%245 = call i32 @neoscrypt_copy(i8* %239, i8* %243, i32 %244)
br label %283
246: ; preds = %223
%247 = load i8*, i8** %26
%248 = load i32, i32* %20
%249 = zext i32 %248 to i64
%250 = getelementptr inbounds i8, i8* %247, i64 %249
%251 = load i8*, i8** %25
%252 = getelementptr inbounds i8, i8* %251, i64 0
%253 = load i32, i32* %21
%254 = call i32 @neoscrypt_xor(i8* %250, i8* %252, i32 %253)
%255 = load i8*, i8** %26
%256 = getelementptr inbounds i8, i8* %255, i64 0
%257 = load i8*, i8** %25
%258 = load i32, i32* %21
%259 = zext i32 %258 to i64
%260 = getelementptr inbounds i8, i8* %257, i64 %259
%261 = load i32, i32* %14
%262 = load i32, i32* %21
%263 = sub i32 %261, %262
%264 = call i32 @neoscrypt_xor(i8* %256, i8* %260, i32 %263)
%265 = load i8*, i8** %13
%266 = getelementptr inbounds i8, i8* %265, i64 0
%267 = load i8*, i8** %26
%268 = load i32, i32* %20
%269 = zext i32 %268 to i64
%270 = getelementptr inbounds i8, i8* %267, i64 %269
%271 = load i32, i32* %21
%272 = call i32 @neoscrypt_copy(i8* %266, i8* %270, i32 %271)
%273 = load i8*, i8** %13
%274 = load i32, i32* %21
%275 = zext i32 %274 to i64
%276 = getelementptr inbounds i8, i8* %273, i64 %275
%277 = load i8*, i8** %26
%278 = getelementptr inbounds i8, i8* %277, i64 0
%279 = load i32, i32* %14
%280 = load i32, i32* %21
%281 = sub i32 %279, %280
%282 = call i32 @neoscrypt_copy(i8* %276, i8* %278, i32 %281)
br label %283
283: ; preds = %246, %229
%284 = load i8*, i8** %30
ret void
}

LLVM IR (-O2):
define void @neoscrypt_fastkdf(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4, i8* %5, i32 %6) {
%8 = alloca [704 x i8]
%9 = ptrtoint [704 x i8]* %8 to i64
%10 = add i64 %9, 64
%11 = and i64 %10, -64
%12 = inttoptr i64 %11 to i8*
%13 = getelementptr inbounds i8, i8* %12, i64 320
%14 = getelementptr inbounds i8, i8* %12, i64 608
%15 = icmp ult i32 %1, 256
%16 = select i1 %15, i32 %1, i32 256
%17 = trunc i32 %16 to i16
%18 = udiv i16 256, %17
%19 = zext i16 %18 to i32
%20 = zext i32 %16 to i64
%21 = zext i16 %18 to i64
br label %22
22: ; preds = %7, %22
%23 = phi i64 [ 0, %7 ], [ %27, %22 ]
%24 = mul nuw nsw i64 %23, %20
%25 = getelementptr inbounds i8, i8* %12, i64 %24
%26 = call i32 @neoscrypt_copy(i8* %25, i8* %0, i32 %16)
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %21
br i1 %28, label %29, label %22
29: ; preds = %22
%30 = mul nuw nsw i32 %16, %19
%31 = icmp eq i32 %30, 256
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = sub nsw i32 256, %30
%34 = zext i32 %30 to i64
%35 = getelementptr inbounds i8, i8* %12, i64 %34
%36 = call i32 @neoscrypt_copy(i8* %35, i8* %0, i32 %33)
br label %37
37: ; preds = %32, %29
%38 = getelementptr inbounds i8, i8* %12, i64 256
%39 = call i32 @neoscrypt_copy(i8* %38, i8* %0, i32 64)
%40 = icmp ult i32 %3, 256
%41 = select i1 %40, i32 %3, i32 256
%42 = trunc i32 %41 to i16
%43 = udiv i16 256, %42
%44 = zext i16 %43 to i32
%45 = zext i32 %41 to i64
%46 = zext i16 %43 to i64
br label %47
47: ; preds = %37, %47
%48 = phi i64 [ 0, %37 ], [ %52, %47 ]
%49 = mul nuw nsw i64 %48, %45
%50 = getelementptr inbounds i8, i8* %13, i64 %49
%51 = call i32 @neoscrypt_copy(i8* %50, i8* %2, i32 %41)
%52 = add nuw nsw i64 %48, 1
%53 = icmp eq i64 %52, %46
br i1 %53, label %54, label %47
54: ; preds = %47
%55 = mul nuw nsw i32 %41, %44
%56 = icmp eq i32 %55, 256
br i1 %56, label %62, label %57
57: ; preds = %54
%58 = sub nsw i32 256, %55
%59 = zext i32 %55 to i64
%60 = getelementptr inbounds i8, i8* %13, i64 %59
%61 = call i32 @neoscrypt_copy(i8* %60, i8* %2, i32 %58)
br label %62
62: ; preds = %57, %54
%63 = getelementptr inbounds i8, i8* %12, i64 576
%64 = call i32 @neoscrypt_copy(i8* %63, i8* %2, i32 32)
%65 = icmp eq i32 %4, 0
br i1 %65, label %126, label %66
66: ; preds = %62
%67 = getelementptr inbounds i8, i8* %12, i64 624
%68 = getelementptr inbounds i8, i8* %12, i64 632
%69 = getelementptr inbounds i8, i8* %12, i64 636
%70 = getelementptr inbounds i8, i8* %12, i64 637
%71 = getelementptr inbounds i8, i8* %12, i64 638
%72 = getelementptr inbounds i8, i8* %12, i64 639
%73 = bitcast i8* %14 to <16 x i8>*
%74 = bitcast i8* %67 to <8 x i8>*
%75 = bitcast i8* %68 to <4 x i8>*
br label %76
76: ; preds = %66, %123
%77 = phi i32 [ %106, %123 ], [ 0, %66 ]
%78 = phi i32 [ %124, %123 ], [ 0, %66 ]
%79 = zext i32 %77 to i64
%80 = getelementptr inbounds i8, i8* %12, i64 %79
%81 = getelementptr inbounds i8, i8* %13, i64 %79
%82 = call i32 @neoscrypt_blake2s(i8* %80, i32 64, i8* %81, i32 32, i8* %14, i32 32)
%83 = load <16 x i8>, <16 x i8>* %73
%84 = zext <16 x i8> %83 to <16 x i32>
%85 = load <8 x i8>, <8 x i8>* %74
%86 = zext <8 x i8> %85 to <8 x i32>
%87 = load <4 x i8>, <4 x i8>* %75
%88 = zext <4 x i8> %87 to <4 x i32>
%89 = load i8, i8* %69
%90 = zext i8 %89 to i32
%91 = load i8, i8* %70
%92 = zext i8 %91 to i32
%93 = load i8, i8* %71
%94 = zext i8 %93 to i32
%95 = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %84)
%96 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %86)
%97 = add nuw nsw i32 %95, %96
%98 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %88)
%99 = add nuw nsw i32 %97, %98
%100 = add nuw nsw i32 %99, %90
%101 = add nuw nsw i32 %100, %92
%102 = add nuw nsw i32 %101, %94
%103 = load i8, i8* %72
%104 = zext i8 %103 to i32
%105 = add nuw nsw i32 %102, %104
%106 = and i32 %105, 255
%107 = zext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %13, i64 %107
%109 = call i32 @neoscrypt_xor(i8* %108, i8* %14, i32 32)
%110 = icmp ult i32 %106, 32
br i1 %110, label %111, label %117
111: ; preds = %76
%112 = or i32 %106, 256
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %13, i64 %113
%115 = sub nuw nsw i32 32, %106
%116 = call i32 @neoscrypt_copy(i8* %114, i8* %108, i32 %115)
br label %123
117: ; preds = %76
%118 = icmp ugt i32 %106, 224
br i1 %118, label %119, label %123
119: ; preds = %117
%120 = or i32 %105, -256
%121 = add nsw i32 %120, 32
%122 = call i32 @neoscrypt_copy(i8* %13, i8* %63, i32 %121)
br label %123
123: ; preds = %111, %119, %117
%124 = add nuw i32 %78, 1
%125 = icmp eq i32 %124, %4
br i1 %125, label %126, label %76
126: ; preds = %123, %62
%127 = phi i32 [ 0, %62 ], [ %106, %123 ]
%128 = icmp ult i32 %6, 256
%129 = select i1 %128, i32 %6, i32 256
%130 = sub nuw nsw i32 256, %127
%131 = icmp ugt i32 %129, %130
%132 = zext i32 %127 to i64
%133 = getelementptr inbounds i8, i8* %13, i64 %132
br i1 %131, label %137, label %134
134: ; preds = %126
%135 = call i32 @neoscrypt_xor(i8* %133, i8* %12, i32 %129)
%136 = call i32 @neoscrypt_copy(i8* %5, i8* %133, i32 %129)
br label %146
137: ; preds = %126
%138 = call i32 @neoscrypt_xor(i8* %133, i8* %12, i32 %130)
%139 = zext i32 %130 to i64
%140 = getelementptr inbounds i8, i8* %12, i64 %139
%141 = sub nsw i32 %129, %130
%142 = call i32 @neoscrypt_xor(i8* %13, i8* %140, i32 %141)
%143 = call i32 @neoscrypt_copy(i8* %5, i8* %133, i32 %130)
%144 = getelementptr inbounds i8, i8* %5, i64 %139
%145 = call i32 @neoscrypt_copy(i8* %144, i8* %13, i32 %141)
br label %146
146: ; preds = %137, %134
ret void
}