// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/elmd1001v2/ref/module.h
// Function: process_block
static void process_block(
	block Delta_1, block Delta_2, 
	block result, const block in_blk, block W,
	u8 Is_complete, u8 Is_Encrypt, u8 Is_final,  u8 type_block) {

	block YY, XX, Y, X; 
	int i;
	
	/* ==============   Mask  ================= */
	if(type_block == AD || type_block == MESSAGE)
		mask(Delta_1, XX, in_blk, Is_complete);	
	else
		mask(Delta_1, XX, in_blk, 1);	

	/* ==============  AES Encrypt =============== */
	if(type_block == AD)  { AES(rd, ENCRYPT, X, XX, &aes_key1); } 
	if(type_block == MESSAGE) { AES(rd, ENCRYPT, X, XX, &aes_key1); }				
	if(type_block == CIPHERTEXT){  AES(rd, ENCRYPT, X, XX, &aes_key1); } 

	/* ============= Linear Mixing =============== */
	linear_mix(W, Y, X, Is_Encrypt, Is_final);
	
	/* ============= AES Decrypt ================== */
	if(type_block == MESSAGE) {  AES(rd, DECRYPT, YY, Y, &aes_key2); }   
	if(type_block == CIPHERTEXT){  AES(rd, DECRYPT, YY, Y, &aes_key2); }
	
	/* =============== Mask ======================= */
	if(type_block == MESSAGE)
		mask(Delta_2, result, YY, 1);	
	if(type_block == CIPHERTEXT)
		mask(Delta_2, result, YY, Is_complete);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %r15
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movb 0xb0(%rsp), %r13b
movb 0xa8(%rsp), %r14b
movb 0xa0(%rsp), %bl
movzbl %r9b, %ebp
cmpb $0x2, %r13b
setae %r12b
leaq 0x40(%rsp), %rsi
movq %rcx, %rdx
jb 0x286e
movl $0x1, %ecx
callq 0x2de1
cmpb $0x2, %r13b
je 0x2875
xorl %r12d, %r12d
jmp 0x288b
movl %ebp, %ecx
callq 0x2de1
movq 0x5754(%rip), %rdx      # 0x7fd0
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1060
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x2583
movb (%r15), %al
vmovd %eax, %xmm0
movw $0x7fff, %cx            # imm = 0x7FFF
kmovd %ecx, %k1
vmovdqu8 0x1(%r15), %xmm1 {%k1} {z}
vpbroadcastb %xmm0, %xmm0
vpalignr $0xf, %xmm0, %xmm1, %xmm0 # xmm0 = xmm0[15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
vpaddw %xmm0, %xmm0, %xmm0
vpsrlw $0x7, %xmm1, %xmm1
vpternlogd $0xd8, 0x1740(%rip){1to4}, %xmm0, %xmm1 # 0x4010
vmovdqu8 %xmm1, (%rsp) {%k1}
movb 0xf(%r15), %cl
addb %cl, %cl
movzbl %cl, %edx
xorb $-0x79, %cl
testb %al, %al
movzbl %cl, %eax
cmovnsl %edx, %eax
movb %al, 0xf(%rsp)
xorb $0x1, %r14b
movl %ebx, %eax
orb %r14b, %al
jne 0x28ff
xorb $0x1, 0x2f(%rsp)
vmovaps 0x50(%rsp), %xmm0
vxorps 0x20(%rsp), %xmm0, %xmm0
vmovaps %xmm0, 0x30(%rsp)
movl %ebx, %eax
xorb $0x1, %al
orb %r14b, %al
jne 0x2921
xorb $0x1, 0x3f(%rsp)
jmp 0x292a
cmpb $0x1, %bl
jne 0x29b2
vmovaps (%rsp), %xmm0
vxorps 0x20(%rsp), %xmm0, %xmm0
vmovups %xmm0, (%r15)
cmpb $0x1, %r13b
jne 0x2954
movq 0x5699(%rip), %rdx      # 0x7fe0
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1050
testb %r12b, %r12b
je 0x296d
movq 0x5680(%rip), %rdx      # 0x7fe0
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1050
cmpb $0x1, %r13b
jne 0x298a
movq %rsp, %rdx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x1, %ecx
callq 0x2de1
testb %r12b, %r12b
je 0x29a3
movq %rsp, %rdx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl %ebp, %ecx
callq 0x2de1
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %bl, %bl
jne 0x293a
vmovups (%r15), %xmm0
jmp 0x292f