// File: /workspace/github_cpp_makefile_star2_O1/Computer-Kids-Club[P]screenshare-pro-backend/sha1.c
// Function: SHA1ProcessMessageBlock(SHA1Context*)
void SHA1ProcessMessageBlock(SHA1Context *context)
{
    const unsigned K[] =            /* Constants defined in SHA-1   */      
    {
        0x5A827999,
        0x6ED9EBA1,
        0x8F1BBCDC,
        0xCA62C1D6
    };
    int         t;                  /* Loop counter                 */
    unsigned    temp;               /* Temporary word value         */
    unsigned    W[80];              /* Word sequence                */
    unsigned    A, B, C, D, E;      /* Word buffers                 */

    /*
     *  Initialize the first 16 words in the array W
     */
    for(t = 0; t < 16; t++)
    {
        W[t] = ((unsigned) context->Message_Block[t * 4]) << 24;
        W[t] |= ((unsigned) context->Message_Block[t * 4 + 1]) << 16;
        W[t] |= ((unsigned) context->Message_Block[t * 4 + 2]) << 8;
        W[t] |= ((unsigned) context->Message_Block[t * 4 + 3]);
    }

    for(t = 16; t < 80; t++)
    {
       W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
    }

    A = context->Message_Digest[0];
    B = context->Message_Digest[1];
    C = context->Message_Digest[2];
    D = context->Message_Digest[3];
    E = context->Message_Digest[4];

    for(t = 0; t < 20; t++)
    {
        temp =  SHA1CircularShift(5,A) +
                ((B & C) | ((~B) & D)) + E + W[t] + K[0];
        temp &= 0xFFFFFFFF;
        E = D;
        D = C;
        C = SHA1CircularShift(30,B);
        B = A;
        A = temp;
    }

    for(t = 20; t < 40; t++)
    {
        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
        temp &= 0xFFFFFFFF;
        E = D;
        D = C;
        C = SHA1CircularShift(30,B);
        B = A;
        A = temp;
    }

    for(t = 40; t < 60; t++)
    {
        temp = SHA1CircularShift(5,A) +
               ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
        temp &= 0xFFFFFFFF;
        E = D;
        D = C;
        C = SHA1CircularShift(30,B);
        B = A;
        A = temp;
    }

    for(t = 60; t < 80; t++)
    {
        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
        temp &= 0xFFFFFFFF;
        E = D;
        D = C;
        C = SHA1CircularShift(30,B);
        B = A;
        A = temp;
    }

    context->Message_Digest[0] =
                        (context->Message_Digest[0] + A) & 0xFFFFFFFF;
    context->Message_Digest[1] =
                        (context->Message_Digest[1] + B) & 0xFFFFFFFF;
    context->Message_Digest[2] =
                        (context->Message_Digest[2] + C) & 0xFFFFFFFF;
    context->Message_Digest[3] =
                        (context->Message_Digest[3] + D) & 0xFFFFFFFF;
    context->Message_Digest[4] =
                        (context->Message_Digest[4] + E) & 0xFFFFFFFF;

    context->Message_Block_Index = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
xorl %eax, %eax
movzbl 0x1c(%rdi,%rax,4), %ecx
shll $0x18, %ecx
movl %ecx, -0x170(%rbp,%rax,4)
movzbl 0x1d(%rdi,%rax,4), %edx
shll $0x10, %edx
orl %ecx, %edx
movl %edx, -0x170(%rbp,%rax,4)
movzbl 0x1e(%rdi,%rax,4), %ecx
shll $0x8, %ecx
orl %edx, %ecx
movl %ecx, -0x170(%rbp,%rax,4)
movzbl 0x1f(%rdi,%rax,4), %edx
orl %ecx, %edx
movl %edx, -0x170(%rbp,%rax,4)
incq %rax
cmpq $0x10, %rax
jne 0x63b2
movl $0x10, %eax
movl -0x190(%rbp,%rax,4), %ecx
xorl -0x17c(%rbp,%rax,4), %ecx
xorl -0x1a8(%rbp,%rax,4), %ecx
xorl -0x1b0(%rbp,%rax,4), %ecx
roll %ecx
movl %ecx, -0x170(%rbp,%rax,4)
incq %rax
cmpq $0x50, %rax
jne 0x63ff
movl (%rdi), %r8d
movl 0x4(%rdi), %esi
movl 0x8(%rdi), %edx
movl 0xc(%rdi), %ecx
movl 0x10(%rdi), %r12d
xorl %eax, %eax
movl %r12d, -0x2c(%rbp)
movl %ecx, %r13d
movl %edx, %r9d
movl %esi, %r11d
movl %r8d, %r10d
movl %r10d, %ebx
movl %r9d, %r15d
movl %r13d, %r14d
movl %r10d, %r9d
roll $0x5, %r9d
addl %r12d, %r9d
movl %r15d, %r10d
xorl %r13d, %r10d
andl %r11d, %r10d
xorl %r13d, %r10d
addl %r9d, %r10d
movl -0x170(%rbp,%rax,4), %r9d
addl %r9d, %r10d
addl $0x5a827999, %r10d      # imm = 0x5A827999
movl %r11d, %r9d
roll $0x1e, %r9d
incq %rax
movl %r13d, %r12d
movl %r15d, %r13d
movl %ebx, %r11d
cmpq $0x14, %rax
jne 0x644f
movl $0x14, %eax
movl %r10d, %r11d
movl %r9d, %r13d
movl %r10d, %r9d
roll $0x5, %r9d
movl %r15d, %r12d
movl %r13d, %r10d
xorl %ebx, %r10d
xorl %r15d, %r10d
addl %r9d, %r10d
addl %r14d, %r10d
movl -0x170(%rbp,%rax,4), %r9d
addl %r9d, %r10d
addl $0x6ed9eba1, %r10d      # imm = 0x6ED9EBA1
movl %ebx, %r9d
roll $0x1e, %r9d
incq %rax
movl %r15d, %r14d
movl %r13d, %r15d
movl %r11d, %ebx
cmpq $0x28, %rax
jne 0x64a1
movl $0x28, %eax
movl %r10d, %ebx
movl %r9d, %r15d
movl %r13d, %r14d
movl %r10d, %r9d
roll $0x5, %r9d
addl %r12d, %r9d
movl %r13d, %r10d
orl %r15d, %r10d
andl %r11d, %r10d
movl %r13d, %r12d
andl %r15d, %r12d
orl %r10d, %r12d
addl %r9d, %r12d
movl -0x170(%rbp,%rax,4), %r9d
leal (%r9,%r12), %r10d
addl $0x8f1bbcdc, %r10d      # imm = 0x8F1BBCDC
movl %r11d, %r9d
roll $0x1e, %r9d
incq %rax
movl %r13d, %r12d
movl %r15d, %r13d
movl %ebx, %r11d
cmpq $0x3c, %rax
jne 0x64f0
movl $0x3c, %r11d
movl %r10d, %r13d
movl %r9d, %eax
movl %r10d, %r9d
roll $0x5, %r9d
movl %r15d, %r12d
movl %eax, %r10d
xorl %ebx, %r10d
xorl %r15d, %r10d
addl %r9d, %r10d
addl %r14d, %r10d
movl -0x170(%rbp,%r11,4), %r9d
addl %r9d, %r10d
addl $0xca62c1d6, %r10d      # imm = 0xCA62C1D6
movl %ebx, %r9d
roll $0x1e, %r9d
incq %r11
movl %r15d, %r14d
movl %eax, %r15d
movl %r13d, %ebx
cmpq $0x50, %r11
jne 0x654a
addl %r8d, %r10d
movl %r10d, (%rdi)
addl %esi, %r13d
movl %r13d, 0x4(%rdi)
addl %edx, %r9d
movl %r9d, 0x8(%rdi)
addl %ecx, %eax
movl %eax, 0xc(%rdi)
addl -0x2c(%rbp), %r12d
movl %r12d, 0x10(%rdi)
movl $0x0, 0x5c(%rdi)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop