// File: /workspace/github_c_makefile_star2_O0/MartinDrab[P]netpipe/sha2.c
// Function: sha512_final
void sha512_final(sha512_ctx *ctx, unsigned char *digest)
{
    unsigned int block_nb;
    unsigned int pm_len;
    unsigned int len_b;

#ifndef UNROLL_LOOPS
    int i;
#endif

    block_nb = 1 + ((SHA512_BLOCK_SIZE - 17)
                     < (ctx->len % SHA512_BLOCK_SIZE));

    len_b = (ctx->tot_len + ctx->len) << 3;
    pm_len = block_nb << 7;

    memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
    ctx->block[ctx->len] = 0x80;
    UNPACK32(len_b, ctx->block + pm_len - 4);

    sha512_transf(ctx, ctx->block, block_nb);

#ifndef UNROLL_LOOPS
    for (i = 0 ; i < 8; i++) {
        UNPACK64(ctx->h[i], &digest[i << 3]);
    }
#else
    UNPACK64(ctx->h[0], &digest[ 0]);
    UNPACK64(ctx->h[1], &digest[ 8]);
    UNPACK64(ctx->h[2], &digest[16]);
    UNPACK64(ctx->h[3], &digest[24]);
    UNPACK64(ctx->h[4], &digest[32]);
    UNPACK64(ctx->h[5], &digest[40]);
    UNPACK64(ctx->h[6], &digest[48]);
    UNPACK64(ctx->h[7], &digest[56]);
#endif /* !UNROLL_LOOPS */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x7f, %ecx
movl $0x6f, %eax
cmpl %ecx, %eax
setb %al
andb $0x1, %al
movzbl %al, %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x4(%rcx), %eax
shll $0x3, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
shll $0x7, %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rdi
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
movb $-0x80, 0x8(%rax,%rcx)
movl -0x1c(%rbp), %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb %dl, 0x7(%rax,%rcx)
movl -0x1c(%rbp), %eax
shrl $0x8, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb %dl, 0x6(%rax,%rcx)
movl -0x1c(%rbp), %eax
shrl $0x10, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb %dl, 0x5(%rax,%rcx)
movl -0x1c(%rbp), %eax
shrl $0x18, %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movb %dl, 0x4(%rax,%rcx)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
movl -0x14(%rbp), %edx
callq 0x98b0
movl $0x0, -0x20(%rbp)
cmpl $0x8, -0x20(%rbp)
jge 0xa221
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x7(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x8, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x6(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x10, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x5(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x18, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x4(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x20, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x3(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x28, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x2(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x30, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, 0x1(%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq 0x108(%rax,%rcx,8), %rax
shrq $0x38, %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xa0d6
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)