// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/deoxyseq256128v13/ref/tweakableBC.c
// Function: deoxysKeySetupDec256
int deoxysKeySetupDec256(uint32_t* rtweakey, 
                         const uint8_t* TweakKey,
                         int no_tweakeys)
{

    int i;
    int j;
    int Nr;
    uint32_t temp;

    /* Produce the round tweakeys used for the encryption */
    Nr=deoxysKeySetupEnc256 (rtweakey, TweakKey, no_tweakeys);

    /* invert their order */
    for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) {
        temp = rtweakey[i    ]; rtweakey[i    ] = rtweakey[j    ]; rtweakey[j    ] = temp;
        temp = rtweakey[i + 1]; rtweakey[i + 1] = rtweakey[j + 1]; rtweakey[j + 1] = temp;
        temp = rtweakey[i + 2]; rtweakey[i + 2] = rtweakey[j + 2]; rtweakey[j + 2] = temp;
        temp = rtweakey[i + 3]; rtweakey[i + 3] = rtweakey[j + 3]; rtweakey[j + 3] = temp;
    }

    /* apply the inverse MixColumn transform to all round keys but the first and the last */
    for (i = 1; i <= Nr; i++) {
        rtweakey += 4;
        rtweakey[0] =
            Td0[Te4[(rtweakey[0] >> 24)       ] & 0xff] ^
            Td1[Te4[(rtweakey[0] >> 16) & 0xff] & 0xff] ^
            Td2[Te4[(rtweakey[0] >>  8) & 0xff] & 0xff] ^
            Td3[Te4[(rtweakey[0]      ) & 0xff] & 0xff];
        rtweakey[1] =
            Td0[Te4[(rtweakey[1] >> 24)       ] & 0xff] ^
            Td1[Te4[(rtweakey[1] >> 16) & 0xff] & 0xff] ^
            Td2[Te4[(rtweakey[1] >>  8) & 0xff] & 0xff] ^
            Td3[Te4[(rtweakey[1]      ) & 0xff] & 0xff];
        rtweakey[2] =
            Td0[Te4[(rtweakey[2] >> 24)       ] & 0xff] ^
            Td1[Te4[(rtweakey[2] >> 16) & 0xff] & 0xff] ^
            Td2[Te4[(rtweakey[2] >>  8) & 0xff] & 0xff] ^
            Td3[Te4[(rtweakey[2]      ) & 0xff] & 0xff];
        rtweakey[3] =
            Td0[Te4[(rtweakey[3] >> 24)       ] & 0xff] ^
            Td1[Te4[(rtweakey[3] >> 16) & 0xff] & 0xff] ^
            Td2[Te4[(rtweakey[3] >>  8) & 0xff] & 0xff] ^
            Td3[Te4[(rtweakey[3]      ) & 0xff] & 0xff];
    }
    return Nr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x10a0
leal (,%rax,4), %ecx
xorl %edx, %edx
cmpq %rcx, %rdx
jge 0x20c3
movl (%rbx,%rdx,4), %esi
movl (%rbx,%rcx,4), %edi
movl %edi, (%rbx,%rdx,4)
movl %esi, (%rbx,%rcx,4)
movl 0x4(%rbx,%rdx,4), %esi
movl 0x4(%rbx,%rcx,4), %edi
movl %edi, 0x4(%rbx,%rdx,4)
movl %esi, 0x4(%rbx,%rcx,4)
movl 0x8(%rbx,%rdx,4), %esi
movl 0x8(%rbx,%rcx,4), %edi
movl %edi, 0x8(%rbx,%rdx,4)
movl %esi, 0x8(%rbx,%rcx,4)
movl 0xc(%rbx,%rdx,4), %esi
movl 0xc(%rbx,%rcx,4), %edi
movl %edi, 0xc(%rbx,%rdx,4)
movl %esi, 0xc(%rbx,%rcx,4)
addq $0x4, %rdx
addq $-0x4, %rcx
jmp 0x2078
movl %eax, %ecx
shlq $0x4, %rcx
xorl %edx, %edx
leaq 0x348e(%rip), %rsi      # 0x5560
leaq 0x3087(%rip), %rdi      # 0x5160
movl $0x3fc, %r8d            # imm = 0x3FC
leaq 0x387a(%rip), %r9       # 0x5960
movl $0xff, %r10d
leaq 0x3c6d(%rip), %r11      # 0x5d60
leaq 0x4066(%rip), %r14      # 0x6160
cmpl %edx, %ecx
je 0x2239
movl 0x10(%rbx,%rdx), %r12d
movl 0x14(%rbx,%rdx), %r15d
movl %r12d, %r13d
shrl $0x18, %r13d
movzbl (%rsi,%r13,4), %r13d
movl %r12d, %ebp
shrl $0xe, %ebp
andl %r8d, %ebp
movzbl (%rbp,%rsi), %ebp
movl (%r9,%rbp,4), %ebp
xorl (%rdi,%r13,4), %ebp
movl %r12d, %r13d
shrl $0x8, %r13d
andl %r10d, %r13d
movzbl (%rsi,%r13,4), %r13d
xorl (%r11,%r13,4), %ebp
andl %r10d, %r12d
movzbl (%rsi,%r12,4), %r12d
xorl (%r14,%r12,4), %ebp
movl %ebp, 0x10(%rbx,%rdx)
movl %r15d, %r12d
shrl $0x18, %r12d
movzbl (%rsi,%r12,4), %r12d
movl %r15d, %r13d
shrl $0xe, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movl (%r9,%r13,4), %ebp
xorl (%rdi,%r12,4), %ebp
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,4), %r12d
xorl (%r11,%r12,4), %ebp
andl %r10d, %r15d
movzbl (%rsi,%r15,4), %r15d
xorl (%r14,%r15,4), %ebp
movl %ebp, 0x14(%rbx,%rdx)
movl 0x18(%rbx,%rdx), %r15d
movl %r15d, %r12d
shrl $0x18, %r12d
movzbl (%rsi,%r12,4), %r12d
movl %r15d, %r13d
shrl $0xe, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movl (%r9,%r13,4), %ebp
xorl (%rdi,%r12,4), %ebp
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,4), %r12d
xorl (%r11,%r12,4), %ebp
andl %r10d, %r15d
movzbl (%rsi,%r15,4), %r15d
xorl (%r14,%r15,4), %ebp
movl %ebp, 0x18(%rbx,%rdx)
movl 0x1c(%rbx,%rdx), %r15d
movl %r15d, %r12d
shrl $0x18, %r12d
movzbl (%rsi,%r12,4), %r12d
movl %r15d, %r13d
shrl $0xe, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movl (%r9,%r13,4), %ebp
xorl (%rdi,%r12,4), %ebp
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,4), %r12d
xorl (%r11,%r12,4), %ebp
andl %r10d, %r15d
movzbl (%rsi,%r15,4), %r15d
xorl (%r14,%r15,4), %ebp
movl %ebp, 0x1c(%rbx,%rdx)
addq $0x10, %rdx
jmp 0x20fa
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq