// File: minirop[P]JDecomqiler/src/ClassFile.cpp
// Function: ClassFile::parseMethod()
MethodOutput ClassFile::parseMethod()
{
	MethodOutput method;
	
	std::uint16_t access_flags, name_index, descriptor_index;
	stream >> access_flags >> name_index >> descriptor_index;
	method.name = getName(name_index);
	
	if(access_flags & ACC_PUBLIC)
		method.isPublic = true;
	if(access_flags & ACC_PRIVATE)
		method.isPrivate = true;
	if(access_flags & ACC_PROTECTED)
		method.isProtected = true;
	if(access_flags & ACC_STATIC)
		method.isStatic = true;
	if(access_flags & ACC_FINAL)
		method.isFinal = true;
	if(access_flags & ACC_SYNCHRONIZED)
		method.isSynchronized = true;
	if(access_flags & ACC_BRIDGE)
		method.isBridge = true;
	if(access_flags & ACC_VARARGS)
		method.isVarargs = true;
	if(access_flags & ACC_NATIVE)
		method.isNative = true;
	if(access_flags & ACC_ABSTRACT)
		method.isAbstract = true;
	if(access_flags & ACC_STRICT)
		method.isStrict = true;
	if(access_flags & ACC_SYNTHETIC)
		cout << "Declared synthetic; not present in the source code." << endl;
	if(access_flags & ~ACC_METHOD_MASK)
		cerr << "ERROR: unrecognized flag(s)" << endl;
	
	method.parametersType = parseSignature(getName(descriptor_index));
	method.returnType = method.parametersType.back();
	method.parametersType.pop_back();
	
	std::uint16_t attributes_count;
	stream >> attributes_count;
	for(std::uint16_t i = 0;i < attributes_count;i++)
	{
		method.attributes.push_back(parseAttribute());
	}
	
	return method;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x5c30
movq -0xd8(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x14(%rbp), %rsi
callq 0x3b40
movq %rax, -0xd0(%rbp)
jmp 0x4f28
movq -0xd0(%rbp), %rdi
leaq -0x16(%rbp), %rsi
callq 0x3b40
movq %rax, -0xf0(%rbp)
jmp 0x4f41
movq -0xf0(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3b40
jmp 0x4f53
movzwl -0x16(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x28ed0
jmp 0x4f62
movq -0xe8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3350
leaq -0x48(%rbp), %rdi
callq 0x31d0
movzwl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4fa5
movq -0xe8(%rbp), %rax
movb $0x1, 0x70(%rax)
jmp 0x4fa5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x5289
movzwl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4fbc
movq -0xe8(%rbp), %rax
movb $0x1, 0x72(%rax)
movzwl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4fd3
movq -0xe8(%rbp), %rax
movb $0x1, 0x71(%rax)
movzwl -0x14(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x4fea
movq -0xe8(%rbp), %rax
movb $0x1, 0x75(%rax)
movzwl -0x14(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x5001
movq -0xe8(%rbp), %rax
movb $0x1, 0x74(%rax)
movzwl -0x14(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x5018
movq -0xe8(%rbp), %rax
movb $0x1, 0x76(%rax)
movzwl -0x14(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x502f
movq -0xe8(%rbp), %rax
movb $0x1, 0x77(%rax)
movzwl -0x14(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5048
movq -0xe8(%rbp), %rax
movb $0x1, 0x78(%rax)
movzwl -0x14(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x5061
movq -0xe8(%rbp), %rax
movb $0x1, 0x79(%rax)
movzwl -0x14(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x507a
movq -0xe8(%rbp), %rax
movb $0x1, 0x73(%rax)
movzwl -0x14(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x5093
movq -0xe8(%rbp), %rax
movb $0x1, 0x7a(%rax)
movzwl -0x14(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x50d4
movq 0x32f28(%rip), %rdi     # 0x37fd0
leaq 0x25072(%rip), %rsi     # 0x2a121
callq 0x32a0
movq %rax, -0xf8(%rbp)
jmp 0x50bd
movq -0xf8(%rbp), %rdi
movq 0x32ef5(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x50d2
jmp 0x50d4
movzwl -0x14(%rbp), %eax
andl $0xffffe200, %eax       # imm = 0xFFFFE200
cmpl $0x0, %eax
je 0x5115
movq 0x32f07(%rip), %rdi     # 0x37ff0
leaq 0x24fa9(%rip), %rsi     # 0x2a099
callq 0x32a0
movq %rax, -0x100(%rbp)
jmp 0x50fe
movq -0x100(%rbp), %rdi
movq 0x32eb4(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x5113
jmp 0x5115
movzwl -0x18(%rbp), %esi
leaq -0x80(%rbp), %rdi
callq 0x28ed0
jmp 0x5124
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x29170
jmp 0x5133
movq -0xe8(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x108(%rbp)
leaq -0x60(%rbp), %rsi
movq %rsi, -0x110(%rbp)
callq 0x5cd0
movq -0x110(%rbp), %rdi
callq 0x5d00
leaq -0x80(%rbp), %rdi
callq 0x31d0
movq -0x108(%rbp), %rdi
callq 0x5d60
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rdi
callq 0x3060
jmp 0x518b
movq -0xe8(%rbp), %rdi
addq $0x40, %rdi
callq 0x5da0
movq -0xd8(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x82(%rbp), %rsi
callq 0x3b40
jmp 0x51b7
movw $0x0, -0x84(%rbp)
movzwl -0x84(%rbp), %eax
movzwl -0x82(%rbp), %ecx
cmpl %ecx, %eax
jge 0x5263
movq -0xd8(%rbp), %rsi
movq -0xe8(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x118(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x52a0
jmp 0x51fd
movq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5c00
jmp 0x5212
leaq -0xc8(%rbp), %rdi
callq 0x58c0
movw -0x84(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x84(%rbp)
jmp 0x51c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31d0
jmp 0x5289
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x58c0
jmp 0x5289
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x5279
movq -0xe8(%rbp), %rdi
callq 0x5850
movq -0xe0(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xe8(%rbp), %rdi
callq 0x5850
movq -0x20(%rbp), %rdi
callq 0x34e0
nop