// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/aesReduced.c
// Function: aesReducedDec
void aesReducedDec(const u32 mk[], const u32 sk[], const u8 ct[], u8 pt[]){
    u32 s0, s1, s2, s3, t0, t1, t2, t3;

    s0 = GETU32(ct     );
	s1 = GETU32(ct +  4);
	s2 = GETU32(ct +  8);
	s3 = GETU32(ct + 12);

    /*apply inverse of mixcolumn to s0-s3 */

    s0 =
			Td0[Te4[(s0 >> 24)       ] & 0xff] ^
			Td1[Te4[(s0 >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(s0 >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(s0      ) & 0xff] & 0xff];

    s1 =
			Td0[Te4[(s1 >> 24)       ] & 0xff] ^
			Td1[Te4[(s1 >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(s1 >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(s1      ) & 0xff] & 0xff];

    s2 =
			Td0[Te4[(s2 >> 24)       ] & 0xff] ^
			Td1[Te4[(s2 >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(s2 >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(s2      ) & 0xff] & 0xff];

    s3 =
			Td0[Te4[(s3 >> 24)       ] & 0xff] ^
			Td1[Te4[(s3 >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(s3 >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(s3      ) & 0xff] & 0xff];

    /*Decryption procedure*/

    t0 =
            Td0[(s0 >> 24)       ] ^
            Td1[(s3 >> 16) & 0xff] ^
            Td2[(s2 >>  8) & 0xff] ^
            Td3[(s1      ) & 0xff] ^
            sk[0];
    t1 =
            Td0[(s1 >> 24)       ] ^
            Td1[(s0 >> 16) & 0xff] ^
            Td2[(s3 >>  8) & 0xff] ^
            Td3[(s2      ) & 0xff] ^
            sk[1];
    t2 =
            Td0[(s2 >> 24)       ] ^
            Td1[(s1 >> 16) & 0xff] ^
            Td2[(s0 >>  8) & 0xff] ^
            Td3[(s3      ) & 0xff] ^
            sk[2];

    t3 =
            Td0[(s3 >> 24)       ] ^
            Td1[(s2 >> 16) & 0xff] ^
            Td2[(s1 >>  8) & 0xff] ^
            Td3[(s0      ) & 0xff] ^
            sk[3];

    s0 =
            Td0[(t0 >> 24)       ] ^
            Td1[(t3 >> 16) & 0xff] ^
            Td2[(t2 >>  8) & 0xff] ^
            Td3[(t1      ) & 0xff] ^
            sk[4];
    s1 =
            Td0[(t1 >> 24)       ] ^
            Td1[(t0 >> 16) & 0xff] ^
            Td2[(t3 >>  8) & 0xff] ^
            Td3[(t2      ) & 0xff] ^
            sk[5];
    s2 =
            Td0[(t2 >> 24)       ] ^
            Td1[(t1 >> 16) & 0xff] ^
            Td2[(t0 >>  8) & 0xff] ^
            Td3[(t3      ) & 0xff] ^
            sk[6];
    s3 =
            Td0[(t3 >> 24)       ] ^
            Td1[(t2 >> 16) & 0xff] ^
            Td2[(t1 >>  8) & 0xff] ^
            Td3[(t0      ) & 0xff] ^
            sk[7];

    t0 =
            Td0[(s0 >> 24)       ] ^
            Td1[(s3 >> 16) & 0xff] ^
            Td2[(s2 >>  8) & 0xff] ^
            Td3[(s1      ) & 0xff] ^
            sk[8];
    t1 =
            Td0[(s1 >> 24)       ] ^
            Td1[(s0 >> 16) & 0xff] ^
            Td2[(s3 >>  8) & 0xff] ^
            Td3[(s2      ) & 0xff] ^
            sk[9];
    t2 =
            Td0[(s2 >> 24)       ] ^
            Td1[(s1 >> 16) & 0xff] ^
            Td2[(s0 >>  8) & 0xff] ^
            Td3[(s3      ) & 0xff] ^
            sk[10];

    t3 =
            Td0[(s3 >> 24)       ] ^
            Td1[(s2 >> 16) & 0xff] ^
            Td2[(s1 >>  8) & 0xff] ^
            Td3[(s0      ) & 0xff] ^
            sk[11];

    s0 =
   		(Td4[(t0 >> 24)       ] & 0xff000000) ^
   		(Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t1      ) & 0xff] & 0x000000ff) ^
   		mk[0];

	PUTU32(pt     , s0);

   	s1 =
   		(Td4[(t1 >> 24)       ] & 0xff000000) ^
   		(Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t2      ) & 0xff] & 0x000000ff) ^
   		mk[1];

	PUTU32(pt +  4, s1);

   	s2 =
   		(Td4[(t2 >> 24)       ] & 0xff000000) ^
   		(Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t3      ) & 0xff] & 0x000000ff) ^
   		mk[2];

	PUTU32(pt +  8, s2);

   	s3 =
   		(Td4[(t3 >> 24)       ] & 0xff000000) ^
   		(Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t0      ) & 0xff] & 0x000000ff) ^
   		mk[3];

	PUTU32(pt + 12, s3);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movzbl (%rdx), %r9d
movzbl 0x1(%rdx), %r11d
movzbl 0x2(%rdx), %r13d
movzbl 0x3(%rdx), %r12d
movzbl 0x4(%rdx), %r15d
movzbl 0x5(%rdx), %ebx
movzbl 0x6(%rdx), %r10d
movzbl 0x7(%rdx), %r8d
leaq 0x6aa7(%rip), %rax      # 0x9c30
movzbl (%rax,%r9,4), %r9d
leaq 0x669b(%rip), %rbp      # 0x9830
movzbl (%rax,%r11,4), %r14d
leaq 0x6e8f(%rip), %r11      # 0xa030
movl (%r11,%r14,4), %r14d
xorl (%rbp,%r9,4), %r14d
movzbl (%rax,%r13,4), %r9d
leaq 0x727a(%rip), %r11      # 0xa430
xorl (%r11,%r9,4), %r14d
movzbl 0x8(%rdx), %r9d
movzbl (%rax,%r12,4), %r12d
leaq 0x7665(%rip), %r11      # 0xa830
xorl (%r11,%r12,4), %r14d
movzbl 0x9(%rdx), %r11d
movq %r11, -0x8(%rsp)
movzbl (%rax,%r15,4), %r13d
movzbl (%rax,%rbx,4), %ebx
leaq 0x6e47(%rip), %r11      # 0xa030
movl (%r11,%rbx,4), %r15d
movq %rbp, %r12
xorl (%rbp,%r13,4), %r15d
movzbl 0xa(%rdx), %ebx
movzbl (%rax,%r10,4), %r10d
leaq 0x722b(%rip), %rbp      # 0xa430
xorl (%rbp,%r10,4), %r15d
movzbl (%rax,%r8,4), %r8d
leaq 0x761a(%rip), %r10      # 0xa830
xorl (%r10,%r8,4), %r15d
movzbl 0xb(%rdx), %r8d
movzbl (%rax,%r9,4), %r9d
movq -0x8(%rsp), %r10
movzbl (%rax,%r10,4), %r10d
movl (%r11,%r10,4), %r13d
xorl (%r12,%r9,4), %r13d
movq %r12, %r11
movzbl 0xc(%rdx), %r9d
movzbl 0xd(%rdx), %r10d
movzbl (%rax,%rbx,4), %ebx
xorl (%rbp,%rbx,4), %r13d
movzbl 0xe(%rdx), %ebx
movzbl 0xf(%rdx), %edx
movzbl (%rax,%r8,4), %r8d
leaq 0x75d0(%rip), %r12      # 0xa830
xorl (%r12,%r8,4), %r13d
movzbl (%rax,%r9,4), %r8d
movzbl (%rax,%r10,4), %r9d
leaq 0x6dbb(%rip), %r10      # 0xa030
movl (%r10,%r9,4), %ebp
xorl (%r11,%r8,4), %ebp
movzbl (%rax,%rbx,4), %r8d
leaq 0x71a7(%rip), %r9       # 0xa430
xorl (%r9,%r8,4), %ebp
movzbl (%rax,%rdx,4), %eax
xorl (%r12,%rax,4), %ebp
movl %r14d, %eax
shrl $0x18, %eax
movl %ebp, %r8d
shrl $0xe, %r8d
movl $0x3fc, %edx            # imm = 0x3FC
andl %edx, %r8d
movl (%r8,%r10), %ebx
xorl (%r11,%rax,4), %ebx
movl %r13d, %r8d
shrl $0x8, %r8d
movl $0xff, %edx
andl %edx, %r8d
xorl (%r9,%r8,4), %ebx
movq %r9, %r11
movl %r15d, %r8d
andl %edx, %r8d
xorl (%r12,%r8,4), %ebx
movq %r12, %r10
movl %r15d, %r8d
shrl $0x18, %r8d
movl %r14d, %r9d
shrl $0xe, %r9d
movl $0x3fc, %eax            # imm = 0x3FC
andl %eax, %r9d
leaq 0x6d3e(%rip), %rax      # 0xa030
movl (%r9,%rax), %r12d
leaq 0x6533(%rip), %r9       # 0x9830
xorl (%r9,%r8,4), %r12d
movl %ebp, %r8d
shrl $0x8, %r8d
andl %edx, %r8d
xorl (%r11,%r8,4), %r12d
movl %r13d, %r8d
andl %edx, %r8d
xorl (%r10,%r8,4), %r12d
movl %r13d, %r8d
shrl $0x18, %r8d
movl %r15d, %r9d
shrl $0xe, %r9d
movl $0x3fc, %r10d           # imm = 0x3FC
andl %r10d, %r9d
movl (%r9,%rax), %r10d
leaq 0x64f5(%rip), %r11      # 0x9830
xorl (%r11,%r8,4), %r10d
movl %r14d, %r8d
shrl $0x8, %r8d
andl %edx, %r8d
leaq 0x70e0(%rip), %r9       # 0xa430
xorl (%r9,%r8,4), %r10d
movl %ebp, %r8d
andl %edx, %r8d
leaq 0x74cf(%rip), %r9       # 0xa830
xorl (%r9,%r8,4), %r10d
shrl $0x18, %ebp
shrl $0xe, %r13d
movl $0x3fc, %r8d            # imm = 0x3FC
andl %r8d, %r13d
movl (%r13,%rax), %r8d
xorl (%r11,%rbp,4), %r8d
movq %r11, %rbp
xorl (%rsi), %ebx
xorl 0x4(%rsi), %r12d
xorl 0x8(%rsi), %r10d
shrl $0x8, %r15d
andl %edx, %r15d
leaq 0x7097(%rip), %r11      # 0xa430
xorl (%r11,%r15,4), %r8d
andl %edx, %r14d
movq %r9, %r13
xorl (%r9,%r14,4), %r8d
xorl 0xc(%rsi), %r8d
movl %ebx, %r9d
shrl $0x18, %r9d
movl %r8d, %r14d
shrl $0xe, %r14d
movl $0x3fc, %r15d           # imm = 0x3FC
andl %r15d, %r14d
movl (%r14,%rax), %r15d
xorl (%rbp,%r9,4), %r15d
movl %r10d, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
xorl (%r11,%r9,4), %r15d
movl %r12d, %r9d
andl %edx, %r9d
xorl (%r13,%r9,4), %r15d
movq %r13, %r11
movl %r12d, %r9d
shrl $0x18, %r9d
movl %ebx, %r14d
shrl $0xe, %r14d
movl $0x3fc, %r13d           # imm = 0x3FC
andl %r13d, %r14d
movl (%r14,%rax), %r13d
xorl (%rbp,%r9,4), %r13d
movl %r8d, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
leaq 0x7018(%rip), %r14      # 0xa430
xorl (%r14,%r9,4), %r13d
movl %r10d, %r9d
andl %edx, %r9d
xorl (%r11,%r9,4), %r13d
movl %r10d, %r9d
shrl $0x18, %r9d
movl %r12d, %r14d
shrl $0xe, %r14d
movl $0x3fc, %ebp            # imm = 0x3FC
andl %ebp, %r14d
movl (%r14,%rax), %ebp
leaq 0x63e9(%rip), %r14      # 0x9830
xorl (%r14,%r9,4), %ebp
movl %ebx, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
leaq 0x6fd4(%rip), %rax      # 0xa430
xorl (%rax,%r9,4), %ebp
movl %r8d, %r9d
andl %edx, %r9d
xorl (%r11,%r9,4), %ebp
shrl $0x18, %r8d
shrl $0xe, %r10d
movl $0x3fc, %r9d            # imm = 0x3FC
andl %r9d, %r10d
leaq 0x6bae(%rip), %r9       # 0xa030
movl (%r10,%r9), %r10d
xorl (%r14,%r8,4), %r10d
xorl 0x10(%rsi), %r15d
xorl 0x14(%rsi), %r13d
shrl $0x8, %r12d
andl %edx, %r12d
xorl (%rax,%r12,4), %r10d
andl %edx, %ebx
xorl (%r11,%rbx,4), %r10d
xorl 0x1c(%rsi), %r10d
movl %r15d, %r8d
shrl $0x18, %r8d
movl %r10d, %r9d
shrl $0xe, %r9d
movl $0x3fc, %eax            # imm = 0x3FC
andl %eax, %r9d
leaq 0x6b6c(%rip), %r11      # 0xa030
movl (%r9,%r11), %ebx
movq %r14, %r12
xorl (%r14,%r8,4), %ebx
movl %r13d, %r8d
shrl $0x18, %r8d
movl %r15d, %r9d
shrl $0xe, %r9d
andl %eax, %r9d
movl (%r9,%r11), %r14d
movq %r11, %rax
xorl (%r12,%r8,4), %r14d
movq %r12, %r11
xorl 0x18(%rsi), %ebp
movl %ebp, %r8d
shrl $0x18, %r8d
movl %r13d, %r9d
shrl $0xe, %r9d
movl $0x3fc, %r12d           # imm = 0x3FC
andl %r12d, %r9d
movl $0x3fc, %edx            # imm = 0x3FC
movl (%r9,%rax), %r12d
xorl (%r11,%r8,4), %r12d
movl %ebp, %r9d
movl %ebp, %r8d
shrl $0xe, %ebp
andl %edx, %ebp
movl (%rbp,%rax), %r11d
movl %r10d, %ebp
movl %r10d, %eax
shrl $0x18, %r10d
leaq 0x62fa(%rip), %rdx      # 0x9830
xorl (%rdx,%r10,4), %r11d
shrl $0x8, %r9d
movl $0xff, %edx
andl %edx, %r9d
leaq 0x6ee3(%rip), %r10      # 0xa430
xorl (%r10,%r9,4), %ebx
shrl $0x8, %ebp
andl %edx, %ebp
xorl (%r10,%rbp,4), %r14d
movl %r15d, %r9d
shrl $0x8, %r9d
andl %edx, %r9d
xorl (%r10,%r9,4), %r12d
movl %r13d, %r9d
shrl $0x8, %r13d
andl %edx, %r13d
xorl (%r10,%r13,4), %r11d
andl %edx, %r9d
leaq 0x72b0(%rip), %r10      # 0xa830
xorl (%r10,%r9,4), %ebx
andl %edx, %r8d
xorl (%r10,%r8,4), %r14d
andl %edx, %eax
xorl (%r10,%rax,4), %r12d
xorl 0x20(%rsi), %ebx
xorl 0x24(%rsi), %r14d
xorl 0x28(%rsi), %r12d
andl %edx, %r15d
xorl (%r10,%r15,4), %r11d
xorl 0x2c(%rsi), %r11d
movl %ebx, %eax
shrl $0x18, %eax
leaq 0x767d(%rip), %rsi      # 0xac30
movzbl 0x3(%rsi,%rax,4), %eax
shll $0x18, %eax
movl %r11d, %r8d
shrl $0xe, %r8d
movl $0x3fc, %r9d            # imm = 0x3FC
andl %r9d, %r8d
movzbl 0x2(%r8,%rsi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
movl %r12d, %eax
shrl $0x8, %eax
andl %edx, %eax
movzbl 0x1(%rsi,%rax,4), %eax
shll $0x8, %eax
orl %r8d, %eax
movl %r14d, %r8d
andl %edx, %r8d
movzbl (%rsi,%r8,4), %r8d
orl %eax, %r8d
xorl (%rdi), %r8d
movbel %r8d, (%rcx)
movl %r14d, %eax
shrl $0x18, %eax
movzbl 0x3(%rsi,%rax,4), %eax
shll $0x18, %eax
movl %ebx, %r8d
shrl $0xe, %r8d
andl %r9d, %r8d
movzbl 0x2(%r8,%rsi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
movl %r11d, %eax
shrl $0x8, %eax
andl %edx, %eax
movzbl 0x1(%rsi,%rax,4), %eax
shll $0x8, %eax
orl %r8d, %eax
movl %r12d, %r8d
andl %edx, %r8d
movzbl (%rsi,%r8,4), %r8d
orl %eax, %r8d
xorl 0x4(%rdi), %r8d
movbel %r8d, 0x4(%rcx)
movl %r12d, %eax
shrl $0x18, %eax
movzbl 0x3(%rsi,%rax,4), %eax
shll $0x18, %eax
movl %r14d, %r8d
shrl $0xe, %r8d
andl %r9d, %r8d
movzbl 0x2(%r8,%rsi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
movl %ebx, %eax
shrl $0x8, %eax
andl %edx, %eax
movzbl 0x1(%rsi,%rax,4), %eax
shll $0x8, %eax
orl %r8d, %eax
movl %r11d, %r8d
andl %edx, %r8d
movzbl (%rsi,%r8,4), %r8d
orl %eax, %r8d
xorl 0x8(%rdi), %r8d
movbel %r8d, 0x8(%rcx)
shrl $0xe, %r12d
andl %r9d, %r12d
shrl $0x18, %r11d
movzbl 0x3(%rsi,%r11,4), %eax
shll $0x18, %eax
movzbl 0x2(%r12,%rsi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
shrl $0x8, %r14d
andl %edx, %r14d
movzbl 0x1(%rsi,%r14,4), %eax
shll $0x8, %eax
orl %r8d, %eax
andl %edx, %ebx
movzbl (%rsi,%rbx,4), %edx
orl %eax, %edx
xorl 0xc(%rdi), %edx
movbel %edx, 0xc(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop