// File: /workspace/github_cpp_makefile_star2_O3/minirop[P]JDecomqiler/src/ClassFile.cpp
// Function: ClassFile::parseConstant()
bool ClassFile::parseConstant()
{
	bool isDoubleSize = false;
	
	CPinfo info;
	
	stream >> info.tag;
	
	switch(info.tag)
	{
		case CONSTANT_Utf8:
			{
				std::uint16_t length;
				stream >> length;
				char * string = new char[length+1];
				stream.readRawData(string, length);
				string[length] = 0;
				info.UTF8Info.bytes = string;
				toDelete.push_back(string);
			}
			break;
		case CONSTANT_Integer:
			stream >> info.IntegerInfo.bytes;
			break;
		case CONSTANT_Float:
			stream >> info.FloatInfo.bytes;
			break;
		case CONSTANT_Long:
			stream >> info.BigIntInfo.bytes;
			isDoubleSize = true;
			break;
		case CONSTANT_Double:
			stream >> info.DoubleInfo.bytes;
			isDoubleSize = true;
			break;
		case CONSTANT_Class:
			stream >> info.ClassInfo.name_index;
			break;
		case CONSTANT_String:
			stream >> info.StringInfo.string_index;
			break;
		case CONSTANT_Fieldref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_Methodref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_InterfaceMethodref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_NameAndType:
			stream >> info.NameAndTypeInfo.name_index;
			stream >> info.NameAndTypeInfo.descriptor_index;
			break;
		case CONSTANT_MethodHandle:
			stream >> info.MethodHandleInfo.reference_kind;
			stream >> info.MethodHandleInfo.reference_index;
			break;
		case CONSTANT_MethodType:
			stream >> info.MethodTypeInfo.descriptor_index;
			break;
		case CONSTANT_InvokeDynamic:
			stream >> info.InvokeDynamicInfo.bootstrap_method_attr_index;
			stream >> info.InvokeDynamicInfo.name_and_type_index;
			break;
		default:
			cerr << "ERROR: unrecognize TAG" << endl;
			exit(1);
	}
	
	constant_pool.push_back(info);
	
	return isDoubleSize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
leaq -0x28(%rbp), %rbx
movb $0x0, (%rbx)
movq 0xa8(%rdi), %rdi
movl $0x1, %edx
movq %rbx, %rsi
callq 0x22d0
movzbl (%rbx), %eax
movb %al, -0x40(%rbp)
decl %eax
cmpl $0x11, %eax
ja 0x360e
leaq 0x18bf1(%rip), %rcx     # 0x1c01c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebx, %ebx
leaq -0x28(%rbp), %r15
movw %bx, (%r15)
movq 0xa8(%r14), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x22d0
movzwl (%r15), %eax
rolw $0x8, %ax
movw %ax, -0x38(%rbp)
movw %bx, (%r15)
movq 0xa8(%r14), %rdi
leaq -0x28(%rbp), %r14
movl $0x2, %edx
movq %r14, %rsi
callq 0x22d0
movzwl (%r14), %eax
rolw $0x8, %ax
movw %ax, -0x36(%rbp)
jmp 0x35c8
movw $0x0, (%rbx)
movq 0xa8(%r14), %rdi
movl $0x2, %edx
movq %rbx, %rsi
callq 0x22d0
movzwl (%rbx), %eax
rolw $0x8, %ax
movw %ax, -0x38(%rbp)
jmp 0x35c6
movl $0x0, (%rbx)
movq 0xa8(%r14), %rdi
movl $0x4, %edx
movq %rbx, %rsi
callq 0x22d0
movl (%rbx), %eax
bswapl %eax
movl %eax, -0x38(%rbp)
jmp 0x35c6
xorl %ebx, %ebx
leaq -0x28(%rbp), %rsi
movq %rbx, (%rsi)
movq 0xa8(%r14), %rdi
movl $0x8, %edx
callq 0x22d0
movq %rbx, -0x38(%rbp)
movb $0x1, %bl
jmp 0x35c8
leaq -0x28(%rbp), %r15
movw $0x0, (%r15)
movq 0xa8(%r14), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x22d0
movzwl (%r15), %eax
rolw $0x8, %ax
movzwl %ax, %r12d
leaq 0x1(%r12), %rdi
callq 0x2030
movq %rax, %rbx
movq %rax, (%r15)
movq 0xa8(%r14), %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x22d0
movb $0x0, (%rbx,%r12)
movq %rbx, -0x30(%rbp)
movq 0x98(%r14), %rsi
cmpq 0xa0(%r14), %rsi
je 0x35b3
movq %rbx, (%rsi)
addq $0x8, 0x98(%r14)
jmp 0x35c6
movb $0x0, (%rbx)
movq 0xa8(%r14), %rdi
movl $0x1, %edx
movq %rbx, %rsi
callq 0x22d0
movb (%rbx), %al
movb %al, -0x38(%rbp)
movw $0x0, (%rbx)
movq 0xa8(%r14), %rdi
movl $0x2, %edx
movq %rbx, %rsi
callq 0x22d0
movzwl (%rbx), %eax
rolw $0x8, %ax
movw %ax, -0x36(%rbp)
jmp 0x35c6
addq $0x90, %r14
leaq -0x28(%rbp), %rdx
movq %r14, %rdi
callq 0x5142
xorl %ebx, %ebx
leaq 0x1fc49(%rip), %rax     # 0x23218
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x35ef
movq -0x30(%rbp), %rcx
movq %rcx, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rax)
jmp 0x35ff
leaq 0x1fc22(%rip), %rdi     # 0x23218
leaq -0x40(%rbp), %rdx
callq 0x527c
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x1f9db(%rip), %rdi     # 0x22ff0
leaq 0x18aee(%rip), %rsi     # 0x1c10a
callq 0x2220
movq %rax, %rdi
callq 0x2130
movl $0x1, %edi
callq 0x22a0
nop