// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
leaq 0xb838(%rip), %rdi      # 0x137ee
movb $0x0, %al
callq 0x1090
movl $0x400, %edi            # imm = 0x400
callq 0x1100
movq %rax, -0x20(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x1100
movq %rax, -0x28(%rbp)
movl $0x1, %esi
movq %rsi, %rdi
callq 0x10c0
movq %rax, -0x10(%rbp)
movl $0x1, %esi
movq %rsi, %rdi
callq 0x10c0
movq %rax, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movq 0x1053f(%rip), %rax     # 0x18548
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x81a7
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x8139
jmp 0x8029
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x11ca0
movq -0x10(%rbp), %rdi
callq 0x13b0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rdi
callq 0x10530
cmpl $0x0, %eax
je 0x80bd
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x104b0
movq -0x18(%rbp), %rdi
callq 0x1070
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1070
movq -0x38(%rbp), %rdi
addq %rax, %rdi
addq $0x3, %rdi
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0xb758(%rip), %rsi      # 0x13805
movb $0x0, %al
callq 0x1160
movl $0x1, -0x2c(%rbp)
jmp 0x8106
movq -0x18(%rbp), %rdi
callq 0x1070
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1070
movq -0x40(%rbp), %rdi
addq %rax, %rdi
addq $0x3, %rdi
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0xb706(%rip), %rsi      # 0x13805
movb $0x0, %al
callq 0x1160
movq -0x18(%rbp), %rdi
callq 0x1030
movl $0x1, %esi
movq %rsi, %rdi
callq 0x10c0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1070
cmpq $0x0, %rax
ja 0x8029
jmp 0x8139
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1030
movq -0x10(%rbp), %rdi
callq 0x1070
movq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x10c0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1050
movq -0x10(%rbp), %rdi
callq 0x1030
movl $0x1, %esi
movq %rsi, %rdi
callq 0x10c0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x800d
jmp 0x81a9
cmpl $0x0, -0x2c(%rbp)
jne 0x7ffb
movq -0x10(%rbp), %rdi
callq 0x1030
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nop