// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/aezv3/ref/rijndael-alg-fst.c
// Function: rijndaelDecryptRound
void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) {
	int r;
	u32 s0, s1, s2, s3, t0, t1, t2, t3;

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

    /*
	 * Nr - 1 full rounds:
	 */
	for (r = (rounds < Nr ? rounds : Nr) - 1; r > 0; r--) {
		t0 =
			Td0[(s0 >> 24)       ] ^
			Td1[(s3 >> 16) & 0xff] ^
			Td2[(s2 >>  8) & 0xff] ^
			Td3[(s1      ) & 0xff] ^
			rk[0];
		t1 =
			Td0[(s1 >> 24)       ] ^
			Td1[(s0 >> 16) & 0xff] ^
			Td2[(s3 >>  8) & 0xff] ^
			Td3[(s2      ) & 0xff] ^
			rk[1];
		t2 =
			Td0[(s2 >> 24)       ] ^
			Td1[(s1 >> 16) & 0xff] ^
			Td2[(s0 >>  8) & 0xff] ^
			Td3[(s3      ) & 0xff] ^
			rk[2];
		t3 =
			Td0[(s3 >> 24)       ] ^
			Td1[(s2 >> 16) & 0xff] ^
			Td2[(s1 >>  8) & 0xff] ^
			Td3[(s0      ) & 0xff] ^
			rk[3];

		s0 = t0;
		s1 = t1;
		s2 = t2;
		s3 = t3;
		rk += 4;

    }

    /*
	 * complete the last round and
	 * map cipher state to byte array block:
	 */
	t0 =
		(Td4[(s0 >> 24)       ] & 0xff000000) ^
		(Td4[(s3 >> 16) & 0xff] & 0x00ff0000) ^
		(Td4[(s2 >>  8) & 0xff] & 0x0000ff00) ^
		(Td4[(s1      ) & 0xff] & 0x000000ff);
	t1 =
		(Td4[(s1 >> 24)       ] & 0xff000000) ^
		(Td4[(s0 >> 16) & 0xff] & 0x00ff0000) ^
		(Td4[(s3 >>  8) & 0xff] & 0x0000ff00) ^
		(Td4[(s2      ) & 0xff] & 0x000000ff);
	t2 =
		(Td4[(s2 >> 24)       ] & 0xff000000) ^
		(Td4[(s1 >> 16) & 0xff] & 0x00ff0000) ^
		(Td4[(s0 >>  8) & 0xff] & 0x0000ff00) ^
		(Td4[(s3      ) & 0xff] & 0x000000ff);
	t3 =
		(Td4[(s3 >> 24)       ] & 0xff000000) ^
		(Td4[(s2 >> 16) & 0xff] & 0x00ff0000) ^
		(Td4[(s1 >>  8) & 0xff] & 0x0000ff00) ^
		(Td4[(s0      ) & 0xff] & 0x000000ff);

	if (rounds == Nr) {
	    t0 ^= rk[0];
	    t1 ^= rk[1];
	    t2 ^= rk[2];
	    t3 ^= rk[3];
	}

	PUTU32(block     , t0);
	PUTU32(block +  4, t1);
	PUTU32(block +  8, t2);
	PUTU32(block + 12, t3);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movbel (%rdx), %r8d
xorl (%rdi), %r8d
movbel 0x4(%rdx), %r9d
xorl 0x4(%rdi), %r9d
movbel 0x8(%rdx), %r14d
xorl 0x8(%rdi), %r14d
movq %rdx, -0x20(%rsp)
movbel 0xc(%rdx), %r10d
xorl 0xc(%rdi), %r10d
cmpl %esi, %ecx
movl %esi, -0x30(%rsp)
movl %esi, %edx
movl %ecx, -0x2c(%rsp)
cmovll %ecx, %edx
movq %rdi, -0x40(%rsp)
leaq 0x10(%rdi), %rax
cmpl $0x2, %edx
jl 0x403b
leal -0x2(%rdx), %ecx
shlq $0x4, %rcx
movq %rcx, -0x28(%rsp)
incl %edx
movl $0xff, %edi
movq %rdx, -0x38(%rsp)
movq %rax, -0x48(%rsp)
movl %r14d, %esi
movl %r10d, %r12d
movl %r10d, %r15d
movl %r14d, %eax
movq %rax, -0x8(%rsp)
movq %rax, -0x10(%rsp)
movl %r10d, %eax
movq %rax, -0x18(%rsp)
shrl $0x18, %r10d
shrl $0xe, %esi
movl $0x3fc, %eax            # imm = 0x3FC
andl %eax, %esi
leaq 0x1be1(%rip), %rdx      # 0x5af0
movl (%rsi,%rdx), %esi
leaq 0x17d7(%rip), %rax      # 0x56f0
xorl (%rax,%r10,4), %esi
movl %r8d, %ecx
movl %r9d, %r13d
movl %r9d, %eax
movl %r8d, %r11d
movl %r9d, %r10d
shrl $0x8, %r9d
andl %edi, %r9d
leaq 0x1fb6(%rip), %rbp      # 0x5ef0
xorl (%rbp,%r9,4), %esi
movl %r8d, %ebx
andl %edi, %r8d
leaq 0x23a4(%rip), %rbp      # 0x62f0
xorl (%rbp,%r8,4), %esi
shrl $0x18, %ecx
shrl $0xe, %r12d
movl $0x3fc, %r9d            # imm = 0x3FC
andl %r9d, %r12d
movl (%r12,%rdx), %r8d
leaq 0x1784(%rip), %r12      # 0x56f0
xorl (%r12,%rcx,4), %r8d
shrl $0x8, %r14d
andl %edi, %r14d
leaq 0x1f72(%rip), %rcx      # 0x5ef0
xorl (%rcx,%r14,4), %r8d
andl %edi, %r13d
xorl (%rbp,%r13,4), %r8d
shrl $0x18, %eax
shrl $0xe, %r11d
andl %r9d, %r11d
movl $0x3fc, %r14d           # imm = 0x3FC
movl (%r11,%rdx), %r9d
movq %rdx, %r11
xorl (%r12,%rax,4), %r9d
movq -0x48(%rsp), %rax
shrl $0x8, %r15d
andl %edi, %r15d
xorl (%rcx,%r15,4), %r9d
movq %rcx, %r15
movq -0x8(%rsp), %rcx
andl %edi, %ecx
xorl (%rbp,%rcx,4), %r9d
movq -0x38(%rsp), %rdx
movq -0x10(%rsp), %rcx
shrl $0x18, %ecx
shrl $0xe, %r10d
andl %r14d, %r10d
movl (%r10,%r11), %r14d
xorl (%r12,%rcx,4), %r14d
shrl $0x8, %ebx
andl %edi, %ebx
xorl (%r15,%rbx,4), %r14d
movq -0x18(%rsp), %rcx
andl %edi, %ecx
xorl (%rbp,%rcx,4), %r14d
xorl (%rax), %r8d
xorl 0x4(%rax), %r9d
xorl 0x8(%rax), %r14d
movl %esi, %r10d
xorl 0xc(%rax), %r10d
addq $0x10, %rax
decl %edx
cmpl $0x2, %edx
jg 0x3ed2
movq -0x40(%rsp), %rax
movq -0x28(%rsp), %rdx
leaq (%rax,%rdx), %rcx
addq $0x20, %rcx
movq %rcx, -0x48(%rsp)
addq %rdx, %rax
addq $0x10, %rax
movq %rax, -0x40(%rsp)
jmp 0x4040
movq %rax, -0x48(%rsp)
leaq 0x36a9(%rip), %rdx      # 0x76f0
movl %r10d, %r15d
shrl $0xe, %r15d
movl $0x3fc, %ebp            # imm = 0x3FC
andl %ebp, %r15d
movl %r14d, %esi
shrl $0x8, %esi
movl $0xff, %edi
andl %edi, %esi
movl %r9d, %eax
andl %edi, %eax
movq %rax, -0x38(%rsp)
movl %r8d, %ebx
shrl $0xe, %ebx
andl %ebp, %ebx
movl %r14d, %r11d
movl %r14d, %r12d
vmovd (%r15,%rdx), %xmm0
movl %r9d, %eax
shrl $0xe, %eax
andl %ebp, %eax
shrl $0xe, %r14d
andl %ebp, %r14d
movl %r9d, %r15d
shrl $0x18, %r15d
vpinsrd $0x1, (%rdx,%r15,4), %xmm0, %xmm0
movl %r10d, %r15d
shrl $0x8, %r15d
andl %edi, %r15d
andl %edi, %r11d
movl %r8d, %r13d
shrl $0x8, %r13d
andl %edi, %r13d
movl %r10d, %ebp
andl %edi, %ebp
shrl $0x8, %r9d
andl %edi, %r9d
movl %r8d, %ecx
andl %edi, %r8d
vpinsrd $0x2, (%rax,%rdx), %xmm0, %xmm0
shrl $0x18, %r10d
vpinsrd $0x3, (%rdx,%r10,4), %xmm0, %xmm1
shrl $0x18, %ecx
vmovd (%rdx,%rcx,4), %xmm0
vpinsrd $0x1, (%rbx,%rdx), %xmm0, %xmm0
shrl $0x18, %r12d
vpinsrd $0x2, (%rdx,%r12,4), %xmm0, %xmm0
vpinsrd $0x3, (%r14,%rdx), %xmm0, %xmm2
vmovd (%rdx,%rsi,4), %xmm0
vpinsrd $0x1, (%rdx,%r15,4), %xmm0, %xmm0
vpinsrd $0x2, (%rdx,%r13,4), %xmm0, %xmm0
vpinsrd $0x3, (%rdx,%r9,4), %xmm0, %xmm3
movq -0x38(%rsp), %rax
vmovd (%rdx,%rax,4), %xmm0
vpinsrd $0x1, (%rdx,%r11,4), %xmm0, %xmm0
vpinsrd $0x2, (%rdx,%rbp,4), %xmm0, %xmm0
vpinsrd $0x3, (%rdx,%r8,4), %xmm0, %xmm0
vpandq 0x1133(%rip){1to2}, %xmm2, %xmm2 # 0x5270
vpternlogq $0xf8, 0x1130(%rip){1to2}, %xmm1, %xmm2 # 0x5278
vpternlogd $0xec, 0x10f1(%rip){1to4}, %xmm2, %xmm3 # 0x5244
vpternlogd $0xec, 0x10e2(%rip){1to4}, %xmm3, %xmm0 # 0x5240
movl -0x30(%rsp), %eax
cmpl %eax, -0x2c(%rsp)
jne 0x418a
movq -0x40(%rsp), %rax
vmovq 0x18(%rax), %xmm1
movq -0x48(%rsp), %rcx
vmovd (%rcx), %xmm2
vpinsrd $0x1, 0x14(%rax), %xmm2, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1 # xmm1 = xmm2[0],xmm1[0]
vpxor %xmm0, %xmm1, %xmm0
vmovd %xmm0, %eax
movl %eax, %ecx
shrl $0x18, %ecx
movq -0x20(%rsp), %rdx
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rdx)
movb %ah, 0x2(%rdx)
movb %al, 0x3(%rdx)
vpextrd $0x1, %xmm0, %eax
movl %eax, %ecx
shrl $0x18, %ecx
movb %cl, 0x4(%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x5(%rdx)
movb %ah, 0x6(%rdx)
movb %al, 0x7(%rdx)
vpextrd $0x2, %xmm0, %eax
movl %eax, %ecx
shrl $0x18, %ecx
movb %cl, 0x8(%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x9(%rdx)
movb %ah, 0xa(%rdx)
movb %al, 0xb(%rdx)
vpextrd $0x3, %xmm0, %eax
movl %eax, %ecx
shrl $0x18, %ecx
movb %cl, 0xc(%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0xd(%rdx)
movb %ah, 0xe(%rdx)
movb %al, 0xf(%rdx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop