// File: /workspace/github_c_makefile_star2_O2/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 $0x268, %rsp            # imm = 0x268
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movq %rdx, -0x38(%rsp)
addq $0x7, %rsi
movq %rsi, -0x40(%rsp)
xorl %ecx, %ecx
cmpq -0x38(%rsp), %rcx
je 0x6b5f
movq %rcx, -0x30(%rsp)
movq %rax, -0x28(%rsp)
cltq
addq -0x40(%rsp), %rax
xorl %ecx, %ecx
cmpq $0x10, %rcx
je 0x69cd
movq -0x7(%rax,%rcx,8), %rdx
bswapq %rdx
movq %rdx, -0x20(%rsp,%rcx,8)
incq %rcx
jmp 0x69b5
xorl %eax, %eax
cmpq $0x40, %rax
je 0x6a25
movq 0x50(%rsp,%rax,8), %rcx
movq %rcx, %rdx
rolq $0x2d, %rdx
movq %rcx, %rsi
rolq $0x3, %rsi
xorq %rdx, %rsi
shrq $0x6, %rcx
xorq %rsi, %rcx
addq 0x28(%rsp,%rax,8), %rcx
movq -0x18(%rsp,%rax,8), %rdx
movq %rdx, %rsi
rorq %rsi
movq %rdx, %r8
rolq $0x38, %r8
xorq %rsi, %r8
shrq $0x7, %rdx
addq -0x20(%rsp,%rax,8), %rcx
xorq %r8, %rdx
addq %rdx, %rcx
movq %rcx, 0x60(%rsp,%rax,8)
incq %rax
jmp 0x69cf
xorl %eax, %eax
cmpq $0x8, %rax
je 0x6a3f
movq 0x108(%rdi,%rax,8), %rcx
movq %rcx, -0x80(%rsp,%rax,8)
incq %rax
jmp 0x6a27
movq -0x48(%rsp), %rbp
movq -0x60(%rsp), %rdx
movq -0x58(%rsp), %rcx
movq -0x50(%rsp), %rsi
movq -0x80(%rsp), %r15
movq -0x78(%rsp), %r10
movq -0x70(%rsp), %rbx
movq -0x68(%rsp), %r9
xorl %r14d, %r14d
movq %rsi, %r12
cmpq $0x280, %r14            # imm = 0x280
je 0x6b08
movq %rdx, %r11
movq %rdx, %r13
movq %rdx, %rax
rolq $0x32, %rax
movq %rcx, %r8
xorq %r12, %r8
andq %rdx, %r8
rolq $0x2e, %r11
movq %rcx, %rsi
movq %rdx, %rcx
xorq %rax, %r11
rolq $0x17, %r13
xorq %r11, %r13
addq %rbp, %r13
leaq 0xad82(%rip), %rax      # 0x11830
addq (%r14,%rax), %r13
xorq %r12, %r8
addq %r8, %r13
addq -0x20(%rsp,%r14), %r13
movq %r15, %rax
movq %r15, %r8
movq %rbx, %r11
movq %r9, %rdx
movq %rbx, %r9
xorq %r10, %rbx
andq %r15, %rbx
andq %r10, %r11
xorq %rbx, %r11
movq %r10, %rbx
movq %r15, %r10
rolq $0x24, %r15
addq %r13, %rdx
rolq $0x1e, %rax
xorq %r15, %rax
rolq $0x19, %r8
xorq %rax, %r8
addq %r8, %r11
addq %r13, %r11
addq $0x8, %r14
movq %r11, %r15
movq %r12, %rbp
jmp 0x6a6a
movq %rbp, -0x48(%rsp)
movq %rdx, -0x60(%rsp)
movq %rcx, -0x58(%rsp)
movq %r12, -0x50(%rsp)
movq %r15, -0x80(%rsp)
movq %r10, -0x78(%rsp)
movq %rbx, -0x70(%rsp)
movq %r9, -0x68(%rsp)
xorl %eax, %eax
cmpq $0x8, %rax
je 0x6b4a
movq -0x80(%rsp,%rax,8), %rcx
addq %rcx, 0x108(%rdi,%rax,8)
incq %rax
jmp 0x6b32
movq -0x30(%rsp), %rcx
incq %rcx
movq -0x28(%rsp), %rax
subl $-0x80, %eax
jmp 0x6997
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq