// File: /workspace/github_c_makefile_star2_O3/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 0x6df0
addq $0x108, %rdi            # imm = 0x108
movl %edx, %eax
movq %rax, -0x28(%rsp)
addq $0x7, -0x78(%rsp)
xorl %eax, %eax
leaq 0x9c0d(%rip), %rdx      # 0x10830
xorl %ecx, %ecx
movq %rcx, -0x20(%rsp)
movq %rax, -0x18(%rsp)
cltq
addq -0x78(%rsp), %rax
xorl %ecx, %ecx
movq -0x7(%rax,%rcx,8), %r9
bswapq %r9
movq %r9, -0x10(%rsp,%rcx,8)
incq %rcx
cmpq $0x10, %rcx
jne 0x6c38
movq -0x10(%rsp), %rcx
xorl %eax, %eax
movq -0x8(%rsp,%rax,8), %r9
movq 0x60(%rsp,%rax,8), %r10
movq %r10, %r11
rolq $0x2d, %r11
movq %r10, %rbx
rolq $0x3, %rbx
xorq %r11, %rbx
shrq $0x6, %r10
xorq %rbx, %r10
addq 0x38(%rsp,%rax,8), %r10
movq %r9, %r11
rorq %r11
movq %r9, %rbx
rolq $0x38, %rbx
xorq %r11, %rbx
movq %r9, %r11
shrq $0x7, %r11
xorq %rbx, %r11
addq %rcx, %r11
addq %r10, %r11
movq %r11, 0x70(%rsp,%rax,8)
incq %rax
movq %r9, %rcx
cmpq $0x40, %rax
jne 0x6c55
movdqu (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups 0x20(%rdi), %xmm2
movups 0x30(%rdi), %xmm3
movaps %xmm3, -0x40(%rsp)
movaps %xmm2, -0x50(%rsp)
movdqa %xmm0, -0x70(%rsp)
movaps %xmm1, -0x60(%rsp)
movq -0x40(%rsp), %rax
movq -0x38(%rsp), %r13
movq -0x50(%rsp), %r10
movq -0x48(%rsp), %rsi
movq -0x70(%rsp), %r14
movq -0x68(%rsp), %r15
movq -0x60(%rsp), %r11
movq -0x58(%rsp), %rbp
xorl %ebx, %ebx
movq %rax, %r12
movq %rsi, %rax
movq %r10, %rsi
movq %rbp, %r10
movq %rsi, %r8
rolq $0x32, %r8
movq %r11, %rbp
movq %rsi, %r9
rolq $0x2e, %r9
movq %r15, %r11
movq %rsi, %rcx
rolq $0x17, %rcx
xorq %r8, %r9
xorq %r9, %rcx
addq %r13, %rcx
movq %rax, %r8
xorq %r12, %r8
andq %rsi, %r8
addq (%rbx,%rdx), %rcx
xorq %r12, %r8
addq %r8, %rcx
addq -0x10(%rsp,%rbx), %rcx
movq %r14, %r15
movq %r14, %r8
rolq $0x24, %r8
movq %r14, %r9
rolq $0x1e, %r9
xorq %r8, %r9
movq %r14, %r8
rolq $0x19, %r8
xorq %r9, %r8
movq %rbp, %r9
xorq %r11, %r9
andq %r14, %r9
movq %rbp, %r14
andq %r11, %r14
xorq %r9, %r14
addq %r8, %r14
addq %rcx, %r10
addq %rcx, %r14
addq $0x8, %rbx
movq %r12, %r13
cmpq $0x280, %rbx            # imm = 0x280
jne 0x6cfc
movq %r12, -0x38(%rsp)
movq %r10, -0x50(%rsp)
movq %rsi, -0x48(%rsp)
movq %rax, -0x40(%rsp)
movq %r14, -0x70(%rsp)
movq %r15, -0x68(%rsp)
movq %r11, -0x60(%rsp)
movq %rbp, -0x58(%rsp)
xorl %eax, %eax
movdqu (%rdi,%rax,8), %xmm0
paddq -0x70(%rsp,%rax,8), %xmm0
movdqu %xmm0, (%rdi,%rax,8)
addq $0x2, %rax
cmpq $0x8, %rax
jne 0x6dbb
movq -0x20(%rsp), %rcx
incq %rcx
movq -0x18(%rsp), %rax
subl $-0x80, %eax
cmpq -0x28(%rsp), %rcx
jne 0x6c25
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq