// File: /workspace/github_c_makefile_star2_O1/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
movl %r9d, %ebp
movq %r8, %r15
movq %rdx, 0x28(%rsp)
movq %rsi, %r14
movb 0xb0(%rsp), %r12b
cmpb $0x2, %r12b
movl $0x1, %eax
cmovbl %r9d, %eax
leaq 0x40(%rsp), %rsi
movq %rcx, %rdx
movl %eax, %ecx
callq 0x2dd8
testb %r12b, %r12b
jne 0x2851
movq 0x578c(%rip), %rdx      # 0x7fd0
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x1060
cmpb $0x1, %r12b
jne 0x286b
movq 0x5772(%rip), %rdx      # 0x7fd0
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x1060
movb 0xa8(%rsp), %bl
movb 0xa0(%rsp), %r13b
cmpb $0x2, %r12b
jne 0x2894
movq 0x5749(%rip), %rdx      # 0x7fd0
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x1060
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x259a
movw $0x7fff, %ax            # imm = 0x7FFF
kmovd %eax, %k1
vmovdqu8 (%r15), %xmm0 {%k1} {z}
vmovdqu8 0x1(%r15), %xmm1 {%k1} {z}
vpsrlw $0x7, %xmm1, %xmm1
vpaddw %xmm0, %xmm0, %xmm0
vpternlogd $0xe4, 0x1743(%rip){1to4}, %xmm1, %xmm0 # 0x4010
movb (%r15), %al
vmovdqu8 %xmm0, 0x10(%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, 0x1f(%rsp)
xorb $0x1, %bl
movl %r13d, %eax
orb %bl, %al
jne 0x28ff
xorb $0x1, 0xf(%rsp)
vmovaps 0x50(%rsp), %xmm0
vxorps (%rsp), %xmm0, %xmm0
vmovaps %xmm0, 0x30(%rsp)
movl %r13d, %eax
xorb $0x1, %al
orb %bl, %al
jne 0x291e
xorb $0x1, 0x3f(%rsp)
cmpb $0x1, %r13b
jne 0x292c
vmovaps 0x10(%rsp), %xmm0
jmp 0x2936
testb %r13b, %r13b
jne 0x2940
vmovups (%r15), %xmm0
vxorps (%rsp), %xmm0, %xmm0
vmovups %xmm0, (%r15)
cmpb $0x1, %r12b
jne 0x295c
movq 0x5693(%rip), %rdx      # 0x7fe0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1050
cmpb $0x2, %r12b
jne 0x2978
movq 0x5677(%rip), %rdx      # 0x7fe0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1050
cmpb $0x1, %r12b
jne 0x2995
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %ecx
callq 0x2dd8
cmpb $0x2, %r12b
jne 0x29b1
movzbl %bpl, %ecx
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x2dd8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq