// File: /workspace/github_c_makefile_star2_O0/aquaxis[P]synverll/src/parser_ir_memory.c
// Function: _get_array_size
int __get_array_size(char *type, char *ptr, char *rslt_ptr)
{
	char *buf;
	char *token;
	int size = 0;
	int total = 0;
	int num = 0;
	char *buf_ptr = NULL;
	char *ptr_cnt = NULL;
	char *temp = NULL;
	char *str = NULL;

	token = malloc(STR_MAX);
	temp = calloc(STR_MAX,1);

	buf = charalloc(type);

	if(ptr != NULL){
		if(strlen(ptr) > 0){
			buf_ptr = charalloc(ptr);
		}
	}

	/*
	 * ポインタの位置の検出
	 */
	if(buf_ptr != NULL){
		// Type
		get_irtype_llvm(buf_ptr, token);
		// Name
		get_token_llvm(buf_ptr, token);
		str = regalloc(token);
		ptr_cnt = charalloc(str);
		free(str);
		// ,
		get_token_llvm(buf_ptr, token);
	}

	// [ num x type ]
	// [
	get_token_llvm(buf, token);
	// num
	get_token_llvm(buf, token);
	num = atoi(token);
	// x
	get_token_llvm(buf, token);
	// type
	get_irtype_llvm(buf, token);

	if(token[0] == '['){
		size = __get_array_size(token, buf_ptr, temp);
	}else if(token[0] == '{'){
		size = __get_struct_size(token, buf_ptr, temp);
	}else if(!strcmp(token, "i8")){
		size = 1;
	}else if(!strcmp(token, "i16")){
		size = 2;
	}else if(!strcmp(token, "i32")){
		size = 4;
	}
	total += size * num;

	// ]
	get_token_llvm(buf, token);

	if(ptr_cnt != NULL){
		if(rslt_ptr != NULL){
			if(strlen(temp) > 0){
				sprintf(rslt_ptr, "%s + (%d * %s)", temp, size, ptr_cnt);
			}else{
				sprintf(rslt_ptr, "(%d * %s)", size, ptr_cnt);
			}
		}
		free(ptr_cnt);
	}

	return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x1100
movq %rax, -0x28(%rbp)
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x925c
movq -0x10(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
jbe 0x925a
movq -0x10(%rbp), %rdi
callq 0x13b0
movq %rax, -0x40(%rbp)
jmp 0x925c
cmpq $0x0, -0x40(%rbp)
je 0x92ad
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x25b0
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x28(%rbp), %rdi
callq 0xaa30
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x13b0
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x28(%rbp), %rdi
callq 0x1140
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x25b0
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x9312
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x91c0
movl %eax, -0x2c(%rbp)
jmp 0x9394
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x9334
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x8f70
movl %eax, -0x2c(%rbp)
jmp 0x9392
movq -0x28(%rbp), %rdi
leaq 0x9ccd(%rip), %rsi      # 0x1300c
callq 0x10d0
cmpl $0x0, %eax
jne 0x9352
movl $0x1, -0x2c(%rbp)
jmp 0x9390
movq -0x28(%rbp), %rdi
leaq 0x9cb2(%rip), %rsi      # 0x1300f
callq 0x10d0
cmpl $0x0, %eax
jne 0x9370
movl $0x2, -0x2c(%rbp)
jmp 0x938e
movq -0x28(%rbp), %rdi
leaq 0xaf1e(%rip), %rsi      # 0x14299
callq 0x10d0
cmpl $0x0, %eax
jne 0x938c
movl $0x4, -0x2c(%rbp)
jmp 0x938e
jmp 0x9390
jmp 0x9392
jmp 0x9394
movl -0x2c(%rbp), %eax
imull -0x34(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
cmpq $0x0, -0x48(%rbp)
je 0x940e
cmpq $0x0, -0x18(%rbp)
je 0x9405
movq -0x50(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
jbe 0x93ea
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %r8
leaq 0xa595(%rip), %rsi      # 0x13976
movb $0x0, %al
callq 0x1160
jmp 0x9403
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %rcx
leaq 0xa57f(%rip), %rsi      # 0x1397b
movb $0x0, %al
callq 0x1160
jmp 0x9405
movq -0x48(%rbp), %rdi
callq 0x1030
movl -0x30(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)