// File: /workspace/github_c_makefile_star2_O1/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 0xebcb(%rip), %rbp      # 0x14578
testq %rbp, %rbp
je 0x5acc
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %r13d
leaq 0x8d93(%rip), %r15      # 0xe758
leaq 0x8dd4(%rip), %r12      # 0xe7a0
cmpl $0x3, %ebx
ja 0x5ab3
movslq (%r15,%r13,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x5abf
cmpb $0x0, (%rax)
je 0x5abf
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x5725
cmpl $-0x1, %eax
jne 0x5a0f
cmpl $0x5, 0x10(%rbp)
jne 0x5a9c
cmpl $0x5, 0x10(%rbp)
je 0x5abf
movl $0x2, 0x10(%rbp)
jmp 0x5abf
movq 0x38(%rbp), %rax
testq %rax, %rax
je 0x5abf
cmpb $0x0, (%rax)
je 0x5abf
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x5725
cmpl $-0x1, %eax
jne 0x5abf
movq 0x38(%rbp), %rdx
jmp 0x5aa0
movq 0x30(%rbp), %rax
testq %rax, %rax
je 0x5abf
cmpb $0x0, (%rax)
je 0x5abf
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x5725
cmpl $-0x1, %eax
jne 0x5abf
movq 0x30(%rbp), %rdx
jmp 0x5aa0
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x5abf
cmpb $0x0, (%rax)
je 0x5abf
movq 0x18(%rbp), %rsi
movq %r12, %rdi
callq 0x5725
cmpl $-0x1, %eax
jne 0x5abf
cmpl $0x5, 0x10(%rbp)
jne 0x5abf
movq 0x28(%rbp), %rdx
movq %r14, %rdi
leaq 0x9028(%rip), %rsi      # 0xead2
xorl %eax, %eax
callq 0x1120
jmp 0x5abf
leaq 0x8ec8(%rip), %rdi      # 0xe982
callq 0x1070
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
jne 0x59cc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq