// File: /workspace/github_c_makefile_star2_O3/dubeyalok7[P]crypto-algo/sha/sha256.c
// Function: sha256Process
static void sha256Process(SHA256Context *ctx)
{
    /* Constants defined in FIPS 180-3, section 4.2.2 */
    static const uint32_t k[64] = {
        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
    };

    int t, t4;
    uint32_t tmp1, tmp2;
    uint32_t w[64];
    uint32_t a,b,c,d,e,f,g,h;

    /* Initialize the first 16 words in the array */
    for(t = t4 = 0; t< 16; t++, t4+=4)
    {
        w[t] = (((uint32_t)ctx->msg_block[t4]) << 24) |
            (((uint32_t)ctx->msg_block[t4 + 1]) << 16) |
            (((uint32_t)ctx->msg_block[t4 + 2]) << 8) |
            (((uint32_t)ctx->msg_block[t4 + 3]));
    }

    for(t = 16; t<64; ++t)
        w[t] = SSIG1(w[t-2]) + w[t-7] + SSIG0(w[t-15]) + w[t-16];

    a = ctx->h[0];
    b = ctx->h[1];
    c = ctx->h[2];
    d = ctx->h[3];
    e = ctx->h[4];
    f = ctx->h[5];
    g = ctx->h[6];
    h = ctx->h[7];

    for(int t = 0; t< 64; ++t) {
        tmp1 = h + SSIG1(e) + SHA256_CH(e, f, g) + k[t] + w[t];
        tmp2 = SSIG0(a) + SHA256_MAJ(a, b, c);
        h = g;
        g = f;
        f = e;
        e = d + tmp1;
        d = c;
        c = b;
        b = a;
        a = tmp1 + tmp2;
    }

    ctx->h[0] += a;
    ctx->h[1] += b;
    ctx->h[2] += c;
    ctx->h[3] += d;
    ctx->h[4] += e;
    ctx->h[5] += f;
    ctx->h[6] += g;
    ctx->h[7] += h;

    ctx->msg_block_idx = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl $0x39, %eax
pxor %xmm0, %xmm0
movzbl -0xb(%rdi,%rax), %ecx
movzbl -0xf(%rdi,%rax), %edx
movd %edx, %xmm2
pinsrw $0x2, %ecx, %xmm2
movzbl -0x7(%rdi,%rax), %ecx
pinsrw $0x4, %ecx, %xmm2
movzbl -0x3(%rdi,%rax), %ecx
pinsrw $0x6, %ecx, %xmm2
pslld $0x18, %xmm2
movzbl -0xe(%rdi,%rax), %ecx
movzbl -0xa(%rdi,%rax), %edx
movzbl -0x6(%rdi,%rax), %esi
shll $0x8, %edx
orl %ecx, %edx
shll $0x10, %esi
orl %edx, %esi
movzbl -0x2(%rdi,%rax), %ecx
shll $0x18, %ecx
orl %esi, %ecx
movd %ecx, %xmm3
punpcklbw %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3],xmm3[4],xmm0[4],xmm3[5],xmm0[5],xmm3[6],xmm0[6],xmm3[7],xmm0[7]
pxor %xmm1, %xmm1
punpcklwd %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1],xmm1[2],xmm3[2],xmm1[3],xmm3[3]
por %xmm2, %xmm1
movzbl -0xd(%rdi,%rax), %ecx
movzbl -0x9(%rdi,%rax), %edx
movzbl -0x5(%rdi,%rax), %esi
shll $0x8, %edx
orl %ecx, %edx
shll $0x10, %esi
orl %edx, %esi
movzbl -0x1(%rdi,%rax), %ecx
shll $0x18, %ecx
orl %esi, %ecx
movd %ecx, %xmm2
punpcklbw %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3],xmm2[4],xmm0[4],xmm2[5],xmm0[5],xmm2[6],xmm0[6],xmm2[7],xmm0[7]
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
pslld $0x8, %xmm2
movzbl -0xc(%rdi,%rax), %ecx
movzbl -0x8(%rdi,%rax), %edx
movzbl -0x4(%rdi,%rax), %esi
shll $0x8, %edx
orl %ecx, %edx
shll $0x10, %esi
orl %edx, %esi
movzbl (%rdi,%rax), %ecx
shll $0x18, %ecx
orl %esi, %ecx
movd %ecx, %xmm3
punpcklbw %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3],xmm3[4],xmm0[4],xmm3[5],xmm0[5],xmm3[6],xmm0[6],xmm3[7],xmm0[7]
punpcklwd %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3]
por %xmm2, %xmm3
por %xmm1, %xmm3
movdqa %xmm3, -0x89(%rsp,%rax)
addq $0x10, %rax
cmpq $0x79, %rax
jne 0x12bc
movl $0x10, %eax
movl -0x50(%rsp), %ecx
movl -0x58(%rsp,%rax,4), %edx
movl %edx, %esi
roll $0xf, %esi
movl %edx, %r8d
roll $0xd, %r8d
roll $0x16, %edx
xorl %esi, %r8d
xorl %r8d, %edx
addl -0x6c(%rsp,%rax,4), %edx
movl -0x8c(%rsp,%rax,4), %esi
movl %esi, %r8d
roll $0x19, %r8d
movl %esi, %r9d
roll $0xe, %r9d
movl %esi, %r10d
roll $0x1d, %r10d
xorl %r8d, %r9d
xorl %r9d, %r10d
addl %ecx, %r10d
addl %edx, %r10d
movl %r10d, -0x50(%rsp,%rax,4)
incq %rax
movl %esi, %ecx
cmpq $0x40, %rax
jne 0x13a9
movl (%rdi), %r11d
movl 0x4(%rdi), %r10d
movl 0x8(%rdi), %r8d
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %r13d
movl 0x14(%rdi), %ebx
movl 0x18(%rdi), %ebp
movl 0x1c(%rdi), %r12d
xorl %r14d, %r14d
movl %r12d, -0x54(%rsp)
movl %ebp, -0x58(%rsp)
movl %ebx, -0x5c(%rsp)
movl %r13d, -0x60(%rsp)
movl %eax, -0x64(%rsp)
movl %eax, -0x74(%rsp)
movl %r8d, -0x68(%rsp)
movl %r10d, -0x6c(%rsp)
movl %r11d, -0x70(%rsp)
movl %r13d, %eax
movl %r13d, %ecx
roll $0xf, %ecx
movl %ebx, %r15d
movl %r13d, %esi
roll $0xd, %esi
movl %ebp, %edx
movl %r13d, %r9d
roll $0x16, %r9d
xorl %ecx, %esi
xorl %esi, %r9d
movl %ebx, %ebp
xorl %edx, %ebp
andl %r13d, %ebp
xorl %edx, %ebp
addl %r12d, %ebp
addl %r9d, %ebp
leaq 0xbc4(%rip), %rcx       # 0x2040
addl (%r14,%rcx), %ebp
addl -0x50(%rsp,%r14), %ebp
movl %r11d, %esi
roll $0x19, %r11d
movl %r10d, %r9d
movl %esi, %r10d
roll $0xe, %r10d
movl %r8d, %ecx
movl %esi, %r8d
roll $0x1d, %r8d
xorl %r11d, %r10d
xorl %r10d, %r8d
movl %ecx, %r10d
xorl %esi, %r10d
andl %r9d, %r10d
movl %ecx, %r11d
andl %esi, %r11d
xorl %r10d, %r11d
addl %r8d, %r11d
movl -0x74(%rsp), %r13d
addl %ebp, %r13d
addl %ebp, %r11d
addq $0x4, %r14
movl %edx, %r12d
movl %ebx, %ebp
movl %eax, %ebx
movl %ecx, -0x74(%rsp)
movl %r9d, %r8d
movl %esi, %r10d
cmpq $0x100, %r14            # imm = 0x100
jne 0x1446
addl -0x70(%rsp), %r11d
movl %r11d, (%rdi)
addl -0x6c(%rsp), %esi
movl %esi, 0x4(%rdi)
addl -0x68(%rsp), %r9d
movl %r9d, 0x8(%rdi)
addl -0x64(%rsp), %ecx
movl %ecx, 0xc(%rdi)
addl -0x60(%rsp), %r13d
movl %r13d, 0x10(%rdi)
addl -0x5c(%rsp), %eax
movl %eax, 0x14(%rdi)
addl -0x58(%rsp), %r15d
movl %r15d, 0x18(%rdi)
addl -0x54(%rsp), %edx
movl %edx, 0x1c(%rdi)
movw $0x0, 0x28(%rdi)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq