// File: /workspace/github_cpp_makefile_star2_O1/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/reduce.cpp
// Function: reduce_step(std::vector<xpair, std::allocator<xpair>>&)
int reduce_step(vector<xpair> &seq)
{
	int** tab = NULL;
	tab = get_table(seq, tab, 0, seq.size());
	int i = 0;
	int NUM = 4;
	int counter = 0;
	while(counter != NUM)
	{
		switch(i)
		{
			case 0:
			{
				if(reduce0(seq, tab))
				{
					// cout << "activate case 0"<<endl;
					tab = get_table(seq, tab, seq.size() + 1, seq.size());
					// i = 0;
					counter = 0;
				}
				else
				{
					i = (i + 1) % NUM;
					counter++;
				}
				break;
			}
			case 1:
			{
				if(reduce1(seq, tab))
				{
					// cout << "activate case 1" << endl;
					tab = get_table(seq, tab, seq.size() + 1, seq.size());
					// i = 1;
					counter = 0;
				}
				else
				{
					i = (i + 1) % NUM;
					counter++;
				}
				break;
			}
			case 2:
			{
				if(reduce2(seq, tab))
				{
					// cout << "activate case 2" <<endl;
					tab = get_table(seq, tab, seq.size() + 1, seq.size());
					counter = 0;
				}
				else
				{
					i = (i + 1) % NUM;
					counter++;
				}
				break;
			}
			case 3:
			{

				if(reduce3(seq, tab))
				{
					// cout << "activate case 3" << endl;
					tab = get_table(seq, tab, seq.size() + 1, seq.size());
					counter = 0;
				}
				else
				{
					// cout << "case 3" << endl;
					i = (i + 1) % NUM;
					counter++;
				}
			}
		}

	}
	delete_table(tab, seq.size());
	return seq.size();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2f16
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4f23
movq %rax, %r14
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x6228
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
leaq 0x10f0(%rip), %r15      # 0x732c
leaq 0x10(%rsp), %rbp
xorl %r13d, %r13d
cmpl $0x3, %r13d
ja 0x640f
movl %r13d, %eax
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r14, %rsi
callq 0x526b
testb %al, %al
je 0x63fb
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2f16
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
leal 0x1(%rcx), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4f23
movq %rax, %r14
movq 0x58(%rsp), %rdi
xorl %r13d, %r13d
testq %rdi, %rdi
je 0x62b9
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
xorl %r12d, %r12d
jmp 0x640f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5b64
testb %al, %al
je 0x63e8
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2f16
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
leal 0x1(%rcx), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4f23
movq %rax, %r14
movq 0x28(%rsp), %rdi
xorl %r12d, %r12d
movl $0x2, %r13d
testq %rdi, %rdi
je 0x640f
movq 0x38(%rsp), %rsi
jmp 0x63de
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5fff
testb %al, %al
je 0x63f3
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2f16
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
leal 0x1(%rcx), %edx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4f23
movq %rax, %r14
movq 0x10(%rsp), %rdi
xorl %r12d, %r12d
movl $0x3, %r13d
testq %rdi, %rdi
je 0x640f
movq 0x20(%rsp), %rsi
jmp 0x63de
movq %rbx, %rdi
movq %r14, %rsi
callq 0x56d1
testb %al, %al
je 0x6406
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2f16
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
leal 0x1(%rcx), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x4f23
movq %rax, %r14
movq 0x40(%rsp), %rdi
xorl %r12d, %r12d
movl $0x1, %r13d
testq %rdi, %rdi
je 0x640f
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x640f
incl %r12d
movl $0x3, %r13d
jmp 0x640f
incl %r12d
xorl %r13d, %r13d
jmp 0x640f
incl %r12d
movl $0x1, %r13d
jmp 0x640f
incl %r12d
movl $0x2, %r13d
cmpl $0x4, %r12d
jne 0x6244
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
movq %r14, %rdi
callq 0x5175
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x64c0
leaq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x64b0
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x64ab
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
jmp 0x64a6
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
jmp 0x64a6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
testq %rdi, %rdi
je 0x64c0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2270