// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/aes.c
// Function: aesDecrypt
void aesDecrypt(const u32 rk[/*4*(Nr + 1)*/], const u8 ct[], u8 pt[]) {
	u32 s0, s1, s2, s3, t0, t1, t2, t3;
    int Nr=10;
    int r;


    /*
	 * map byte array block to cipher state
	 * and add initial round key:
	 */
    s0 = GETU32(ct     ) ^ rk[0];
    s1 = GETU32(ct +  4) ^ rk[1];
    s2 = GETU32(ct +  8) ^ rk[2];
    s3 = GETU32(ct + 12) ^ rk[3];

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

        rk += 8;
        if (--r == 0) {
            break;
        }

        s0 =
            Td0[(t0 >> 24)       ] ^
            Td1[(t3 >> 16) & 0xff] ^
            Td2[(t2 >>  8) & 0xff] ^
            Td3[(t1      ) & 0xff] ^
            rk[0];
        s1 =
            Td0[(t1 >> 24)       ] ^
            Td1[(t0 >> 16) & 0xff] ^
            Td2[(t3 >>  8) & 0xff] ^
            Td3[(t2      ) & 0xff] ^
            rk[1];
        s2 =
            Td0[(t2 >> 24)       ] ^
            Td1[(t1 >> 16) & 0xff] ^
            Td2[(t0 >>  8) & 0xff] ^
            Td3[(t3      ) & 0xff] ^
            rk[2];
        s3 =
            Td0[(t3 >> 24)       ] ^
            Td1[(t2 >> 16) & 0xff] ^
            Td2[(t1 >>  8) & 0xff] ^
            Td3[(t0      ) & 0xff] ^
            rk[3];
    }
    /*
	 * apply last round and
	 * map cipher state to byte array block:
	 */
   	s0 =
   		(Td4[(t0 >> 24)       ] & 0xff000000) ^
   		(Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t1      ) & 0xff] & 0x000000ff) ^
   		rk[0];
	PUTU32(pt     , s0);
   	s1 =
   		(Td4[(t1 >> 24)       ] & 0xff000000) ^
   		(Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t2      ) & 0xff] & 0x000000ff) ^
   		rk[1];
	PUTU32(pt +  4, s1);
   	s2 =
   		(Td4[(t2 >> 24)       ] & 0xff000000) ^
   		(Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t3      ) & 0xff] & 0x000000ff) ^
   		rk[2];
	PUTU32(pt +  8, s2);
   	s3 =
   		(Td4[(t3 >> 24)       ] & 0xff000000) ^
   		(Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
   		(Td4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
   		(Td4[(t0      ) & 0xff] & 0x000000ff) ^
   		rk[3];
	PUTU32(pt + 12, s3);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movbel (%rsi), %r14d
xorl (%rdi), %r14d
movbel 0x4(%rsi), %ebp
xorl 0x4(%rdi), %ebp
movbel 0x8(%rsi), %r9d
movq %rdx, -0x8(%rsp)
movq %rdi, -0x10(%rsp)
xorl 0x8(%rdi), %r9d
movbel 0xc(%rsi), %edx
xorl %r8d, %r8d
movl $0xff, %r11d
movq -0x10(%rsp), %rbx
xorl 0xc(%rbx,%r8), %edx
movl %r14d, %ecx
shrl $0x18, %ecx
movl %edx, %eax
shrl $0xe, %eax
movl $0x3fc, %esi            # imm = 0x3FC
andl %esi, %eax
movl $0x3fc, %r13d           # imm = 0x3FC
leaq 0x4e59(%rip), %r15      # 0x7830
movl (%rax,%r15), %eax
leaq 0x4a4e(%rip), %r10      # 0x7430
xorl (%r10,%rcx,4), %eax
movl %r9d, %ecx
shrl $0x8, %ecx
andl %r11d, %ecx
leaq 0x523a(%rip), %r12      # 0x7c30
xorl (%r12,%rcx,4), %eax
movl %ebp, %ecx
andl %r11d, %ecx
leaq 0x562a(%rip), %rdi      # 0x8030
xorl (%rdi,%rcx,4), %eax
movl %ebp, %esi
shrl $0x18, %esi
movl %r14d, %ecx
shrl $0xe, %ecx
andl %r13d, %ecx
movl (%rcx,%r15), %ecx
xorl (%r10,%rsi,4), %ecx
movl %edx, %esi
shrl $0x8, %esi
andl %r11d, %esi
xorl (%r12,%rsi,4), %ecx
movl %r9d, %esi
andl %r11d, %esi
xorl (%rdi,%rsi,4), %ecx
movl %r9d, %r13d
shrl $0x18, %r13d
movl %ebp, %esi
shrl $0xe, %esi
movl $0x3fc, %edi            # imm = 0x3FC
andl %edi, %esi
movl (%rsi,%r15), %esi
xorl (%r10,%r13,4), %esi
movl %r14d, %r13d
shrl $0x8, %r13d
andl %r11d, %r13d
xorl (%r12,%r13,4), %esi
movl %edx, %r13d
andl %r11d, %r13d
leaq 0x55c6(%rip), %rdi      # 0x8030
xorl (%rdi,%r13,4), %esi
shrl $0x18, %edx
shrl $0xe, %r9d
movl $0x3fc, %r13d           # imm = 0x3FC
andl %r13d, %r9d
movl (%r9,%r15), %r13d
xorl (%r10,%rdx,4), %r13d
shrl $0x8, %ebp
andl %r11d, %ebp
xorl (%r12,%rbp,4), %r13d
xorl 0x10(%rbx,%r8), %eax
xorl 0x14(%rbx,%r8), %ecx
xorl 0x18(%rbx,%r8), %esi
andl %r11d, %r14d
xorl (%rdi,%r14,4), %r13d
xorl 0x1c(%rbx,%r8), %r13d
movl %eax, %r9d
shrl $0x18, %r9d
cmpl $0x80, %r8d
je 0x2b9c
movl %r13d, %edx
shrl $0xe, %edx
movl $0x3fc, %ebx            # imm = 0x3FC
andl %ebx, %edx
leaq 0x4d5d(%rip), %r15      # 0x7830
movl (%rdx,%r15), %r14d
leaq 0x4952(%rip), %r10      # 0x7430
xorl (%r10,%r9,4), %r14d
movl %esi, %edx
shrl $0x8, %edx
andl %r11d, %edx
leaq 0x513f(%rip), %r12      # 0x7c30
xorl (%r12,%rdx,4), %r14d
movl %ecx, %edx
andl %r11d, %edx
leaq 0x552f(%rip), %rdi      # 0x8030
xorl (%rdi,%rdx,4), %r14d
movl %ecx, %edx
shrl $0x18, %edx
movl %eax, %r9d
shrl $0xe, %r9d
andl %ebx, %r9d
movl (%r9,%r15), %ebp
xorl (%r10,%rdx,4), %ebp
movl %r13d, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorl (%r12,%rdx,4), %ebp
movl %esi, %edx
andl %r11d, %edx
xorl (%rdi,%rdx,4), %ebp
movl %esi, %edx
shrl $0x18, %edx
movl %ecx, %r9d
shrl $0xe, %r9d
andl %ebx, %r9d
movl (%r9,%r15), %r9d
xorl (%r10,%rdx,4), %r9d
movl %eax, %edx
shrl $0x8, %edx
andl %r11d, %edx
xorl (%r12,%rdx,4), %r9d
movl %r13d, %edx
andl %r11d, %edx
xorl (%rdi,%rdx,4), %r9d
shrl $0x18, %r13d
shrl $0xe, %esi
andl %ebx, %esi
movl (%rsi,%r15), %edx
xorl (%r10,%r13,4), %edx
shrl $0x8, %ecx
andl %r11d, %ecx
xorl (%r12,%rcx,4), %edx
andl %r11d, %eax
xorl (%rdi,%rax,4), %edx
movq -0x10(%rsp), %rax
xorl 0x20(%rax,%r8), %r14d
xorl 0x24(%rax,%r8), %ebp
xorl 0x28(%rax,%r8), %r9d
addq $0x20, %r8
jmp 0x29ae
leaq 0x688d(%rip), %rdx      # 0x9430
movzbl 0x3(%rdx,%r9,4), %r8d
shll $0x18, %r8d
movl %r13d, %r10d
shrl $0xe, %r10d
movl $0x3fc, %r9d            # imm = 0x3FC
andl %r9d, %r10d
movzbl 0x2(%r10,%rdx), %r10d
shll $0x10, %r10d
orl %r8d, %r10d
movl %esi, %r11d
shrl $0x8, %r11d
movl $0xff, %r8d
andl %r8d, %r11d
movzbl 0x1(%rdx,%r11,4), %r11d
shll $0x8, %r11d
orl %r10d, %r11d
movl %ecx, %r10d
andl %r8d, %r10d
movzbl (%rdx,%r10,4), %r10d
orl %r11d, %r10d
movq -0x10(%rsp), %rdi
xorl 0xa0(%rdi), %r10d
movq -0x8(%rsp), %rbx
movbel %r10d, (%rbx)
movl %ecx, %r10d
shrl $0x18, %r10d
movzbl 0x3(%rdx,%r10,4), %r10d
shll $0x18, %r10d
movl %eax, %r11d
shrl $0xe, %r11d
andl %r9d, %r11d
movzbl 0x2(%r11,%rdx), %r11d
shll $0x10, %r11d
orl %r10d, %r11d
movl %r13d, %r10d
shrl $0x8, %r10d
andl %r8d, %r10d
movzbl 0x1(%rdx,%r10,4), %r10d
shll $0x8, %r10d
orl %r11d, %r10d
movl %esi, %r11d
andl %r8d, %r11d
movzbl (%rdx,%r11,4), %r11d
orl %r10d, %r11d
xorl 0xa4(%rdi), %r11d
movbel %r11d, 0x4(%rbx)
movl %esi, %r10d
shrl $0x18, %r10d
movzbl 0x3(%rdx,%r10,4), %r10d
shll $0x18, %r10d
movl %ecx, %r11d
shrl $0xe, %r11d
andl %r9d, %r11d
movzbl 0x2(%r11,%rdx), %r11d
shll $0x10, %r11d
orl %r10d, %r11d
movl %eax, %r10d
shrl $0x8, %r10d
andl %r8d, %r10d
movzbl 0x1(%rdx,%r10,4), %r10d
shll $0x8, %r10d
orl %r11d, %r10d
movl %r13d, %r11d
andl %r8d, %r11d
movzbl (%rdx,%r11,4), %r11d
orl %r10d, %r11d
xorl 0xa8(%rdi), %r11d
movbel %r11d, 0x8(%rbx)
shrl $0x18, %r13d
movzbl 0x3(%rdx,%r13,4), %r10d
shll $0x18, %r10d
shrl $0xe, %esi
andl %r9d, %esi
movzbl 0x2(%rsi,%rdx), %esi
shll $0x10, %esi
orl %r10d, %esi
shrl $0x8, %ecx
andl %r8d, %ecx
movzbl 0x1(%rdx,%rcx,4), %ecx
shll $0x8, %ecx
orl %esi, %ecx
andl %r8d, %eax
movzbl (%rdx,%rax,4), %eax
orl %ecx, %eax
xorl 0xac(%rdi), %eax
movbel %eax, 0xc(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)