// File: /workspace/github_c_makefile_star2_O1/MartinDrab[P]netpipe/sha2.c
// Function: sha512_transf
void sha512_transf(sha512_ctx *ctx, const unsigned char *message,
                   unsigned int block_nb)
{
    uint64 w[80];
    uint64 wv[8];
    uint64 t1, t2;
    const unsigned char *sub_block;
    int i, j;

    for (i = 0; i < (int) block_nb; i++) {
        sub_block = message + (i << 7);

#ifndef UNROLL_LOOPS
        for (j = 0; j < 16; j++) {
            PACK64(&sub_block[j << 3], &w[j]);
        }

        for (j = 16; j < 80; j++) {
            SHA512_SCR(j);
        }

        for (j = 0; j < 8; j++) {
            wv[j] = ctx->h[j];
        }

        for (j = 0; j < 80; j++) {
            t1 = wv[7] + SHA512_F2(wv[4]) + CH(wv[4], wv[5], wv[6])
                + sha512_k[j] + w[j];
            t2 = SHA512_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
            wv[7] = wv[6];
            wv[6] = wv[5];
            wv[5] = wv[4];
            wv[4] = wv[3] + t1;
            wv[3] = wv[2];
            wv[2] = wv[1];
            wv[1] = wv[0];
            wv[0] = t1 + t2;
        }

        for (j = 0; j < 8; j++) {
            ctx->h[j] += wv[j];
        }
#else
        PACK64(&sub_block[  0], &w[ 0]); PACK64(&sub_block[  8], &w[ 1]);
        PACK64(&sub_block[ 16], &w[ 2]); PACK64(&sub_block[ 24], &w[ 3]);
        PACK64(&sub_block[ 32], &w[ 4]); PACK64(&sub_block[ 40], &w[ 5]);
        PACK64(&sub_block[ 48], &w[ 6]); PACK64(&sub_block[ 56], &w[ 7]);
        PACK64(&sub_block[ 64], &w[ 8]); PACK64(&sub_block[ 72], &w[ 9]);
        PACK64(&sub_block[ 80], &w[10]); PACK64(&sub_block[ 88], &w[11]);
        PACK64(&sub_block[ 96], &w[12]); PACK64(&sub_block[104], &w[13]);
        PACK64(&sub_block[112], &w[14]); PACK64(&sub_block[120], &w[15]);

        SHA512_SCR(16); SHA512_SCR(17); SHA512_SCR(18); SHA512_SCR(19);
        SHA512_SCR(20); SHA512_SCR(21); SHA512_SCR(22); SHA512_SCR(23);
        SHA512_SCR(24); SHA512_SCR(25); SHA512_SCR(26); SHA512_SCR(27);
        SHA512_SCR(28); SHA512_SCR(29); SHA512_SCR(30); SHA512_SCR(31);
        SHA512_SCR(32); SHA512_SCR(33); SHA512_SCR(34); SHA512_SCR(35);
        SHA512_SCR(36); SHA512_SCR(37); SHA512_SCR(38); SHA512_SCR(39);
        SHA512_SCR(40); SHA512_SCR(41); SHA512_SCR(42); SHA512_SCR(43);
        SHA512_SCR(44); SHA512_SCR(45); SHA512_SCR(46); SHA512_SCR(47);
        SHA512_SCR(48); SHA512_SCR(49); SHA512_SCR(50); SHA512_SCR(51);
        SHA512_SCR(52); SHA512_SCR(53); SHA512_SCR(54); SHA512_SCR(55);
        SHA512_SCR(56); SHA512_SCR(57); SHA512_SCR(58); SHA512_SCR(59);
        SHA512_SCR(60); SHA512_SCR(61); SHA512_SCR(62); SHA512_SCR(63);
        SHA512_SCR(64); SHA512_SCR(65); SHA512_SCR(66); SHA512_SCR(67);
        SHA512_SCR(68); SHA512_SCR(69); SHA512_SCR(70); SHA512_SCR(71);
        SHA512_SCR(72); SHA512_SCR(73); SHA512_SCR(74); SHA512_SCR(75);
        SHA512_SCR(76); SHA512_SCR(77); SHA512_SCR(78); SHA512_SCR(79);

        wv[0] = ctx->h[0]; wv[1] = ctx->h[1];
        wv[2] = ctx->h[2]; wv[3] = ctx->h[3];
        wv[4] = ctx->h[4]; wv[5] = ctx->h[5];
        wv[6] = ctx->h[6]; wv[7] = ctx->h[7];

        j = 0;

        do {
            SHA512_EXP(0,1,2,3,4,5,6,7,j); j++;
            SHA512_EXP(7,0,1,2,3,4,5,6,j); j++;
            SHA512_EXP(6,7,0,1,2,3,4,5,j); j++;
            SHA512_EXP(5,6,7,0,1,2,3,4,j); j++;
            SHA512_EXP(4,5,6,7,0,1,2,3,j); j++;
            SHA512_EXP(3,4,5,6,7,0,1,2,j); j++;
            SHA512_EXP(2,3,4,5,6,7,0,1,j); j++;
            SHA512_EXP(1,2,3,4,5,6,7,0,j); j++;
        } while (j < 80);

        ctx->h[0] += wv[0]; ctx->h[1] += wv[1];
        ctx->h[2] += wv[2]; ctx->h[3] += wv[3];
        ctx->h[4] += wv[4]; ctx->h[5] += wv[5];
        ctx->h[6] += wv[6]; ctx->h[7] += wv[7];
#endif /* !UNROLL_LOOPS */
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, -0x78(%rsp)
testl %edx, %edx
jle 0x6ebc
leaq 0x108(%rdi), %rax
movq %rax, -0x28(%rsp)
movl %edx, %eax
movq %rax, -0x30(%rsp)
addq $0x7, -0x78(%rsp)
xorl %eax, %eax
leaq 0x9b28(%rip), %r8       # 0x10820
xorl %ecx, %ecx
movq %rcx, -0x20(%rsp)
movq %rax, -0x18(%rsp)
cltq
addq -0x78(%rsp), %rax
xorl %ecx, %ecx
movq -0x7(%rax,%rcx,8), %rsi
bswapq %rsi
movq %rsi, -0x10(%rsp,%rcx,8)
incq %rcx
cmpq $0x10, %rcx
jne 0x6d0d
xorl %eax, %eax
movq 0x60(%rsp,%rax,8), %rcx
movq %rcx, %rsi
rolq $0x2d, %rsi
movq %rcx, %r10
rolq $0x3, %r10
xorq %rsi, %r10
shrq $0x6, %rcx
xorq %r10, %rcx
addq 0x38(%rsp,%rax,8), %rcx
movq -0x8(%rsp,%rax,8), %rsi
movq %rsi, %r10
rorq %r10
movq %rsi, %r11
rolq $0x38, %r11
xorq %r10, %r11
shrq $0x7, %rsi
xorq %r11, %rsi
addq -0x10(%rsp,%rax,8), %rcx
addq %rsi, %rcx
movq %rcx, 0x70(%rsp,%rax,8)
incq %rax
cmpq $0x40, %rax
jne 0x6d25
movq -0x28(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movaps %xmm3, -0x40(%rsp)
movaps %xmm2, -0x50(%rsp)
movaps %xmm0, -0x70(%rsp)
movaps %xmm1, -0x60(%rsp)
movq -0x40(%rsp), %rax
movq -0x38(%rsp), %rbp
movq -0x50(%rsp), %r11
movq -0x48(%rsp), %rdx
movq -0x70(%rsp), %r15
movq -0x68(%rsp), %r12
movq -0x60(%rsp), %rcx
movq -0x58(%rsp), %rbx
xorl %r14d, %r14d
movq %rax, %r13
movq %rdx, %rax
movq %r11, %rdx
movq %rbx, %r11
movq %rdx, %r9
rolq $0x32, %r9
movq %rcx, %rbx
movq %rdx, %r10
rolq $0x2e, %r10
movq %r12, %rcx
movq %rdx, %rsi
rolq $0x17, %rsi
xorq %r9, %r10
xorq %r10, %rsi
addq %rbp, %rsi
movq %rax, %r9
xorq %r13, %r9
andq %rdx, %r9
addq (%r14,%r8), %rsi
xorq %r13, %r9
addq %r9, %rsi
addq -0x10(%rsp,%r14), %rsi
movq %r15, %r12
movq %r15, %r9
rolq $0x24, %r9
movq %r15, %r10
rolq $0x1e, %r10
xorq %r9, %r10
movq %r15, %r9
rolq $0x19, %r9
xorq %r10, %r9
movq %rbx, %r10
xorq %rcx, %r10
andq %r15, %r10
movq %rbx, %r15
andq %rcx, %r15
xorq %r10, %r15
addq %r9, %r15
addq %rsi, %r11
addq %rsi, %r15
addq $0x8, %r14
movq %r13, %rbp
cmpq $0x280, %r14            # imm = 0x280
jne 0x6dcc
movq %r13, -0x38(%rsp)
movq %r11, -0x50(%rsp)
movq %rdx, -0x48(%rsp)
movq %rax, -0x40(%rsp)
movq %r15, -0x70(%rsp)
movq %r12, -0x68(%rsp)
movq %rcx, -0x60(%rsp)
movq %rbx, -0x58(%rsp)
xorl %eax, %eax
movq -0x70(%rsp,%rax,8), %rcx
addq %rcx, 0x108(%rdi,%rax,8)
incq %rax
cmpq $0x8, %rax
jne 0x6e8b
movq -0x20(%rsp), %rcx
incq %rcx
movq -0x18(%rsp), %rax
subl $-0x80, %eax
cmpq -0x30(%rsp), %rcx
jne 0x6cfa
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq