#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 */
typedef unsigned char const uint8_t;

/* Variables and functions */
size_t Base64Encode(unsigned char const *, size_t, char **);
int /*<<< orphan*/ EVP_sha512();
int /*<<< orphan*/ PKCS5_PBKDF2_HMAC(char *, size_t, unsigned char const *,
                                     size_t, size_t, int /*<<< orphan*/, int,
                                     unsigned char const *);
int /*<<< orphan*/ abs(int);
scalar_t__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ log10(int /*<<< orphan*/);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, char *);
char *PBKDF2_HMAC_SHA_512Ex(char *In, size_t InLen, char *Salt, size_t SaltLen,
                            size_t Iterations) {
  char *pbkdf2b64, *saltb64, *ret;
  size_t pbkdf2b64Len, saltb64Len;
  uint8_t pbkdf2[512 / 8];
  PKCS5_PBKDF2_HMAC(In, InLen, (const unsigned char *)Salt, SaltLen, Iterations,
                    EVP_sha512(), 512 / 8, pbkdf2);
  pbkdf2b64Len = Base64Encode(pbkdf2, 512 / 8, &pbkdf2b64);
  {
    saltb64Len = Base64Encode((const unsigned char *)Salt, SaltLen, &saltb64);
    {
      ret = malloc((floor(log10(abs(15000))) + 1) + saltb64Len + pbkdf2b64Len +
                   2 + 1);
      sprintf(ret, "%d$%s$%s", 15000, saltb64, pbkdf2b64);
    }
    free(saltb64);
  }
  free(pbkdf2b64);
  return ret;
}


x86 assembly (clang, -O0):
<PBKDF2_HMAC_SHA_512Ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    $0x0,%al
call   1070 <EVP_sha512@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
mov    -0x98(%rbp),%r8
mov    %eax,%r9d
lea    -0x90(%rbp),%rax
movl   $0x40,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <PKCS5_PBKDF2_HMAC@plt>
lea    -0x90(%rbp),%rdi
mov    $0x40,%esi
lea    -0x30(%rbp),%rdx
call   1030 <Base64Encode@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <Base64Encode@plt>
mov    %rax,-0x50(%rbp)
mov    $0x3a98,%edi
call   1050 <abs@plt>
mov    %eax,%edi
call   1090 <log10@plt>
mov    %eax,%edi
call   10b0 <floor@plt>
mov    %rax,%rdi
add    $0x1,%rdi
add    -0x50(%rbp),%rdi
add    -0x48(%rbp),%rdi
add    $0x2,%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xd5c(%rip),%rsi
mov    $0x3a98,%edx
call   10a0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PBKDF2_HMAC_SHA_512Ex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <EVP_sha512@plt>
lea    0x10(%rsp),%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %eax,%r9d
push   %rbp
push   $0x40
call   1050 <PKCS5_PBKDF2_HMAC@plt>
add    $0x10,%rsp
lea    0x8(%rsp),%rdx
mov    $0x40,%esi
mov    %rbp,%rdi
call   1030 <Base64Encode@plt>
mov    %rax,%rbx
mov    %rsp,%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <Base64Encode@plt>
mov    %rax,%rbp
mov    $0x3a98,%edi
call   1080 <log10@plt>
mov    %eax,%edi
call   10a0 <floor@plt>
add    %rbx,%rbp
lea    (%rax,%rbp,1),%rdi
add    $0x4,%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    (%rsp),%rcx
mov    0x8(%rsp),%r8
lea    0xddf(%rip),%rsi
mov    %rax,%rdi
mov    $0x3a98,%edx
call   1090 <sprintf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d$%s$%s\00"
define i8* @PBKDF2_HMAC_SHA_512Ex(i8* %0, i64 %1, i8* %2, i64 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca [64 x i8]
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i64 %4, i64* %10
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = load i8*, i8** %8
%20 = load i64, i64* %9
%21 = load i64, i64* %10
%22 = call i32 (...) @EVP_sha512()
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %16, i64 0, i64 0
%24 = call i32 @PKCS5_PBKDF2_HMAC(i8* %17, i64 %18, i8* %19, i64 %20, i64 %21, i32 %22, i32 64, i8* %23)
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %16, i64 0, i64 0
%26 = call i64 @Base64Encode(i8* %25, i64 64, i8** %11)
store i64 %26, i64* %14
%27 = load i8*, i8** %8
%28 = load i64, i64* %9
%29 = call i64 @Base64Encode(i8* %27, i64 %28, i8** %12)
store i64 %29, i64* %15
%30 = call i32 @abs(i32 15000)
%31 = call i32 @log10(i32 %30)
%32 = call i64 @floor(i32 %31)
%33 = add nsw i64 %32, 1
%34 = load i64, i64* %15
%35 = add i64 %33, %34
%36 = load i64, i64* %14
%37 = add i64 %35, %36
%38 = add i64 %37, 2
%39 = add i64 %38, 1
%40 = call i8* @malloc(i64 %39)
store i8* %40, i8** %13
%41 = load i8*, i8** %13
%42 = load i8*, i8** %12
%43 = load i8*, i8** %11
%44 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 15000, i8* %42, i8* %43)
%45 = load i8*, i8** %12
%46 = call i32 @free(i8* %45)
%47 = load i8*, i8** %11
%48 = call i32 @free(i8* %47)
%49 = load i8*, i8** %13
ret i8* %49
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d$%s$%s\00"
define noalias i8* @PBKDF2_HMAC_SHA_512Ex(i8* %0, i64 %1, i8* %2, i64 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [64 x i8]
%9 = bitcast i8** %6 to i8*
%10 = bitcast i8** %7 to i8*
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%12 = tail call i32 (...) @EVP_sha512()
%13 = call i32 @PKCS5_PBKDF2_HMAC(i8* %0, i64 %1, i8* %2, i64 %3, i64 %4, i32 %12, i32 64, i8* %11)
%14 = call i64 @Base64Encode(i8* %11, i64 64, i8** %6)
%15 = call i64 @Base64Encode(i8* %2, i64 %3, i8** %7)
%16 = call i32 @log10(i32 15000)
%17 = call i64 @floor(i32 %16)
%18 = add i64 %14, 4
%19 = add i64 %18, %15
%20 = add i64 %19, %17
%21 = call i8* @malloc(i64 %20)
%22 = load i8*, i8** %7
%23 = load i8*, i8** %6
%24 = call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 15000, i8* %22, i8* %23)
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
ret i8* %21
}