// File: /workspace/github_c_makefile_star2_O3/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
movq 0xecbb(%rip), %rbp      # 0x14568
testq %rbp, %rbp
je 0x59cf
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %r13d
leaq 0x8e83(%rip), %r15      # 0xe748
leaq 0x8ec4(%rip), %r12      # 0xe790
cmpl $0x3, %ebx
ja 0x599a
movslq (%r15,%r13,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x59c2
cmpb $0x0, (%rax)
je 0x59c2
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x562e
movl 0x10(%rbp), %ecx
cmpl $-0x1, %eax
je 0x59a8
cmpl $0x5, %ecx
je 0x59c2
movl $0x2, 0x10(%rbp)
jmp 0x59c2
movq 0x38(%rbp), %rax
testq %rax, %rax
je 0x59c2
cmpb $0x0, (%rax)
je 0x59c2
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x562e
cmpl $-0x1, %eax
jne 0x59c2
movq 0x38(%rbp), %rdx
jmp 0x59b1
movq 0x30(%rbp), %rax
testq %rax, %rax
je 0x59c2
cmpb $0x0, (%rax)
je 0x59c2
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x562e
cmpl $-0x1, %eax
jne 0x59c2
movq 0x30(%rbp), %rdx
jmp 0x59b1
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x59c2
cmpb $0x0, (%rax)
je 0x59c2
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x562e
cmpl $-0x1, %eax
jne 0x59c2
cmpl $0x5, 0x10(%rbp)
je 0x59ad
jmp 0x59c2
leaq 0x8fd4(%rip), %rdi      # 0xe975
callq 0x1070
jmp 0x59c2
cmpl $0x5, %ecx
je 0x59c2
movq 0x28(%rbp), %rdx
movq %r14, %rdi
leaq 0x910b(%rip), %rsi      # 0xeac6
xorl %eax, %eax
callq 0x1110
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
jne 0x58cc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq