// File: /workspace/github_c_makefile_star2_O3/aquaxis[P]synverll/src/parser_ir_memory.c
// Function: deploy_array_type
int deploy_array_type()
{
	MEMORY_TREE *now_memory_tree;
	char *buf = NULL;
	char *buf_temp = NULL;
	char *token;
	char *argument;
	int convert = 0;

	printf(" -> deploy_array_type\n");

	token = malloc(STR_MAX);
	argument = malloc(STR_MAX);

	buf = calloc(1,1);
	buf_temp = calloc(1,1);

	/*
	 * arryタイプの中にstructが無くなるまで置換し続けます。
	 */
	do{
		convert = 0;

		now_memory_tree = memory_tree_top;
		while(now_memory_tree != NULL){
			if(now_memory_tree->type != NULL){
				do{
					get_token_llvm(now_memory_tree->type, token);

					buf_temp = charalloc(buf);
					free(buf);

					if(is_struct_name(token)){
						// struct名を発見した場合、structの中身に置き換える
						get_struct_argument(token, argument);
						buf = calloc(strlen(buf_temp) + strlen(argument) + 3,1);
						sprintf(buf, "%s %s ", buf_temp, argument);
						convert = 1;
					}else{
						buf = calloc(strlen(buf_temp) + strlen(token) + 3,1);
						sprintf(buf, "%s %s ", buf_temp, token);
					}

					free(buf_temp);
					buf_temp = calloc(1,1);

				}while(strlen(now_memory_tree->type) > 0);
			}
			free(now_memory_tree->type);
			now_memory_tree->type = calloc(strlen(buf)+1,1);
			strcpy(now_memory_tree->type, buf);

			free(buf);
			buf = calloc(1,1);

			now_memory_tree = now_memory_tree->next_ptr;
		}
	}while(convert);

    free(buf);
    free(buf_temp);
    free(token);
    free(argument);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x8f3a(%rip), %rdi      # 0xe9a7
callq 0x1070
movl $0x400, %edi            # imm = 0x400
callq 0x1130
movq %rax, %rbx
movl $0x400, %edi            # imm = 0x400
callq 0x1130
movq %rax, %r14
movl $0x1, %edi
movl $0x1, %esi
callq 0x10f0
movq %rax, %r12
movl $0x1, %edi
movl $0x1, %esi
callq 0x10f0
movq %rax, %r13
movq 0xeab1(%rip), %r15      # 0x14568
testq %r15, %r15
je 0x5bdb
movl $0x0, 0x4(%rsp)
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x5b7d
movq %rbx, %rsi
callq 0xcaa7
movq %r12, %rdi
callq 0x137c
movq %rax, %r13
movq %r12, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0xbd16
movq %rbx, %rbp
testl %eax, %eax
je 0x5b15
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbccd
movl $0x1, 0x4(%rsp)
movq %r14, %rbp
movq %r13, %rdi
callq 0x1090
movq %rax, %r12
movq %rbp, %rdi
callq 0x1090
leaq (%r12,%rax), %rdi
addq $0x3, %rdi
movl $0x1, %esi
callq 0x10f0
movq %rax, %r12
movq %rax, %rdi
leaq 0x8c73(%rip), %rsi      # 0xe7ba
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11a0
movq %r13, %rdi
callq 0x1030
movl $0x1, %edi
movl $0x1, %esi
callq 0x10f0
movq 0x20(%r15), %rdi
cmpb $0x0, (%rdi)
jne 0x5ad5
movq %rax, %r13
jmp 0x5b7f
xorl %edi, %edi
callq 0x1030
movq %r12, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
movl $0x1, %esi
callq 0x10f0
movq %rax, 0x20(%r15)
movq %rax, %rdi
movq %r12, %rsi
callq 0x1060
movq %r12, %rdi
callq 0x1030
movl $0x1, %edi
movl $0x1, %esi
callq 0x10f0
movq %rax, %r12
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5ac8
cmpl $0x0, 0x4(%rsp)
jne 0x5ab0
movq %r12, %rdi
callq 0x1030
movq %r13, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq