// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
leaq 0x8194(%rip), %rdi      # 0xd987
callq 0x1070
movl $0x400, %edi            # imm = 0x400
callq 0x1130
movq %rax, %r12
movl $0x400, %edi            # imm = 0x400
callq 0x1130
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rbx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x10f0
movq %rax, %r13
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x10f0
movq %rax, %rbp
leaq 0xdd2e(%rip), %r15      # 0x13568
movq %r15, %r14
xorl %eax, %eax
movq (%r14), %r14
testq %r14, %r14
jne 0x5858
movq %r15, %r14
testl %eax, %eax
movl $0x0, %eax
jne 0x583f
jmp 0x596d
movl %eax, 0xc(%rsp)
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x591d
movq %r12, %rsi
callq 0xc4ad
movq %r13, %rdi
callq 0x1372
movq %rax, %rbp
movq %r13, %rdi
callq 0x1030
movq %r12, %rdi
callq 0xb784
movq %r12, %rbx
testl %eax, %eax
je 0x58aa
movq %r12, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0xb73d
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
callq 0x1090
movq %rax, %r13
movq %rbx, %rdi
callq 0x1090
leaq (%rax,%r13), %rdi
addq $0x3, %rdi
movq %r12, %r15
pushq $0x1
popq %r12
movq %r12, %rsi
callq 0x10f0
movq %rax, %r13
movq %rax, %rdi
leaq 0x7eb9(%rip), %rsi      # 0xd79a
movq %rbp, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x11a0
movq %rbp, %rdi
callq 0x1030
movq %r12, %rdi
movq %r12, %rsi
movq %r15, %r12
callq 0x10f0
movq 0x20(%r14), %rdi
cmpb $0x0, (%rdi)
jne 0x5869
movq %rax, %rbp
leaq 0xdc4d(%rip), %r15      # 0x13568
jmp 0x591f
xorl %edi, %edi
callq 0x1030
movq %r13, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
pushq $0x1
popq %rbx
movq %rbx, %rsi
callq 0x10f0
movq %rax, 0x20(%r14)
movq %rax, %rdi
movq %r13, %rsi
callq 0x1060
movq %r13, %rdi
callq 0x1030
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x10f0
movq %rax, %r13
addq $0x8, %r14
movl 0xc(%rsp), %eax
jmp 0x583f
movq %r13, %rdi
callq 0x1030
movq %rbp, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq 0x10(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq