// File: /workspace/github_c_makefile_star2_O3/aquaxis[P]synverll/src/parser_ir.c
// Function: search_reg_llvm
INST_STAGE search_reg_llvm(PARSER_TREE_IR *now_parser_tree_ir, char *name, char *left_name, char *right_name)
{
    now_parser_tree_ir = now_parser_tree_ir->prev_ptr;
	INST_STAGE inst_stage;

	int left_stage = 0;
	int left_parallel = 0;
	int right_stage = 0;
	int right_parallel = 0;

	inst_stage.parallel = 0;
	inst_stage.stage = 0;

	while(now_parser_tree_ir != parser_tree_ir_top){

		switch(now_parser_tree_ir->flag){
			case PARSER_IR_FLAG_MODULE:
				if(!search_module_llvm(left_name, now_parser_tree_ir->module.argument)){
					left_parallel = now_parser_tree_ir->parallel;
					left_stage = now_parser_tree_ir->stage;
					break;
				}
			case PARSER_IR_FLAG_REGISTER:
			case PARSER_IR_FLAG_LOAD:
			case PARSER_IR_FLAG_FLOAT:
			case PARSER_IR_FLAG_WIRE:
			case PARSER_IR_FLAG_CALL:
			case PARSER_IR_FLAG_ALLOCA:
			case PARSER_IR_FLAG_COMPARE:
			case PARSER_IR_FLAG_POINTER:
			case PARSER_IR_FLAG_SELECT:
			case PARSER_IR_FLAG_TYPE:
			case PARSER_IR_FLAG_REGISTER_LOOP:
				if(!strcmp(now_parser_tree_ir->label, left_name) && (strlen(left_name) > 0) && (left_name[0] == '%')){
					left_parallel = now_parser_tree_ir->parallel;
					left_stage = now_parser_tree_ir->stage;
					break;
				}
				if(!strcmp(now_parser_tree_ir->label, right_name) && (strlen(right_name) > 0) && (right_name[0] == '%')){
					right_parallel = now_parser_tree_ir->parallel;
					right_stage = now_parser_tree_ir->stage;
					break;
				}
			default:
				break;
		}
        now_parser_tree_ir = now_parser_tree_ir->prev_ptr;
	}

	if(left_stage > right_stage){
		inst_stage.parallel = left_parallel;
		inst_stage.stage = left_stage;
	}else if(right_stage > left_stage){
		inst_stage.parallel = right_parallel;
		inst_stage.stage = right_stage;
	}else{
		inst_stage.parallel = left_parallel;
		inst_stage.stage = left_stage;
	}

	return inst_stage;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq (%rdi), %rbp
cmpq 0xf8c9(%rip), %rbp      # 0x14130
je 0x4916
movq %rcx, %r14
movq %rdx, %r15
movq $0x0, 0x10(%rsp)
movl $0x12f9e, %ebx          # imm = 0x12F9E
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movl 0x10(%rbp), %eax
cmpl $0x10, %eax
ja 0x4907
btl %eax, %ebx
jae 0x48ed
leaq 0x30(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1100
testl %eax, %eax
jne 0x48c7
cmpb $0x25, (%r15)
jne 0x48c7
movl 0x18(%rbp), %eax
movl %eax, 0x8(%rsp)
movl 0x1c(%rbp), %r13d
jmp 0x4907
movq %r12, %rdi
movq %r14, %rsi
callq 0x1100
testl %eax, %eax
jne 0x4907
cmpb $0x25, (%r14)
jne 0x4907
movl 0x18(%rbp), %eax
movq %rax, 0x10(%rsp)
movl 0x1c(%rbp), %eax
movl %eax, 0xc(%rsp)
jmp 0x4907
cmpl $0xf, %eax
jne 0x4907
leaq 0x1430(%rbp), %rsi
movq %r15, %rdi
callq 0x47e0
testl %eax, %eax
jne 0x48a1
jmp 0x48ba
movq (%rbp), %rbp
cmpq 0xf81e(%rip), %rbp      # 0x14130
jne 0x4894
jmp 0x4932
xorl %r13d, %r13d
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
movl 0xc(%rsp), %edx
cmpl %r13d, %edx
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
cmovlel %ecx, %eax
cmovgl %edx, %r13d
cmovll %ecx, %eax
shlq $0x20, %r13
orq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq