// File: /workspace/github_c_makefile_star2_O3/janmojzis[P]mcencrypt/poly1305.c
// Function: poly1305_blocks
void poly1305_blocks(poly1305_ctx *ctx, const unsigned char *m, unsigned long long n) {

    unsigned long long d0, d1, d2, d3, d4;
    unsigned long c;
    unsigned long h0 = ctx->h[0];
    unsigned long h1 = ctx->h[1];
    unsigned long h2 = ctx->h[2];
    unsigned long h3 = ctx->h[3];
    unsigned long h4 = ctx->h[4];
    unsigned long r0 = ctx->r[0];
    unsigned long r1 = ctx->r[1];
    unsigned long r2 = ctx->r[2];
    unsigned long r3 = ctx->r[3];
    unsigned long r4 = ctx->r[4];
    unsigned long s1 = ctx->s[1];
    unsigned long s2 = ctx->s[2];
    unsigned long s3 = ctx->s[3];
    unsigned long s4 = ctx->s[4];

    while (n > 0) {

        /* h += m[i] */
        if (n >= 16) {
            h0 += (unpack(m     )     ) & 0x3ffffff;
            h1 += (unpack(m +  3) >> 2) & 0x3ffffff;
            h2 += (unpack(m +  6) >> 4) & 0x3ffffff;
            h3 += (unpack(m +  9) >> 6) & 0x3ffffff;
            h4 += (unpack(m + 12) >> 8) | 16777216;
            m += 16;
            n -= 16;
        }
        else {
            unsigned char mm[16];
            long long i;
            for (i = 0; i < 16; ++i) mm[i] = 0;
            for (i = 0; i <  n; ++i) mm[i] = m[i];
            mm[i] = 1;
            h0 += (unpack(mm     )     ) & 0x3ffffff;
            h1 += (unpack(mm +  3) >> 2) & 0x3ffffff;
            h2 += (unpack(mm +  6) >> 4) & 0x3ffffff;
            h3 += (unpack(mm +  9) >> 6) & 0x3ffffff;
            h4 += (unpack(mm + 12) >> 8);
            m += n;
            n = 0;
        }

        /* h *= r */
        d0 = ((unsigned long long)h0 * r0) + ((unsigned long long)h1 * s4) + ((unsigned long long)h2 * s3) + ((unsigned long long)h3 * s2) + ((unsigned long long)h4 * s1);
        d1 = ((unsigned long long)h0 * r1) + ((unsigned long long)h1 * r0) + ((unsigned long long)h2 * s4) + ((unsigned long long)h3 * s3) + ((unsigned long long)h4 * s2);
        d2 = ((unsigned long long)h0 * r2) + ((unsigned long long)h1 * r1) + ((unsigned long long)h2 * r0) + ((unsigned long long)h3 * s4) + ((unsigned long long)h4 * s3);
        d3 = ((unsigned long long)h0 * r3) + ((unsigned long long)h1 * r2) + ((unsigned long long)h2 * r1) + ((unsigned long long)h3 * r0) + ((unsigned long long)h4 * s4);
        d4 = ((unsigned long long)h0 * r4) + ((unsigned long long)h1 * r3) + ((unsigned long long)h2 * r2) + ((unsigned long long)h3 * r1) + ((unsigned long long)h4 * r0);

        /* (partial) h %= p */
                      c = (unsigned long)(d0 >> 26); h0 = (unsigned long)d0 & 0x3ffffff;
        d1 += c;      c = (unsigned long)(d1 >> 26); h1 = (unsigned long)d1 & 0x3ffffff;
        d2 += c;      c = (unsigned long)(d2 >> 26); h2 = (unsigned long)d2 & 0x3ffffff;
        d3 += c;      c = (unsigned long)(d3 >> 26); h3 = (unsigned long)d3 & 0x3ffffff;
        d4 += c;      c = (unsigned long)(d4 >> 26); h4 = (unsigned long)d4 & 0x3ffffff;
        h0 += c * 5;  c =                (h0 >> 26); h0 =                h0 & 0x3ffffff;
        h1 += c;
    }

    ctx->h[0] = h0;
    ctx->h[1] = h1;
    ctx->h[2] = h2;
    ctx->h[3] = h3;
    ctx->h[4] = h4;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdi), %r9
movq 0x8(%rdi), %rbp
movq 0x10(%rdi), %r13
movq 0x18(%rdi), %rax
movq 0x20(%rdi), %r14
testq %rdx, %rdx
movq %rdi, -0x20(%rsp)
je 0x66c7
movq 0x28(%rdi), %rcx
movq %rcx, -0x48(%rsp)
movq 0x30(%rdi), %rcx
movq %rcx, -0x40(%rsp)
movq 0x38(%rdi), %rcx
movq %rcx, -0x50(%rsp)
movq 0x40(%rdi), %rcx
movq %rcx, -0x8(%rsp)
movq 0x48(%rdi), %rcx
movq %rcx, -0x10(%rsp)
movq 0x58(%rdi), %rcx
movq %rcx, -0x18(%rsp)
movq 0x60(%rdi), %rcx
movq %rcx, -0x28(%rsp)
movq 0x68(%rdi), %rcx
movq %rcx, -0x30(%rsp)
movq 0x70(%rdi), %rcx
movq %rcx, -0x38(%rsp)
xorps %xmm0, %xmm0
cmpq $0x10, %rdx
jb 0x64e7
movl (%rsi), %r12d
movl 0x3(%rsi), %r10d
movl 0x6(%rsi), %r15d
movl 0x9(%rsi), %r11d
movl 0xc(%rsi), %ebx
shrl $0x8, %ebx
orl $0x1000000, %ebx        # imm = 0x1000000
addq $0x10, %rsi
addq $-0x10, %rdx
jmp 0x6525
movaps %xmm0, -0x68(%rsp)
xorl %r10d, %r10d
movb (%rsi,%r10), %r11b
movb %r11b, -0x68(%rsp,%r10)
incq %r10
cmpq %r10, %rdx
jne 0x64ef
movb $0x1, -0x68(%rsp,%rdx)
movl -0x68(%rsp), %r12d
movl -0x65(%rsp), %r10d
movl -0x62(%rsp), %r15d
movl -0x5f(%rsp), %r11d
movl -0x5c(%rsp), %ebx
shrl $0x8, %ebx
addq %rdx, %rsi
xorl %edx, %edx
movl %ebx, %ebx
addq %rbx, %r14
movl $0x3ffffff, %ecx        # imm = 0x3FFFFFF
andl %ecx, %r12d
addq %r12, %r9
shrl $0x2, %r10d
andl %ecx, %r10d
addq %r10, %rbp
shrl $0x4, %r15d
andl %ecx, %r15d
addq %r15, %r13
shrl $0x6, %r11d
addq %r11, %rax
movq %r9, %r10
movq -0x48(%rsp), %rcx
imulq %rcx, %r10
movq %rcx, %r8
movq %rbp, %rbx
movq -0x38(%rsp), %rdi
imulq %rdi, %rbx
addq %r10, %rbx
movq %r13, %r10
movq -0x30(%rsp), %rcx
imulq %rcx, %r10
movq %rax, %r15
imulq -0x28(%rsp), %r15
addq %r10, %r15
movq %r14, %r11
imulq -0x18(%rsp), %r11
addq %r15, %r11
addq %rbx, %r11
movq %r9, %r10
imulq -0x40(%rsp), %r10
movq %rbp, %rbx
imulq %r8, %rbx
addq %r10, %rbx
movq %r13, %r10
imulq %rdi, %r10
movq %rax, %r12
imulq %rcx, %r12
addq %r10, %r12
movq %r14, %r15
imulq -0x28(%rsp), %r15
addq %r12, %r15
addq %rbx, %r15
movq %r9, %r10
imulq -0x50(%rsp), %r10
movq %rbp, %rbx
movq -0x40(%rsp), %rcx
imulq %rcx, %rbx
addq %r10, %rbx
movq %r13, %r10
imulq %r8, %r10
movq %rax, %r12
imulq %rdi, %r12
addq %r10, %r12
movq %r14, %r10
imulq -0x30(%rsp), %r10
addq %r12, %r10
addq %rbx, %r10
movq %r9, %rbx
movq -0x8(%rsp), %r8
imulq %r8, %rbx
movq %rbp, %rdi
imulq -0x50(%rsp), %rdi
addq %rbx, %rdi
movq %r13, %rbx
imulq %rcx, %rbx
movq %rax, %rcx
imulq -0x48(%rsp), %rcx
addq %rbx, %rcx
movq %r14, %r12
imulq -0x38(%rsp), %r12
addq %rcx, %r12
addq %rdi, %r12
imulq -0x10(%rsp), %r9
imulq %r8, %rbp
addq %r9, %rbp
imulq -0x50(%rsp), %r13
imulq -0x40(%rsp), %rax
addq %r13, %rax
imulq -0x48(%rsp), %r14
addq %rax, %r14
addq %rbp, %r14
movq %r11, %rbx
shrq $0x1a, %rbx
addq %r15, %rbx
movl $0x3ffffff, %edi        # imm = 0x3FFFFFF
andq %rdi, %r11
movq %rbx, %r13
shrq $0x1a, %r13
addq %r10, %r13
andq %rdi, %rbx
movq %r13, %rax
shrq $0x1a, %rax
addq %r12, %rax
andq %rdi, %r13
movq %rax, %r10
shrq $0x1a, %r10
addq %r14, %r10
andq %rdi, %rax
movq %r10, %rcx
shrq $0x1a, %rcx
andq %rdi, %r10
leaq (%rcx,%rcx,4), %r9
addq %r11, %r9
movq %r9, %rbp
shrq $0x1a, %rbp
addq %rbx, %rbp
andq %rdi, %r9
movq %r10, %r14
testq %rdx, %rdx
jne 0x64bc
jmp 0x66ca
movq %r14, %r10
movq -0x20(%rsp), %rcx
movq %r9, (%rcx)
movq %rbp, 0x8(%rcx)
movq %r13, 0x10(%rcx)
movq %rax, 0x18(%rcx)
movq %r10, 0x20(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq