// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/stribob192r2/8bit/wbob_pi8.c
// Function: wbob_pi
void wbob_pi(w512_t *s512)
{
    int r, i, j;
    uint8_t t[64], x, *pt;

    for (r = 0; r < 12; r++) {                      // 12 rounds

        for (i = 0; i < 64; i++) {
            t[(i & 7) + ((i + (i << 3)) & 070)] =   // P
                wbob_sbox[s512->b[i]];              // S
        }

        // The round constants C comes from the S-box
        pt = (uint8_t *) &wbob_sbox[8 * r];
        for (i = 0; i < 8; i++)
            s512->b[i] = pt[i];                     // C in first 8
        for (i = 8; i < 64; i++)
            s512->b[i] = 0;                         // zero the rest

        // Apply the circular, low weight MDS matrix
        for (i = 0; i < 64; i += 8) {
            pt = &s512->b[i];                       // start of row
            for (j = 0; j < 8; j++) {
                x = t[i + j];                       // Circular MDS
                pt[j & 7] ^= x;                     // 01
                pt[(j + 1) & 7] ^= x;               // 01
                pt[(j + 3) & 7] ^= x;               // 01
                pt[(j + 5) & 7] ^= x;
                pt[(j + 7) & 7] ^= x;

                // x <- 02
                x = (x << 1) ^ (x & 0x80 ? 0x1D : 0x00);
                pt[(j + 6) & 7] ^= x;               // 02

                // x <- 04
                x = (x << 1) ^ (x & 0x80 ? 0x1D : 0x00);
                pt[(j + 2) & 7] ^= x;               // 04
                pt[(j + 5) & 7] ^= x;               // 01 + 04 = 05

                // x <- 08
                x = (x << 1) ^ (x & 0x80 ? 0x1D : 0x00);
                pt[(j + 4) & 7] ^= x;               // 08
                pt[(j + 7) & 7] ^= x;               // 01 + 08 = 09
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0xa1f(%rip), %rax       # 0x2000
xorl %ecx, %ecx
movq %rax, %r8
cmpq $0xc, %rcx
je 0x171e
xorl %edx, %edx
xorl %r9d, %r9d
cmpq $0x40, %r9
je 0x1621
movzbl (%rdi,%r9), %r10d
movb (%r10,%rax), %r10b
movl %r9d, %r11d
andl $0x7, %r11d
movl %edx, %ebx
andl $0x38, %ebx
orq %r11, %rbx
movb %r10b, -0x48(%rsp,%rbx)
incq %r9
addq $0x9, %rdx
jmp 0x15f5
xorl %edx, %edx
cmpq $0x8, %rdx
je 0x1636
movb (%r8,%rdx), %r9b
movb %r9b, (%rdi,%rdx)
incq %rdx
jmp 0x1623
movabsq $0x8, %rdx
cmpq $0x40, %rdx
je 0x164f
movb $0x0, (%rdi,%rdx)
incq %rdx
jmp 0x1640
leaq -0x48(%rsp), %r9
movq %rdi, %r10
xorl %r11d, %r11d
cmpq $0x3f, %r11
ja 0x1712
leaq (%rdi,%r11), %rbx
xorl %r14d, %r14d
cmpq $0x8, %r14
je 0x1701
movb (%r9,%r14), %r15b
xorb %r15b, (%r10,%r14)
leaq 0x1(%r14), %r12
movl %r12d, %edx
andl $0x7, %edx
xorb %r15b, (%rbx,%rdx)
leal 0x3(%r14), %edx
andl $0x7, %edx
xorb %r15b, (%rbx,%rdx)
leal 0x5(%r14), %ebp
andl $0x7, %ebp
xorb %r15b, (%rbx,%rbp)
leal -0x1(%r14), %r13d
andl $0x7, %r13d
xorb %r15b, (%rbx,%r13)
leal (%r15,%r15), %edx
sarb $0x7, %r15b
andb $0x1d, %r15b
xorb %dl, %r15b
leal 0x6(%r14), %esi
andl $0x7, %esi
xorb %r15b, (%rbx,%rsi)
addb %r15b, %r15b
sarb $0x7, %dl
andb $0x1d, %dl
xorb %r15b, %dl
leal 0x2(%r14), %esi
andl $0x7, %esi
xorb %dl, (%rbx,%rsi)
xorb %dl, (%rbx,%rbp)
addb %dl, %dl
sarb $0x7, %r15b
andb $0x1d, %r15b
xorb %dl, %r15b
xorq $0x4, %r14
xorb %r15b, (%rbx,%r14)
xorb %r15b, (%rbx,%r13)
movq %r12, %r14
jmp 0x166b
addq $0x8, %r11
addq $0x8, %r10
addq $0x8, %r9
jmp 0x165a
incq %rcx
addq $0x8, %r8
jmp 0x15e6
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)