// File: minirop[P]JDecomqiler/src/ClassFile.cpp
// Function: ClassFile::parseField()
FieldOutput ClassFile::parseField()
{
	FieldOutput field;
	
	std::uint16_t access_flags, name_index, descriptor_index;
	stream >> access_flags >> name_index >> descriptor_index;
	
	field.name = getName(name_index);
	int i = 0;
	field.type = parseType(getName(descriptor_index), i);
	
	if(access_flags & ACC_PUBLIC)
		field.isPublic = true;
	if(access_flags & ACC_PRIVATE)
		field.isPrivate = true;
	if(access_flags & ACC_PROTECTED)
		field.isProtected = true;
	if(access_flags & ACC_STATIC)
		field.isStatic = true;
	if(access_flags & ACC_FINAL)
		field.isFinal = true;
	if(access_flags & ACC_VOLATILE)
		field.isVolatile = true;
	if(access_flags & ACC_TRANSIENT)
		field.isTransient = true;
	if(access_flags & ACC_SYNTHETIC)
		cout << "Declared synthetic; not present in the source code." << endl;
	if(access_flags & ACC_ENUM)
		cout << "is part of an enum." << endl;
	if(access_flags & ~ACC_FIELD_MASK)
		cerr << "ERROR: unrecognized flag(s)" << endl;
	
	std::uint16_t attributes_count;
	stream >> attributes_count;
	cout << "- " << attributes_count << " attributes" << endl;
	for(std::uint16_t i = 0;i < attributes_count;i++)
	{
		field.attributes.push_back(parseAttribute());
	}
	
	return field;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0xf8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x5ba0
movq -0xe8(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x14(%rbp), %rsi
callq 0x3b40
movq %rax, -0xe0(%rbp)
jmp 0x4b28
movq -0xe0(%rbp), %rdi
leaq -0x16(%rbp), %rsi
callq 0x3b40
movq %rax, -0x100(%rbp)
jmp 0x4b41
movq -0x100(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3b40
jmp 0x4b53
movzwl -0x16(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x28ed0
jmp 0x4b62
movq -0xf8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq %rsi, -0x108(%rbp)
callq 0x3350
movq -0x108(%rbp), %rdi
callq 0x31d0
movl $0x0, -0x4c(%rbp)
movzwl -0x18(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x28ed0
jmp 0x4b9e
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
callq 0x29470
jmp 0x4bb4
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x70(%rbp), %rsi
callq 0x3350
leaq -0x70(%rbp), %rdi
callq 0x31d0
leaq -0x90(%rbp), %rdi
callq 0x31d0
movzwl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4c24
movq -0xf8(%rbp), %rax
movb $0x1, 0x58(%rax)
jmp 0x4c24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x4eaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x31d0
jmp 0x4eaf
movzwl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4c3b
movq -0xf8(%rbp), %rax
movb $0x1, 0x5a(%rax)
movzwl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4c52
movq -0xf8(%rbp), %rax
movb $0x1, 0x59(%rax)
movzwl -0x14(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x4c69
movq -0xf8(%rbp), %rax
movb $0x1, 0x5d(%rax)
movzwl -0x14(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x4c80
movq -0xf8(%rbp), %rax
movb $0x1, 0x5c(%rax)
movzwl -0x14(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x4c97
movq -0xf8(%rbp), %rax
movb $0x1, 0x5b(%rax)
movzwl -0x14(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x4cb0
movq -0xf8(%rbp), %rax
movb $0x1, 0x5e(%rax)
movzwl -0x14(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x4cf1
movq 0x3330b(%rip), %rdi     # 0x37fd0
leaq 0x25455(%rip), %rsi     # 0x2a121
callq 0x32a0
movq %rax, -0x110(%rbp)
jmp 0x4cda
movq -0x110(%rbp), %rdi
movq 0x332d8(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x4cef
jmp 0x4cf1
movzwl -0x14(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x4d32
movq 0x332ca(%rip), %rdi     # 0x37fd0
leaq 0x25448(%rip), %rsi     # 0x2a155
callq 0x32a0
movq %rax, -0x118(%rbp)
jmp 0x4d1b
movq -0x118(%rbp), %rdi
movq 0x33297(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x4d30
jmp 0x4d32
movzwl -0x14(%rbp), %eax
andl $0xffffaf20, %eax       # imm = 0xFFFFAF20
cmpl $0x0, %eax
je 0x4d73
movq 0x332a9(%rip), %rdi     # 0x37ff0
leaq 0x2534b(%rip), %rsi     # 0x2a099
callq 0x32a0
movq %rax, -0x120(%rbp)
jmp 0x4d5c
movq -0x120(%rbp), %rdi
movq 0x33256(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x4d71
jmp 0x4d73
movq -0xe8(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x92(%rbp), %rsi
callq 0x3b40
jmp 0x4d8f
movq 0x3323a(%rip), %rdi     # 0x37fd0
leaq 0x259a1(%rip), %rsi     # 0x2a73e
callq 0x32a0
movq %rax, -0x128(%rbp)
jmp 0x4dab
movq -0x128(%rbp), %rdi
movzwl -0x92(%rbp), %esi
callq 0x34a0
movq %rax, -0x130(%rbp)
jmp 0x4dc7
movq -0x130(%rbp), %rdi
leaq 0x252fd(%rip), %rsi     # 0x2a0d2
callq 0x32a0
movq %rax, -0x138(%rbp)
jmp 0x4de3
movq -0x138(%rbp), %rdi
movq 0x331cf(%rip), %rsi     # 0x37fc0
callq 0x32d0
jmp 0x4df8
movw $0x0, -0x94(%rbp)
movzwl -0x94(%rbp), %eax
movzwl -0x92(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4e89
movq -0xe8(%rbp), %rsi
movq -0xf8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x140(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x52a0
jmp 0x4e3a
movq -0x140(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x5c00
jmp 0x4e4f
leaq -0xd8(%rbp), %rdi
callq 0x58c0
movw -0x94(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x94(%rbp)
jmp 0x4e01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x58c0
jmp 0x4eaf
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x4e9f
movq -0xf8(%rbp), %rdi
callq 0x57e0
movq -0xf0(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0xf8(%rbp), %rdi
callq 0x57e0
movq -0x20(%rbp), %rdi
callq 0x34e0
nopw %cs:(%rax,%rax)