// File: /workspace/github_cpp_makefile_star2_O3/minirop[P]JDecomqiler/src/ClassFile.cpp
// Function: ClassFile::ClassFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
ClassFile::ClassFile(std::string filename)
{
	std::ifstream file(filename, std::ios::in | std::ios::binary);
	if(!file.is_open())
		return;
	
	stream.setStream(&file);
	
	std::uint32_t magic;
	stream >> magic;
	if(magic != 0xcafebabe)
	{
		cout << "magic number is " << std::hex << magic << endl;
		return;
	}
	
	std::uint16_t major, minor;
	stream >> minor >> major;
	cout << "JAVA " << major << "." << minor << endl;
	
	std::uint16_t constant_pool_count;
	stream >> constant_pool_count;
	cout << constant_pool_count << " constants" << endl;
	
	constant_pool.push_back(CPinfo()); // index 0 is invalid
	for(std::size_t i = 1;i < constant_pool_count;i++)
	{
		if(parseConstant()) // return true if double or bigint
		{
			constant_pool.push_back(CPinfo()); // double and bigint use 2 indexes
			i++;
		}
	}
	
	std::uint16_t access_flags, this_class, super_class;
	stream >> access_flags >> this_class >> super_class;
	
	if(access_flags & ACC_PUBLIC)
		output.isPublic = true;
	if(access_flags & ACC_FINAL)
		output.isFinal = true;
	if(access_flags & ACC_SUPER)
		cout << "is super, ignored." << endl;
	if(access_flags & ACC_INTERFACE)
		output.isInterface = true;
	if(access_flags & ACC_ABSTRACT)
		output.isAbstract = true;
	if(access_flags & ACC_ANNOTATION)
		output.isAnnotation = true;
	if(access_flags & ACC_ENUM)
		output.isEnum = true;
	if(access_flags & (~0x0631))
		cout << "ERROR: unrecognized flag(s)" << endl;
	
	output.name = getName(constant_pool[this_class].ClassInfo.name_index);
	output.extends = checkClassName(getName(constant_pool[super_class].ClassInfo.name_index));
	
	std::uint16_t interfaces_count;
	stream >> interfaces_count;
	cout << interfaces_count << " interfaces" << endl;
	for(std::uint16_t i = 0;i < interfaces_count;i++)
	{
		output.interfaces.push_back(parseInterface());
	}
	
	std::uint16_t fields_count;
	stream >> fields_count;
	cout << fields_count << " fields" << endl;
	for(std::uint16_t i = 0;i < fields_count;i++)
	{
		output.fields.push_back(parseField());
	}
	
	std::uint16_t methods_count;
	stream >> methods_count;
	cout << methods_count << " methods" << endl;
	for(std::uint16_t i = 0;i < methods_count;i++)
	{
		output.methods.push_back(parseMethod());
	}
	
	std::uint16_t attributes_count;
	stream >> attributes_count;
	cout << attributes_count << " attributes" << endl;
	for(std::uint16_t i = 0;i < attributes_count;i++)
	{
		parseAttribute();
	}
	
	file.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x8(%rdi)
movb %al, 0x10(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x20(%rdi)
movq %rax, 0x28(%rdi)
movb %al, 0x30(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x7e(%rdi)
movups %xmm0, 0x90(%rdi)
movq %rdi, -0x30(%rbp)
movq %rax, 0xa0(%rdi)
leaq -0x368(%rbp), %r14
movq %r14, %rdi
movl $0xc, %edx
callq 0x2340
leaq -0x2f0(%rbp), %rdi
callq 0x2090
testb %al, %al
je 0x331a
movq -0x30(%rbp), %rax
movq %r14, 0xa8(%rax)
leaq -0x100(%rbp), %rsi
movl $0x0, (%rsi)
movl $0x4, %edx
movq %r14, %rdi
callq 0x22d0
movl -0x100(%rbp), %ebx
bswapl %ebx
cmpl $0xcafebabe, %ebx       # imm = 0xCAFEBABE
jne 0x2c57
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
leaq -0x100(%rbp), %rsi
movzwl (%rsi), %r15d
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzbl -0x100(%rbp), %r14d
movzbl -0xff(%rbp), %ebx
movq 0x204a7(%rip), %rdi     # 0x22fd0
leaq 0x19545(%rip), %rsi     # 0x1c075
movl $0x5, %edx
callq 0x2280
shll $0x8, %r14d
orq %rbx, %r14
movq 0x20488(%rip), %rdi     # 0x22fd0
movq %r14, %rsi
callq 0x2170
movq %rax, %r14
leaq 0x1953d(%rip), %rsi     # 0x1c097
movl $0x1, %edx
movq %rax, %rdi
callq 0x2280
rolw $0x8, %r15w
movzwl %r15w, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x100(%rbp), %eax
rolw $0x8, %ax
movzwl %ax, %r15d
movq 0x203f7(%rip), %rdi     # 0x22fd0
movq %r15, %rsi
callq 0x2170
movq %rax, %r14
leaq 0x19490(%rip), %rsi     # 0x1c07b
movl $0xa, %edx
movq %rax, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
xorps %xmm0, %xmm0
movaps %xmm0, -0x100(%rbp)
movq $0x0, -0xf0(%rbp)
leaq 0x205dd(%rip), %r14     # 0x23218
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x2cc2
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
addq $0x18, 0x8(%r14)
jmp 0x2cd5
movq 0x20372(%rip), %r14     # 0x22fd0
leaq 0x193ff(%rip), %rsi     # 0x1c064
movl $0x10, %edx
movq %r14, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movl %ebx, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
jmp 0x331a
leaq 0x2054f(%rip), %rdi     # 0x23218
leaq -0x100(%rbp), %rdx
callq 0x45f0
cmpl $0x2, %r15d
jb 0x2d3c
movl $0x1, %r13d
leaq -0x100(%rbp), %r12
movq -0x30(%rbp), %rdi
callq 0x33e6
testb %al, %al
je 0x2d34
xorps %xmm0, %xmm0
movaps %xmm0, -0x100(%rbp)
movq $0x0, -0xf0(%rbp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x2d26
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
addq $0x18, 0x8(%r14)
jmp 0x2d31
movq %r14, %rdi
movq %r12, %rdx
callq 0x45f0
incq %r13
incq %r13
cmpq %r15, %r13
jb 0x2ce8
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
leaq -0x100(%rbp), %rsi
movzbl (%rsi), %r12d
movzbl 0x1(%rsi), %eax
movl %eax, -0x34(%rbp)
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
leaq -0x100(%rbp), %rsi
movzwl (%rsi), %ebx
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x34(%rbp), %eax
testb $0x1, %al
je 0x2dc0
movq -0x30(%rbp), %rcx
movb $0x1, 0x8b(%rcx)
testb $0x10, %al
je 0x2dcf
movq -0x30(%rbp), %rcx
movb $0x1, 0x88(%rcx)
movzwl -0x100(%rbp), %r13d
testb $0x20, %al
je 0x2e21
movq 0x201ee(%rip), %r15     # 0x22fd0
leaq 0x1929d(%rip), %rsi     # 0x1c086
movl $0x12, %edx
movq %r15, %rdi
callq 0x2280
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x201bc(%rip), %rdi     # 0x22fd0
callq 0x2040
movq %rax, %rdi
callq 0x2180
movzwl %r12w, %eax
testb $0x2, %al
je 0x2e34
movq -0x30(%rbp), %rcx
movb $0x1, 0x8a(%rcx)
shll $0x8, %r12d
testb $0x4, %al
je 0x2e47
movq -0x30(%rbp), %rcx
movb $0x1, 0x89(%rcx)
addl -0x34(%rbp), %r12d
testb $0x20, %al
je 0x2e5a
movq -0x30(%rbp), %rcx
movb $0x1, 0x8c(%rcx)
testb $0x40, %al
je 0x2e69
movq -0x30(%rbp), %rax
movb $0x1, 0x8d(%rax)
testl $0xf9ce, %r12d          # imm = 0xF9CE
je 0x2eb8
movq 0x20157(%rip), %r15     # 0x22fd0
leaq 0x19219(%rip), %rsi     # 0x1c099
movl $0x1b, %edx
movq %r15, %rdi
callq 0x2280
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0x20125(%rip), %rdi     # 0x22fd0
callq 0x2040
movq %rax, %rdi
callq 0x2180
rolw $0x8, %bx
movzwl %bx, %eax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movzwl 0x8(%rcx,%rax,8), %esi
leaq -0x100(%rbp), %rdi
callq 0x1a8c6
rolw $0x8, %r13w
movzwl %r13w, %ebx
leaq -0x100(%rbp), %r15
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x22c0
movq (%r15), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x2f07
callq 0x2200
movq (%r14), %rax
leaq (%rbx,%rbx,2), %rcx
movzwl 0x8(%rax,%rcx,8), %esi
leaq -0x120(%rbp), %rdi
callq 0x1a8c6
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x1a962
movq -0x30(%rbp), %rax
leaq 0x20(%rax), %rdi
leaq -0x100(%rbp), %r14
movq %r14, %rsi
callq 0x22c0
movq (%r14), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x2f5d
callq 0x2200
leaq -0x110(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f72
callq 0x2200
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x100(%rbp), %r12d
rolw $0x8, %r12w
movzwl %r12w, %esi
movq 0x20025(%rip), %rdi     # 0x22fd0
callq 0x2170
movq %rax, %r14
leaq 0x190fb(%rip), %rsi     # 0x1c0b5
movl $0xb, %edx
movq %rax, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
testw %r12w, %r12w
je 0x3031
movq -0x30(%rbp), %rax
leaq 0x40(%rax), %r14
movq %r15, %rdi
movq -0x30(%rbp), %rsi
callq 0x3634
movq %r14, %rdi
movq %r15, %rsi
callq 0x4768
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x302b
callq 0x2200
decw %r12w
jne 0x2ffc
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x100(%rbp), %r13d
rolw $0x8, %r13w
movzwl %r13w, %esi
movq 0x1ff66(%rip), %rdi     # 0x22fd0
callq 0x2170
movq %rax, %r14
leaq 0x19048(%rip), %rsi     # 0x1c0c1
movl $0x7, %edx
movq %rax, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
testw %r13w, %r13w
je 0x311e
movq -0x30(%rbp), %rax
leaq 0x70(%rax), %r14
leaq -0xc0(%rbp), %r15
leaq -0xd0(%rbp), %rbx
leaq -0x100(%rbp), %r12
movq %r12, %rdi
movq -0x30(%rbp), %rsi
callq 0x3756
movq %r14, %rdi
movq %r12, %rsi
callq 0x49d2
movq %r15, %rdi
callq 0x4328
movq -0xe0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3100
callq 0x2200
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x3118
callq 0x2200
decw %r13w
jne 0x30d0
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x100(%rbp), %r15d
rolw $0x8, %r15w
movzwl %r15w, %esi
movq 0x1fe79(%rip), %rdi     # 0x22fd0
callq 0x2170
movq %rax, %r14
leaq 0x18f63(%rip), %rsi     # 0x1c0c9
movl $0x8, %edx
movq %rax, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
testw %r15w, %r15w
je 0x3243
movq -0x30(%rbp), %rax
leaq 0x58(%rax), %r14
leaq -0x50(%rbp), %rbx
leaq -0xc0(%rbp), %r12
leaq -0x100(%rbp), %r13
movq %r13, %rdi
movq -0x30(%rbp), %rsi
callq 0x3b0c
movq %r14, %rdi
movq %r13, %rsi
callq 0x4ca4
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x31e3
callq 0x2200
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x31f5
callq 0x2200
leaq -0xa8(%rbp), %rdi
callq 0x4328
movq %r12, %rdi
callq 0x42d0
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x3221
callq 0x2200
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x3239
callq 0x2200
decw %r15w
jne 0x31be
leaq -0x100(%rbp), %rsi
movw $0x0, (%rsi)
movq -0x30(%rbp), %rax
movq 0xa8(%rax), %rdi
movl $0x2, %edx
callq 0x22d0
movzwl -0x100(%rbp), %r15d
rolw $0x8, %r15w
movzwl %r15w, %esi
movq 0x1fd54(%rip), %rdi     # 0x22fd0
callq 0x2170
movq %rax, %r14
leaq 0x18e47(%rip), %rsi     # 0x1c0d2
movl $0xb, %edx
movq %rax, %rdi
callq 0x2280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
testw %r15w, %r15w
je 0x330e
leaq -0x130(%rbp), %rbx
leaq -0x150(%rbp), %r12
leaq -0x160(%rbp), %r14
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0x3ebe
movq -0x140(%rbp), %rdi
cmpq %rbx, %rdi
je 0x32f7
callq 0x2200
movq -0x160(%rbp), %rdi
cmpq %r12, %rdi
je 0x3308
callq 0x2200
decw %r15w
jne 0x32da
leaq -0x368(%rbp), %rdi
callq 0x2080
leaq -0x368(%rbp), %rdi
callq 0x20a0
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3392
movq %rax, %r14
leaq -0x110(%rbp), %rax
movq -0x10(%rax), %rdi
jmp 0x33da
jmp 0x3392
jmp 0x3392
jmp 0x3392
movq %rax, %r14
jmp 0x33a1
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
jmp 0x3392
movq %rax, %r14
leaq -0x100(%rbp), %rdi
callq 0x41d2
jmp 0x3395
jmp 0x3392
movq %rax, %r14
leaq -0x100(%rbp), %rdi
callq 0x4194
jmp 0x3395
movq %rax, %r14
leaq -0x368(%rbp), %rdi
callq 0x20a0
movq -0x30(%rbp), %rax
addq $0x90, %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x33b8
callq 0x2200
movq -0x30(%rbp), %rdi
callq 0x4280
movq %r14, %rdi
callq 0x23b0
movq %rax, %r14
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x3395
callq 0x2200
jmp 0x3395