// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r15
movl $0x400, %edi            # imm = 0x400
movq %r15, %rsi
callq 0x10f0
movq %rax, %rbx
movl $0x400, %edi            # imm = 0x400
movq %r15, %rsi
callq 0x10f0
movq %rax, %r15
leaq 0x3804(%rip), %rsi      # 0xd647
movq %rax, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11a0
leaq 0x3773(%rip), %rsi      # 0xd5cd
movq %r13, %rdi
callq 0x1100
testl %eax, %eax
je 0x9e7f
leaq 0x4c76(%rip), %rsi      # 0xeae3
movq %r15, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x9e99
leaq 0x4c52(%rip), %rsi      # 0xead8
movq %r15, %rdi
movq %r13, %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x11a0
leaq 0x9710(%rip), %r13      # 0x135b0
leaq 0x4bed(%rip), %rbp      # 0xea94
leaq 0x4c22(%rip), %r12      # 0xead0
movq (%r13), %r13
testq %r13, %r13
je 0x9f17
movl 0x30(%r13), %eax
decl %eax
cmpl $0x5, %eax
ja 0x9f11
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x10(%r13), %rdi
movq %r15, %rsi
jmp 0x9eec
movq 0x10(%r13), %rdi
movq %r15, %rsi
callq 0x1100
testl %eax, %eax
jne 0x9f11
movq 0x28(%r13), %rdi
movq %r14, %rsi
callq 0x1100
testl %eax, %eax
jne 0x9f11
movq 0x50(%r13), %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x11a0
movl $0x1, 0x20(%r13)
addq $0x8, %r13
jmp 0x9eae
movq %rbx, %rdi
callq 0x1090
testq %rax, %rax
je 0x9f4d
movb $0x3b, -0x1(%rbx,%rax)
movq %rbx, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x10f0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1060
jmp 0x9f50
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