#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 int /*<<< orphan*/ SHA512_CTX;

/* Variables and functions */
int /*<<< orphan*/ SHA512_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA512_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA512_Update(int /*<<< orphan*/ *, unsigned char const *,
                                 size_t);
void crypto_hash_sha512_3(unsigned char *out, const unsigned char *in1,
                          size_t len1, const unsigned char *in2, size_t len2,
                          const unsigned char *in3, size_t len3) {
  SHA512_CTX c;
  SHA512_Init(&c);
  SHA512_Update(&c, in1, len1);
  SHA512_Update(&c, in2, len2);
  SHA512_Update(&c, in3, len3);
  SHA512_Final(out, &c);
}


x86 assembly (clang, -O0):
<crypto_hash_sha512_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x34(%rbp),%rdi
call   1050 <SHA512_Init@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x34(%rbp),%rdi
call   1030 <SHA512_Update@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x34(%rbp),%rdi
call   1030 <SHA512_Update@plt>
mov    -0x30(%rbp),%rsi
mov    0x10(%rbp),%rdx
lea    -0x34(%rbp),%rdi
call   1030 <SHA512_Update@plt>
mov    -0x8(%rbp),%rdi
lea    -0x34(%rbp),%rsi
call   1040 <SHA512_Final@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_hash_sha512_3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x14(%rsp),%r14
mov    %r14,%rdi
call   1050 <SHA512_Init@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <SHA512_Update@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <SHA512_Update@plt>
mov    %r14,%rdi
mov    0x8(%rsp),%rsi
mov    0x50(%rsp),%rdx
call   1030 <SHA512_Update@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <SHA512_Final@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @crypto_hash_sha512_3(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4, i8* %5, i64 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i8* %3, i8** %11
store i64 %4, i64* %12
store i8* %5, i8** %13
store i64 %6, i64* %14
%16 = call i32 @SHA512_Init(i32* %15)
%17 = load i8*, i8** %9
%18 = load i64, i64* %10
%19 = call i32 @SHA512_Update(i32* %15, i8* %17, i64 %18)
%20 = load i8*, i8** %11
%21 = load i64, i64* %12
%22 = call i32 @SHA512_Update(i32* %15, i8* %20, i64 %21)
%23 = load i8*, i8** %13
%24 = load i64, i64* %14
%25 = call i32 @SHA512_Update(i32* %15, i8* %23, i64 %24)
%26 = load i8*, i8** %8
%27 = call i32 @SHA512_Final(i8* %26, i32* %15)
ret void
}

LLVM IR (-O2):
define void @crypto_hash_sha512_3(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4, i8* %5, i64 %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = call i32 @SHA512_Init(i32* %8)
%11 = call i32 @SHA512_Update(i32* %8, i8* %1, i64 %2)
%12 = call i32 @SHA512_Update(i32* %8, i8* %3, i64 %4)
%13 = call i32 @SHA512_Update(i32* %8, i8* %5, i64 %6)
%14 = call i32 @SHA512_Final(i8* %0, i32* %8)
ret void
}