// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0x4(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x11f28(%rip), %rax     # 0x18110
je 0x630c
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x3c(%rbp)
decl %eax
subl $0x4, %eax
jb 0x626a
jmp 0x6201
movl -0x3c(%rbp), %eax
addl $-0x7, %eax
subl $0x5, %eax
jb 0x626a
jmp 0x620e
movl -0x3c(%rbp), %eax
subl $0xd, %eax
je 0x626a
jmp 0x6218
movl -0x3c(%rbp), %eax
subl $0xf, %eax
je 0x622f
jmp 0x6222
movl -0x3c(%rbp), %eax
subl $0x10, %eax
je 0x626a
jmp 0x62fa
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0xc30, %rsi            # imm = 0xC30
addq $0x800, %rsi            # imm = 0x800
callq 0x60f0
cmpl $0x0, %eax
jne 0x6268
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x62fc
jmp 0x626a
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rsi
callq 0x10d0
cmpl $0x0, %eax
jne 0x62b1
movq -0x20(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
jbe 0x62b1
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
jne 0x62b1
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x62fc
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x28(%rbp), %rsi
callq 0x10d0
cmpl $0x0, %eax
jne 0x62f8
movq -0x28(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
jbe 0x62f8
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
jne 0x62f8
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x62fc
jmp 0x62fa
jmp 0x62fc
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x61dd
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x6322
movl -0x30(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6346
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x6338
movl -0x38(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6344
movl -0x30(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6346
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq