// File: /workspace/github_cpp_makefile_star2_O3/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 0x4f2f
movq %rax, %r14
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x6236
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
xorl %r12d, %r12d
leaq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x10e2(%rip), %r15      # 0x732c
leaq 0x10(%rsp), %rbp
xorl %r13d, %r13d
cmpl $0x3, %r13d
ja 0x641d
movl %r13d, %eax
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r14, %rsi
callq 0x522d
testb %al, %al
je 0x6409
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 0x4f2f
movq %rax, %r14
movq 0x58(%rsp), %rdi
xorl %r13d, %r13d
testq %rdi, %rdi
je 0x62c7
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
xorl %r12d, %r12d
jmp 0x641d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5b41
testb %al, %al
je 0x63f6
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 0x4f2f
movq %rax, %r14
movq 0x28(%rsp), %rdi
xorl %r12d, %r12d
movl $0x2, %r13d
testq %rdi, %rdi
je 0x641d
movq 0x38(%rsp), %rsi
jmp 0x63ec
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5fe9
testb %al, %al
je 0x6401
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 0x4f2f
movq %rax, %r14
movq 0x10(%rsp), %rdi
xorl %r12d, %r12d
movl $0x3, %r13d
testq %rdi, %rdi
je 0x641d
movq 0x20(%rsp), %rsi
jmp 0x63ec
movq %rbx, %rdi
movq %r14, %rsi
callq 0x568e
testb %al, %al
je 0x6414
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 0x4f2f
movq %rax, %r14
movq 0x40(%rsp), %rdi
xorl %r12d, %r12d
movl $0x1, %r13d
testq %rdi, %rdi
je 0x641d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x641d
incl %r12d
movl $0x3, %r13d
jmp 0x641d
incl %r12d
xorl %r13d, %r13d
jmp 0x641d
incl %r12d
movl $0x1, %r13d
jmp 0x641d
incl %r12d
movl $0x2, %r13d
cmpl $0x4, %r12d
jne 0x6252
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
movq %r14, %rdi
callq 0x515f
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 0x64ce
leaq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x64be
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x64b9
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
jmp 0x64b4
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
jmp 0x64b4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
testq %rdi, %rdi
je 0x64ce
movq 0x8(%rsp), %rax
movq (%rax), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2270