// File: /workspace/github_c_makefile_star2_O2/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), %rbp
movq 0x8(%rdi), %rbx
movq 0x10(%rdi), %r10
movq 0x18(%rdi), %r14
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %rax
movq %rax, -0x10(%rsp)
movq 0x30(%rdi), %r8
movq %r8, -0x50(%rsp)
movq 0x38(%rdi), %rax
movq %rax, -0x8(%rsp)
movq 0x40(%rdi), %rax
movq %rax, -0x18(%rsp)
movq 0x48(%rdi), %rax
movq %rax, -0x20(%rsp)
movq 0x58(%rdi), %rax
movq %rax, -0x28(%rsp)
movq 0x60(%rdi), %rax
movq %rax, -0x30(%rsp)
movq 0x68(%rdi), %rax
movq %rax, -0x58(%rsp)
movq %rdi, -0x38(%rsp)
movq 0x70(%rdi), %rax
movq %rax, -0x40(%rsp)
movq -0x10(%rsp), %r12
testq %rdx, %rdx
je 0x5d8e
cmpq $0x10, %rdx
jb 0x5ba5
movl (%rsi), %r15d
movl 0x3(%rsi), %r8d
movl 0x6(%rsi), %r9d
movl 0x9(%rsi), %edi
movl 0xc(%rsi), %r13d
shrl $0x8, %r13d
orl $0x1000000, %r13d       # imm = 0x1000000
addq $0x10, %rsi
movq %rsi, -0x48(%rsp)
addq $-0x10, %rdx
jmp 0x5bf7
xorl %edi, %edi
cmpq $0x10, %rdi
je 0x5bb7
movb $0x0, -0x68(%rsp,%rdi)
incq %rdi
jmp 0x5ba7
xorl %edi, %edi
cmpq %rdi, %rdx
je 0x5bcc
movb (%rsi,%rdi), %r8b
movb %r8b, -0x68(%rsp,%rdi)
incq %rdi
jmp 0x5bb9
movb $0x1, -0x68(%rsp,%rdx)
movl -0x68(%rsp), %r15d
movl -0x65(%rsp), %r8d
movl -0x62(%rsp), %r9d
movl -0x5f(%rsp), %edi
movl -0x5c(%rsp), %r13d
shrl $0x8, %r13d
addq %rdx, %rsi
movq %rsi, -0x48(%rsp)
xorl %edx, %edx
movl %r13d, %r13d
movl $0x3ffffff, %eax        # imm = 0x3FFFFFF
andl %eax, %r15d
addq %r15, %rbp
shrl $0x2, %r8d
andl %eax, %r8d
addq %r8, %rbx
shrl $0x4, %r9d
andl %eax, %r9d
addq %r9, %r10
shrl $0x6, %edi
addq %rdi, %r14
addq %r13, %rcx
movq %rbp, %r8
imulq %r12, %r8
movq %rbx, %rdi
movq -0x40(%rsp), %rax
imulq %rax, %rdi
movq %r10, %r9
imulq -0x58(%rsp), %r9
addq %rdi, %r9
movq %r14, %r15
movq -0x30(%rsp), %r11
imulq %r11, %r15
movq %rcx, %rdi
imulq -0x28(%rsp), %rdi
addq %r15, %rdi
addq %r9, %rdi
addq %r8, %rdi
movq %rbp, %r8
movq -0x50(%rsp), %rsi
imulq %rsi, %r8
movq %rbx, %r9
imulq %r12, %r9
movq %r10, %r15
imulq %rax, %r15
addq %r9, %r15
movq %r14, %r13
imulq -0x58(%rsp), %r13
movq %rcx, %r9
imulq %r11, %r9
addq %r13, %r9
addq %r15, %r9
addq %r8, %r9
movq %rbp, %r15
movq -0x8(%rsp), %rax
imulq %rax, %r15
movq %rbx, %r8
imulq %rsi, %r8
movq %r10, %r13
imulq %r12, %r13
addq %r8, %r13
movq %r14, %r11
movq -0x40(%rsp), %rsi
imulq %rsi, %r11
movq %rcx, %r8
imulq -0x58(%rsp), %r8
addq %r11, %r8
addq %r13, %r8
addq %r15, %r8
movq %rbx, %r11
imulq %rax, %r11
movq %r10, %r13
imulq -0x50(%rsp), %r13
addq %r11, %r13
movq %r14, %r11
imulq %r12, %r11
movq %rcx, %r15
imulq %rsi, %r15
addq %r11, %r15
addq %r13, %r15
movq %rbp, %r11
movq -0x18(%rsp), %r13
imulq %r13, %r11
addq %r11, %r15
imulq %r13, %rbx
imulq %rax, %r10
addq %rbx, %r10
imulq -0x50(%rsp), %r14
imulq %r12, %rcx
addq %r14, %rcx
addq %r10, %rcx
imulq -0x20(%rsp), %rbp
addq %rbp, %rcx
movq %rdi, %r13
shrq $0x1a, %r13
addq %r9, %r13
movl $0x3ffffff, %eax        # imm = 0x3FFFFFF
andq %rax, %rdi
movq %r13, %r10
shrq $0x1a, %r10
addq %r8, %r10
andq %rax, %r13
movq %r10, %r14
shrq $0x1a, %r14
addq %r15, %r14
movq %r14, %r8
shrq $0x1a, %r8
addq %rcx, %r8
movq %r8, %r9
shrq $0x1a, %r9
leaq (%r9,%r9,4), %rbp
addq %rdi, %rbp
movq %rbp, %rbx
shrq $0x1a, %rbx
addq %r13, %rbx
andq %rax, %r10
andq %rax, %r14
andq %rax, %r8
andq %rax, %rbp
movq %r8, %rcx
movq -0x48(%rsp), %rsi
jmp 0x5b6a
movq -0x38(%rsp), %rax
movq %rbp, (%rax)
movq %rbx, 0x8(%rax)
movq %r10, 0x10(%rax)
movq %r14, 0x18(%rax)
movq %rcx, 0x20(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq