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

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

	buf = charalloc(type);

	// {
	get_token_llvm(buf, token);

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

	/*
	 * ポインタの位置の検出
	 */
	if(buf_ptr != NULL){
		// Type
		get_irtype_llvm(buf_ptr, token);
		// Name
		get_token_llvm(buf_ptr, token);
		ptr_cnt = atoi(token);	// 数字しかありえないはず
		// ,
		get_token_llvm(buf_ptr, token);
	}

	do{
		get_irtype_llvm(buf, token);
		if((strlen(token) == 0) || (!strcmp(token, ")"))) break;

		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;

		if(ptr_cnt > 0){
			size_count += size;
			ptr_cnt--;
		}

		// ","か"}"
		get_token_llvm(buf, token);
	}while(strlen(buf) > 0);

	if(ptr != NULL){
		if(rslt_ptr != NULL){
			if(strlen(temp) > 0){
				sprintf(rslt_ptr, "%s + (%d)", temp, size_count);
			}else{
				sprintf(rslt_ptr, "(%d)", size_count);
			}
		}
	}

	free(token);

	return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0x1100
movq %rax, -0x28(%rbp)
movl $0x400, %edi            # imm = 0x400
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13b0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
cmpq $0x0, -0x10(%rbp)
je 0x8fff
movq -0x10(%rbp), %rdi
callq 0x13b0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x9039
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x25b0
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x28(%rbp), %rdi
callq 0x1140
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
jmp 0x903b
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x25b0
movq -0x28(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
je 0x906c
movq -0x28(%rbp), %rdi
leaq 0xb0b7(%rip), %rsi      # 0x14119
callq 0x10d0
cmpl $0x0, %eax
jne 0x9071
jmp 0x9159
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x9096
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x91c0
movl %eax, -0x2c(%rbp)
jmp 0x9118
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x90b8
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x8f70
movl %eax, -0x2c(%rbp)
jmp 0x9116
movq -0x28(%rbp), %rdi
leaq 0x9f49(%rip), %rsi      # 0x1300c
callq 0x10d0
cmpl $0x0, %eax
jne 0x90d6
movl $0x1, -0x2c(%rbp)
jmp 0x9114
movq -0x28(%rbp), %rdi
leaq 0x9f2e(%rip), %rsi      # 0x1300f
callq 0x10d0
cmpl $0x0, %eax
jne 0x90f4
movl $0x2, -0x2c(%rbp)
jmp 0x9112
movq -0x28(%rbp), %rdi
leaq 0xb19a(%rip), %rsi      # 0x14299
callq 0x10d0
cmpl $0x0, %eax
jne 0x9110
movl $0x4, -0x2c(%rbp)
jmp 0x9112
jmp 0x9114
jmp 0x9116
jmp 0x9118
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x3c(%rbp)
jle 0x9139
movl -0x2c(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11ca0
movq -0x20(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
ja 0x903b
cmpq $0x0, -0x10(%rbp)
je 0x91aa
cmpq $0x0, -0x18(%rbp)
je 0x91a8
movq -0x48(%rbp), %rdi
callq 0x1070
cmpq $0x0, %rax
jbe 0x9191
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl -0x4c(%rbp), %ecx
leaq 0xa7e4(%rip), %rsi      # 0x1396c
movb $0x0, %al
callq 0x1160
jmp 0x91a6
movq -0x18(%rbp), %rdi
movl -0x4c(%rbp), %edx
leaq 0xa7d2(%rip), %rsi      # 0x13971
movb $0x0, %al
callq 0x1160
jmp 0x91a8
jmp 0x91aa
movq -0x28(%rbp), %rdi
callq 0x1030
movl -0x30(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)