// File: /workspace/github_c_makefile_star2_O1/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 0x8e4a(%rip), %rdi      # 0xe9b4
callq 0x1070
movl $0x400, %edi            # imm = 0x400
callq 0x1140
movq %rax, %rbx
movl $0x400, %edi            # imm = 0x400
callq 0x1140
movq %rax, %r14
movl $0x1, %edi
movl $0x1, %esi
callq 0x1100
movq %rax, %r12
movl $0x1, %edi
movl $0x1, %esi
callq 0x1100
movq %rax, %r13
movq 0xe9c4(%rip), %r15      # 0x14578
testq %r15, %r15
je 0x5cd9
movl $0x0, 0x4(%rsp)
cmpq $0x0, 0x20(%r15)
je 0x5c7a
movq 0x20(%r15), %rdi
movq %rbx, %rsi
callq 0xcc26
movq %r12, %rdi
callq 0x1395
movq %rax, %r13
movq %r12, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0xbe1a
movq %rbx, %rbp
testl %eax, %eax
je 0x5c14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbdd1
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 0x1100
movq %rax, %r12
movq %rax, %rdi
leaq 0x8b84(%rip), %rsi      # 0xe7ca
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11b0
movq %r13, %rdi
callq 0x1030
movl $0x1, %edi
movl $0x1, %esi
callq 0x1100
movq %rax, %r13
movq 0x20(%r15), %rax
cmpb $0x0, (%rax)
jne 0x5bd0
movq 0x20(%r15), %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
movl $0x1, %esi
callq 0x1100
movq %rax, 0x20(%r15)
movq %rax, %rdi
movq %r12, %rsi
callq 0x1060
movq %r12, %rdi
callq 0x1030
movl $0x1, %edi
movl $0x1, %esi
callq 0x1100
movq %rax, %r12
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x5bc5
cmpl $0x0, 0x4(%rsp)
sete %al
jmp 0x5cdb
movb $0x1, %al
testb %al, %al
je 0x5bad
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