// File: /workspace/github_c_makefile_star2_O2/aquaxis[P]synverll/src/parser_ir_memory.c
// Function: output_memory_tree
int output_memory_tree(FILE *fp, int flag)
{
	MEMORY_TREE *now_memory_tree;

    now_memory_tree = memory_tree_top;
    while(now_memory_tree != NULL){
		switch(flag){
			case 0:
				// 引数の表示
				if(now_memory_tree->verilog_args != NULL){
					if(strlen(now_memory_tree->verilog_args) > 0){
						if(
							(get_adrs_memmap("GLOBAL", now_memory_tree->label) == -1) &&
							(now_memory_tree->flag != MEMORY_FLAG_RETURN)
						){
							fprintf(fp, "%s\n", now_memory_tree->verilog_args);
						}else if(now_memory_tree->flag == MEMORY_FLAG_RETURN){
						}else{
							now_memory_tree->flag = MEMORY_FLAG_LOCAL;
						}
					}
				}
				break;
			case 1:
				// returnの表示
				if(now_memory_tree->verilog_args != NULL){
					if(strlen(now_memory_tree->verilog_args) > 0){
						if(
							(get_adrs_memmap("GLOBAL", now_memory_tree->label) == -1) &&
							(now_memory_tree->flag == MEMORY_FLAG_RETURN)
						){
							fprintf(fp, "%s\n", now_memory_tree->verilog_args);
						}
					}
				}
				break;
			case 2:
				// 宣言の表示
				if(now_memory_tree->verilog_decl != NULL){
					if(strlen(now_memory_tree->verilog_decl) > 0){
						if(get_adrs_memmap("GLOBAL", now_memory_tree->label) == -1){
							fprintf(fp, "%s\n", now_memory_tree->verilog_decl);
						}
					}
				}
				break;
			case 3:
				// procの表示
				if(now_memory_tree->verilog_proc != NULL){
					if(strlen(now_memory_tree->verilog_proc) > 0){
						if(get_adrs_memmap("GLOBAL", now_memory_tree->label) == -1){
							fprintf(fp, "%s\n", now_memory_tree->verilog_proc);
						}
					}
				}
				break;
			default:
				printf("[ERROR] output_memory_tree()\n");
				break;
		}
        now_memory_tree = now_memory_tree->next_ptr;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
leaq 0xdf2d(%rip), %rbp      # 0x13568
movl %esi, %r13d
leaq 0x8103(%rip), %r15      # 0xd748
leaq 0x8124(%rip), %r12      # 0xd770
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x5758
cmpl $0x3, %ebx
ja 0x5727
movslq (%r15,%r13,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x574f
cmpb $0x0, (%rax)
je 0x574f
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x53de
movl 0x10(%rbp), %ecx
cmpl $-0x1, %eax
je 0x5735
cmpl $0x5, %ecx
je 0x574f
movl $0x2, 0x10(%rbp)
jmp 0x574f
movq 0x38(%rbp), %rax
testq %rax, %rax
je 0x574f
cmpb $0x0, (%rax)
je 0x574f
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x53de
cmpl $-0x1, %eax
jne 0x574f
movq 0x38(%rbp), %rdx
jmp 0x573e
movq 0x30(%rbp), %rax
testq %rax, %rax
je 0x574f
cmpb $0x0, (%rax)
je 0x574f
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x53de
cmpl $-0x1, %eax
jne 0x574f
movq 0x30(%rbp), %rdx
jmp 0x573e
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x574f
cmpb $0x0, (%rax)
je 0x574f
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x53de
cmpl $-0x1, %eax
jne 0x574f
cmpl $0x5, 0x10(%rbp)
je 0x573a
jmp 0x574f
leaq 0x8227(%rip), %rdi      # 0xd955
callq 0x1070
jmp 0x574f
cmpl $0x5, %ecx
je 0x574f
movq 0x28(%rbp), %rdx
movq %r14, %rdi
leaq 0x835e(%rip), %rsi      # 0xdaa6
xorl %eax, %eax
callq 0x1110
addq $0x8, %rbp
jmp 0x564c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq