// File: /workspace/github_cpp_makefile_star2_O1/simap[P]ecctools/lib/SHA256.cpp
// Function: SHA256::processChunk()
void SHA256::processChunk()
{
    // Round constants for SHA-256.
    static uint32_t const k[64] PROGMEM = {
        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
        0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
        0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
        0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
        0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
        0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
        0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
        0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
        0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
        0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
        0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
        0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
        0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
        0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
    };

    // Convert the first 16 words from big endian to host byte order.
    uint8_t index;
    for (index = 0; index < 16; ++index)
        state.w[index] = be32toh(state.w[index]);

    // Initialise working variables to the current hash value.
    uint32_t a = state.h[0];
    uint32_t b = state.h[1];
    uint32_t c = state.h[2];
    uint32_t d = state.h[3];
    uint32_t e = state.h[4];
    uint32_t f = state.h[5];
    uint32_t g = state.h[6];
    uint32_t h = state.h[7];

    // Perform the first 16 rounds of the compression function main loop.
    uint32_t temp1, temp2;
    for (index = 0; index < 16; ++index) {
        temp1 = h + pgm_read_dword(k + index) + state.w[index] +
                (rightRotate6(e) ^ rightRotate11(e) ^ rightRotate25(e)) +
                ((e & f) ^ ((~e) & g));
        temp2 = (rightRotate2(a) ^ rightRotate13(a) ^ rightRotate22(a)) +
                ((a & b) ^ (a & c) ^ (b & c));
        h = g;
        g = f;
        f = e;
        e = d + temp1;
        d = c;
        c = b;
        b = a;
        a = temp1 + temp2;
    }

    // Perform the 48 remaining rounds.  We expand the first 16 words to
    // 64 in-place in the "w" array.  This saves 192 bytes of memory
    // that would have otherwise need to be allocated to the "w" array.
    for (; index < 64; ++index) {
        // Expand the next word.
        temp1 = state.w[(index - 15) & 0x0F];
        temp2 = state.w[(index - 2) & 0x0F];
        temp1 = state.w[index & 0x0F] =
            state.w[(index - 16) & 0x0F] + state.w[(index - 7) & 0x0F] +
                (rightRotate7(temp1) ^ rightRotate18(temp1) ^ (temp1 >> 3)) +
                (rightRotate17(temp2) ^ rightRotate19(temp2) ^ (temp2 >> 10));

        // Perform the round.
        temp1 = h + pgm_read_dword(k + index) + temp1 +
                (rightRotate6(e) ^ rightRotate11(e) ^ rightRotate25(e)) +
                ((e & f) ^ ((~e) & g));
        temp2 = (rightRotate2(a) ^ rightRotate13(a) ^ rightRotate22(a)) +
                ((a & b) ^ (a & c) ^ (b & c));
        h = g;
        g = f;
        f = e;
        e = d + temp1;
        d = c;
        c = b;
        b = a;
        a = temp1 + temp2;
    }

    // Add the compressed chunk to the current hash value.
    state.h[0] += a;
    state.h[1] += b;
    state.h[2] += c;
    state.h[3] += d;
    state.h[4] += e;
    state.h[5] += f;
    state.h[6] += g;
    state.h[7] += h;

    // Attempt to clean up the stack.
    a = b = c = d = e = f = g = h = temp1 = temp2 = 0;
}

// Assembly:
xorl %eax, %eax
movl 0x28(%rdi,%rax,4), %ecx
bswapl %ecx
movl %ecx, 0x28(%rdi,%rax,4)
incq %rax
cmpq $0x10, %rax
jne 0x5a38
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x8(%rdi), %r9d
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %ecx
movl 0x14(%rdi), %r12d
movl 0x18(%rdi), %r15d
movl 0x1c(%rdi), %ebp
movl 0x20(%rdi), %r10d
movl 0x24(%rdi), %r11d
xorl %esi, %esi
leaq 0x745(%rip), %rbx       # 0x61c0
movl %r9d, -0x20(%rsp)
movl %eax, -0x1c(%rsp)
movl %ecx, -0x18(%rsp)
movl %r12d, -0x14(%rsp)
movl %r15d, -0x10(%rsp)
movl %ebp, -0xc(%rsp)
movl %r10d, -0x8(%rsp)
movl %r11d, -0x4(%rsp)
movl %r11d, %r8d
movl %r10d, %r11d
movl %ebp, %r10d
movl %r15d, %ebp
movl %r12d, %r15d
movl %ebp, %edx
roll $0x1a, %edx
movl %ecx, %r12d
movl %ebp, %r14d
roll $0x15, %r14d
movl %eax, %ecx
movl %ebp, %eax
roll $0x7, %eax
xorl %edx, %r14d
xorl %r14d, %eax
movl %r10d, %edx
xorl %r11d, %edx
andl %ebp, %edx
xorl %r11d, %edx
addl %r8d, %edx
addl %eax, %edx
addl (%rsi,%rbx), %edx
addl 0x28(%rdi,%rsi), %edx
movl %r9d, %eax
movl %r9d, %r8d
roll $0x1e, %r8d
roll $0x13, %r9d
xorl %r8d, %r9d
movl %eax, %r8d
roll $0xa, %r8d
xorl %r9d, %r8d
movl %ecx, %r14d
xorl %r12d, %r14d
andl %eax, %r14d
movl %ecx, %r9d
andl %r12d, %r9d
xorl %r14d, %r9d
addl %r8d, %r9d
addl %edx, %r15d
addl %edx, %r9d
addq $0x4, %rsi
cmpq $0x40, %rsi
jne 0x5aa0
movl $0x1e, %esi
leal -0xd(%rsi), %edx
andl $0xf, %edx
movl 0x28(%rdi,%rdx,4), %r13d
movl %esi, %r8d
andl $0xf, %r8d
movl %r13d, %ebx
roll $0x19, %ebx
movl 0x28(%rdi,%r8,4), %r14d
movl %r13d, %edx
roll $0xe, %edx
xorl %ebx, %edx
movl %r14d, %ebx
roll $0xf, %ebx
shrl $0x3, %r13d
movl %r14d, %r8d
roll $0xd, %r8d
xorl %edx, %r13d
xorl %ebx, %r8d
leal -0xe(%rsi), %edx
andl $0xf, %edx
shrl $0xa, %r14d
xorl %r8d, %r14d
leal -0x5(%rsi), %r8d
andl $0xf, %r8d
movl 0x28(%rdi,%r8,4), %r8d
addl 0x28(%rdi,%rdx,4), %r8d
addl %r8d, %r14d
movl %r11d, %r8d
movl %r10d, %r11d
movl %ebp, %r10d
movl %r15d, %ebp
movl %r12d, %r15d
movl %ecx, %r12d
movl %eax, %ecx
addl %r13d, %r14d
leaq 0x619(%rip), %rbx       # 0x61c0
movl %r14d, 0x28(%rdi,%rdx,4)
movl %ebp, %eax
roll $0x1a, %eax
movl %ebp, %edx
roll $0x15, %edx
xorl %eax, %edx
movl %ebp, %eax
roll $0x7, %eax
xorl %edx, %eax
movl %r10d, %edx
xorl %r11d, %edx
andl %ebp, %edx
xorl %r11d, %edx
addl %r8d, %edx
addl %eax, %edx
addl -0x38(%rbx,%rsi,4), %edx
movl %r9d, %eax
movl %r9d, %r8d
roll $0x1e, %r8d
addl %r14d, %edx
roll $0x13, %r9d
xorl %r8d, %r9d
movl %eax, %r8d
roll $0xa, %r8d
xorl %r9d, %r8d
movl %ecx, %ebx
xorl %r12d, %ebx
andl %eax, %ebx
movl %ecx, %r9d
andl %r12d, %r9d
xorl %ebx, %r9d
addl %r8d, %r9d
addl %edx, %r15d
addl %edx, %r9d
incq %rsi
cmpq $0x4e, %rsi
jne 0x5b2b
addl -0x20(%rsp), %r9d
movl %r9d, 0x8(%rdi)
addl -0x1c(%rsp), %eax
movl %eax, 0xc(%rdi)
addl -0x18(%rsp), %ecx
movl %ecx, 0x10(%rdi)
addl -0x14(%rsp), %r12d
movl %r12d, 0x14(%rdi)
addl -0x10(%rsp), %r15d
movl %r15d, 0x18(%rdi)
addl -0xc(%rsp), %ebp
movl %ebp, 0x1c(%rdi)
addl -0x8(%rsp), %r10d
movl %r10d, 0x20(%rdi)
addl -0x4(%rsp), %r11d
movl %r11d, 0x24(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq