// File: /workspace/github_c_makefile_star2_O1/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 0xf80a(%rip), %rbp      # 0x14140
je 0x49e5
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 0x49d6
btl %eax, %ebx
jae 0x49bc
leaq 0x30(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1110
testl %eax, %eax
jne 0x4996
cmpb $0x25, (%r15)
jne 0x4996
movl 0x18(%rbp), %eax
movl %eax, 0x8(%rsp)
movl 0x1c(%rbp), %r13d
jmp 0x49d6
movq %r12, %rdi
movq %r14, %rsi
callq 0x1110
testl %eax, %eax
jne 0x49d6
cmpb $0x25, (%r14)
jne 0x49d6
movl 0x18(%rbp), %eax
movq %rax, 0x10(%rsp)
movl 0x1c(%rbp), %eax
movl %eax, 0xc(%rsp)
jmp 0x49d6
cmpl $0xf, %eax
jne 0x49d6
leaq 0x1430(%rbp), %rsi
movq %r15, %rdi
callq 0x48af
testl %eax, %eax
jne 0x4970
jmp 0x4989
movq (%rbp), %rbp
cmpq 0xf75f(%rip), %rbp      # 0x14140
jne 0x4963
jmp 0x4a01
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