// File: /workspace/github_c_makefile_star2_O1/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 0x1100
movq %rax, %rbx
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x1100
movq %rax, %r15
leaq 0x42a1(%rip), %rsi      # 0xe655
movq %rax, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11b0
leaq 0x4210(%rip), %rsi      # 0xe5db
movq %r13, %rdi
callq 0x1110
testl %eax, %eax
je 0xa3f0
leaq 0x5731(%rip), %rsi      # 0xfb0f
movq %r15, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11b0
jmp 0xa40a
leaq 0x570d(%rip), %rsi      # 0xfb04
movq %r15, %rdi
movq %r13, %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x11b0
movq 0xa1af(%rip), %r13      # 0x145c0
testq %r13, %r13
je 0xa487
leaq 0x56a3(%rip), %rbp      # 0xfac0
leaq 0x56d8(%rip), %r12      # 0xfafc
movl 0x30(%r13), %eax
decl %eax
cmpl $0x5, %eax
ja 0xa47e
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x10(%r13), %rdi
movq %r15, %rsi
jmp 0xa459
movq 0x10(%r13), %rdi
movq %r15, %rsi
callq 0x1110
testl %eax, %eax
jne 0xa47e
movq 0x28(%r13), %rdi
movq %r14, %rsi
callq 0x1110
testl %eax, %eax
jne 0xa47e
movq 0x50(%r13), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x11b0
movl $0x1, 0x20(%r13)
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0xa424
movq %rbx, %rdi
callq 0x1090
testq %rax, %rax
je 0xa4bf
movb $0x3b, -0x1(%rbx,%rax)
movq %rbx, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
movl $0x1, %esi
callq 0x1100
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1060
jmp 0xa4c2
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