// File: /workspace/github_c_makefile_star2_O3/aquaxis[P]synverll/src/parser_ir_top.c
// Function: search_top_signal_func
char *search_top_signal_func(char *func, char *call_name, char *args)
{
	TOP_SIGNAL_TREE *now_top_signal_tree = NULL;
	char *result = NULL;
	char *label = NULL;
	char *signal_name = NULL;
	char *verilog = NULL;

	result = calloc(STR_MAX, 1);
//printf("call_name: %s_%s(%d)\n", call_name, name, args_num);

	signal_name = calloc(STR_MAX, 1);
	label = calloc(STR_MAX, 1);

	sprintf(label, "__call_%s_%s", call_name, args);
	if(!strcmp(func, "call")){
		sprintf(label, "__%s_%s_%s", func, call_name, args);
	}else{
		sprintf(label, "__%s_%s", func, args);
	}
	sprintf(signal_name, "%s", label);
//printf("call_name: %s\n", signal_name);

	now_top_signal_tree = top_signal_tree_top;
    while(now_top_signal_tree != NULL){
//printf("    call_name: %s <> %s\n", now_top_signal_tree->label, label);
		if(now_top_signal_tree->flag == FLAG_CALL){
			if(!strcmp(now_top_signal_tree->label, label)){
				sprintf(result, "%s %s |", result, now_top_signal_tree->verilog_signal);
				now_top_signal_tree->used = 1;
//printf("    call_name: %s <> %s\n", now_top_signal_tree->label, label);
			}
		}else if(now_top_signal_tree->flag == FLAG_CTRL){
			if(!strcmp(now_top_signal_tree->label, label) && !strcmp(now_top_signal_tree->module_name, call_name)){
				sprintf(result, "%s %s |", result, now_top_signal_tree->verilog_signal);
				now_top_signal_tree->used = 1;
//printf("    call_name: %s <> %s\n", now_top_signal_tree->label, label);
			}
		}else if(now_top_signal_tree->flag == FLAG_GMEM){
			if(!strcmp(now_top_signal_tree->label, label)){
				sprintf(result, "%s %s |", result, now_top_signal_tree->verilog_signal);
				now_top_signal_tree->used = 1;
//printf("    call_name: %s <> %s\n", now_top_signal_tree->label, label);
			}
		}else if(now_top_signal_tree->flag == FLAG_RETURN){
			if(!strcmp(now_top_signal_tree->label, label) && !strcmp(now_top_signal_tree->module_name, call_name)){
				sprintf(result, "%s %s |", result, now_top_signal_tree->verilog_signal);
				now_top_signal_tree->used = 1;
//printf("    call_name: %s <> %s\n", now_top_signal_tree->label, label);
			}
		}


        now_top_signal_tree = now_top_signal_tree->next_ptr;
	}

	if(strlen(result) > 0){
		result[strlen(result)-1] = ';';
		verilog = calloc(strlen(result)+1, 1);
		strcpy(verilog, result);
//printf("    result: %s,%s\n", result, verilog);
	}

	free(result);

	return verilog;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r13
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10f0
movq %rax, %rbx
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10f0
movq %rax, %r15
leaq 0x438f(%rip), %rsi      # 0xe647
movq %rax, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11a0
leaq 0x42fe(%rip), %rsi      # 0xe5cd
movq %r13, %rdi
callq 0x1100
testl %eax, %eax
je 0xa2f4
leaq 0x5821(%rip), %rsi      # 0xfb03
movq %r15, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0xa30e
leaq 0x57fd(%rip), %rsi      # 0xfaf8
movq %r15, %rdi
movq %r13, %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x11a0
movq 0xa29b(%rip), %r13      # 0x145b0
testq %r13, %r13
je 0xa38b
leaq 0x5793(%rip), %rbp      # 0xfab4
leaq 0x57c8(%rip), %r12      # 0xfaf0
movl 0x30(%r13), %eax
decl %eax
cmpl $0x5, %eax
ja 0xa382
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x10(%r13), %rdi
movq %r15, %rsi
jmp 0xa35d
movq 0x10(%r13), %rdi
movq %r15, %rsi
callq 0x1100
testl %eax, %eax
jne 0xa382
movq 0x28(%r13), %rdi
movq %r14, %rsi
callq 0x1100
testl %eax, %eax
jne 0xa382
movq 0x50(%r13), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x1, 0x20(%r13)
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0xa328
movq %rbx, %rdi
callq 0x1090
testq %rax, %rax
je 0xa3c3
movb $0x3b, -0x1(%rbx,%rax)
movq %rbx, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
movl $0x1, %esi
callq 0x10f0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1060
jmp 0xa3c6
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x1030
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq