// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/shellaes.c
// Function: KeySetupDec
void KeySetupDec(u32 mk[], u32 sk[], u32 isk[], u8 L[], u8 Lprime[], u8 keyprime[], const u32 rk[], const u8 key[]){

    int i;
    u32 temp;

    KeySetupEnc(mk, sk, L, Lprime, keyprime, rk, key);

    memcpy(isk, sk, 48*d);

    /*inverse the order of round keys for each auxiliary permutation */
    for(i=0; i<d; ++i){
        temp=isk[12*i  ]; isk[12*i  ]=isk[12*i+ 8]; isk[12*i+ 8]=temp;
        temp=isk[12*i+1]; isk[12*i+1]=isk[12*i+ 9]; isk[12*i+ 9]=temp;
        temp=isk[12*i+2]; isk[12*i+2]=isk[12*i+10]; isk[12*i+10]=temp;
        temp=isk[12*i+3]; isk[12*i+3]=isk[12*i+11]; isk[12*i+11]=temp;
    }


    /*apply inverse mixcolumn to the round keys*/
    for(i=0; i< 12*d; ++i){
        isk[i] =
			Td0[Te4[(isk[i] >> 24)       ] & 0xff] ^
			Td1[Te4[(isk[i] >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(isk[i] >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(isk[i]      ) & 0xff] & 0xff];
    }
}

// Assembly:
subq $0x48, %rsp
movq 0x58(%rsp), %rax
movq 0x50(%rsp), %rax
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0x58(%rsp), %rax
movq %rax, (%rsp)
callq 0x2230
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl $0xf0, %edx
callq 0x2270
movl $0x0, 0x14(%rsp)
cmpl $0x5, 0x14(%rsp)
jge 0x5819
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x10(%rsp)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0x10(%rsp), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x10(%rsp)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0x10(%rsp), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x10(%rsp)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0x10(%rsp), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x10(%rsp)
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0xb, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0x10(%rsp), %edx
movq 0x30(%rsp), %rax
imull $0xc, 0x14(%rsp), %ecx
addl $0xb, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x56b4
movl $0x0, 0x14(%rsp)
cmpl $0x3c, 0x14(%rsp)
jge 0x5919
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8bf9(%rip), %rax      # 0xe440
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x87e6(%rip), %rax      # 0xe040
movl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8bc3(%rip), %rax      # 0xe440
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8fb0(%rip), %rax      # 0xe840
xorl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8b8d(%rip), %rax      # 0xe440
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x937a(%rip), %rax      # 0xec40
xorl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x8b5a(%rip), %rax      # 0xe440
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x9747(%rip), %rax      # 0xf040
xorl (%rax,%rcx,4), %edx
movq 0x30(%rsp), %rax
movslq 0x14(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x5821
addq $0x48, %rsp
retq
nop