// File: /workspace/github_c_makefile_star2_O2/aquaxis[P]synverll/src/parser_ir_call.c
// Function: output_call_signal_tree
int output_call_signal_tree(FILE *fp)
{
	CALL_TREE *now_call_tree;
	CALL_SIGNAL_TREE *now_call_signal_tree;
	char *temp;

	temp = calloc(STR_MAX, 1);

    now_call_tree = call_tree_top;
    while(now_call_tree != NULL){
		now_call_signal_tree = now_call_tree->signal_top_ptr;
		while(now_call_signal_tree != NULL){
			switch(now_call_signal_tree->inout){
				case 0:	// in
					sprintf(temp, "\tinput ");
					break;
				case 1:	// out
					sprintf(temp, "\toutput reg ");
					break;
			}
			if(now_call_signal_tree->size > 0){
					sprintf(temp, "%s[%d:0] ", temp, now_call_signal_tree->size -1);
			}
			sprintf(temp, "%s__call_%s_%s",
				temp,
				convname(sep_p(now_call_tree->call_name)),
				now_call_signal_tree->signal_name
			);
			if(
				strcmp(now_call_signal_tree->signal_name, "req") &&
				strcmp(now_call_signal_tree->signal_name, "ready") &&
				strcmp(now_call_signal_tree->signal_name, "done") &&
				strcmp(now_call_signal_tree->signal_name, "result")
			){
				sprintf(temp, "%s_%d",
					temp,
					now_call_signal_tree->num
				);
			}
			fprintf(fp, "%s,\n", temp);
			now_call_signal_tree = now_call_signal_tree->next_ptr;
		}
		fprintf(fp, "\n");

        now_call_tree = now_call_tree->next_ptr;
    }

	free(temp);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x1
popq %rsi
movl $0x400, %edi            # imm = 0x400
callq 0x10f0
movq %rax, %r14
leaq 0xe450(%rip), %r12      # 0x13550
leaq 0x9b43(%rip), %rbp      # 0xec4a
movq (%r12), %r12
testq %r12, %r12
je 0x5242
leaq 0x20(%r12), %r13
movq (%r13), %r13
testq %r13, %r13
je 0x522e
movl 0x20(%r13), %eax
cmpl $0x1, %eax
je 0x513f
testl %eax, %eax
jne 0x515a
movabsq $0x207475706e6909, %rax # imm = 0x207475706E6909
jmp 0x5157
movabsq $0x20676572207475, %rax # imm = 0x20676572207475
movq %rax, 0x5(%r14)
movabsq $0x2074757074756f09, %rax # imm = 0x2074757074756F09
movq %rax, (%r14)
movl 0x24(%r13), %ecx
testl %ecx, %ecx
jle 0x5178
decl %ecx
movq %r14, %rdi
leaq 0x84cd(%rip), %rsi      # 0xd63b
movq %r14, %rdx
xorl %eax, %eax
callq 0x11a0
movq 0x10(%r12), %rdi
movzbl (%rdi), %eax
cmpl $0x40, %eax
je 0x518a
cmpl $0x25, %eax
jne 0x518d
incq %rdi
callq 0x1393
movq 0x10(%r13), %r8
movq %r14, %rdi
leaq 0x84a5(%rip), %rsi      # 0xd645
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x11a0
movq 0x10(%r13), %r15
movq %r15, %rdi
leaq 0x9b42(%rip), %rsi      # 0xecfd
callq 0x1100
testl %eax, %eax
je 0x5215
movq %r15, %rdi
leaq 0x9b04(%rip), %rsi      # 0xecd2
callq 0x1100
testl %eax, %eax
je 0x5215
movq %r15, %rdi
leaq 0x9ae5(%rip), %rsi      # 0xecc6
callq 0x1100
testl %eax, %eax
je 0x5215
movq %r15, %rdi
leaq 0x9bbe(%rip), %rsi      # 0xedb2
callq 0x1100
testl %eax, %eax
je 0x5215
movl 0x28(%r13), %ecx
movq %r14, %rdi
leaq 0x98bf(%rip), %rsi      # 0xeaca
movq %r14, %rdx
xorl %eax, %eax
callq 0x11a0
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
addq $0x8, %r13
jmp 0x5119
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10d0
addq $0x8, %r12
jmp 0x5107
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop