// File: martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute_R_X(mips_cpu_impl*, unsigned int&, unsigned int&, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute_R_X(mips_cpu_h state, uint32_t& hi, uint32_t& lo, const uint32_t* instruction_data, const string& op, string& instruction, uint32_t& pcN, uint32_t& pc){

	stringstream ss;

	mips_error err = mips_ExceptionInvalidInstruction;;
	uint32_t* source1 = new uint32_t;
	uint32_t* source2 = new uint32_t;
	uint32_t destination = instruction_data[3];
	uint32_t shift = instruction_data[4];

	err = mips_cpu_get_register(state, (unsigned)instruction_data[1], source1);
	if (err==mips_Success)
		err = mips_cpu_get_register(state, (unsigned)instruction_data[2], source2);
	if (err!=mips_Success)
		return mips_ExceptionAccessViolation;

	if (op.compare("ADDU")==0)
		err = mips_cpu_set_register(state, destination, *source1 + *source2);

	if (op.compare("SRL")==0)
		err = mips_cpu_set_register(state, destination, uint32_t(*source2) >> shift);

	if (op.compare("SRA")==0)
		err = mips_cpu_set_register(state, destination, int32_t(*source2) >> shift);

	if (op.compare("SRAV")==0)
		err = mips_cpu_set_register(state, destination, int32_t(*source2) >> (*source1 & 0x1F));

	if (op.compare("SRLV")==0)
		err = mips_cpu_set_register(state, destination, uint32_t(*source2) >> (*source1 & 0x1F));

	if (op.compare("SLL")==0)
		err = mips_cpu_set_register(state, destination, *source2 << shift);

	if (op.compare("SLLV")==0)
		err = mips_cpu_set_register(state, destination, *source2 << (*source1 & 0x1F));

	if (op.compare("SUBU")==0)
		err = mips_cpu_set_register(state, destination, *source1 - *source2);

	if (op.compare("SUB")==0){
		if (!subtraction_overflow(*source1,*source2))
			err = mips_cpu_set_register(state, destination, int32_t(*source1) - int32_t(*source2));
		else
			err = mips_ExceptionArithmeticOverflow;
	}

	if (op.compare("AND")==0)
		err = mips_cpu_set_register(state, destination, *source1 & *source2);

	if (op.compare("OR")==0)
		err = mips_cpu_set_register(state, destination, *source1 | *source2);

	if (op.compare("XOR")==0)
		err = mips_cpu_set_register(state, destination, uint32_t(*source1 ^ *source2));

	if(op.compare("SLT")==0)
		err = mips_cpu_set_register(state, destination, int((int32_t(*source1) < int32_t(*source2))));

	if (op.compare("SLTU")==0)
		err = mips_cpu_set_register(state, destination, int(*source1 < *source2));

	if (op.compare("ADD")==0){
		if (!addition_overflow(*source1 ,*source2))
			err = mips_cpu_set_register(state, destination, *source1 + *source2);
		else
			err = mips_ExceptionArithmeticOverflow;
	}
	if (op.compare("MFLO")==0)
		err = mips_cpu_set_register(state, destination, lo);

	if (op.compare("MTLO")==0){
		lo = *source1;
		err = mips_Success;
	}
	if (op.compare("MFHI")==0)
		err = mips_cpu_set_register(state, destination, hi);

	if (op.compare("MTHI")==0){
		hi = *source1;
		err = mips_Success;
	}
	if (op.compare("MULT")==0){
		int64_t result =  int64_t(*source1) * int64_t(*source2);
		lo = uint32_t(result & 0xFFFFFFFF);
		hi = int32_t((result & 0xFFFFFFFF00000000) >> 32);
		err = mips_Success;
	}
	if (op.compare("MULTU")==0){
		uint64_t result =  uint64_t(*source1) * uint64_t(*source2);
		lo = uint32_t(result & 0xFFFFFFFF);
		hi = (uint32_t(result >> 32 ) & 0xFFFFFFFF);
		err = mips_Success;
	}

	if (op.compare("DIV")==0){
		if (*source2!=0) {
			lo = (int32_t(*source1) / int32_t(*source2));
			hi = (int32_t(*source1) % int32_t(*source2));
			err = mips_Success;
		} else {
			err = mips_ExceptionInvalidInstruction;
		}
	}

	if (op.compare("DIVU")==0){
		if (*source2!=0){
			lo = (uint32_t(*source1) / uint32_t(*source2));
			hi = (uint32_t(*source1) % uint32_t(*source2));
			err = mips_Success;
		} else {
			err = mips_ExceptionInvalidInstruction;
		}
	}

	if (op.compare("JR")==0){
		pc = pcN;
		pcN = *source1;
		err = mips_ExceptionBreak;
	}

	if (op.compare("JALR")==0){
		mips_cpu_set_register(state, destination, pc + 8 );
		pc = pcN;
		pcN = *source1;
		err = mips_ExceptionBreak;
	}


	//COUT OUTPUT
	if ((err==mips_Success) || (err == mips_ExceptionBreak)) {
		if ((op.compare("MTHI")==0) || (op.compare("MTLO")==0) || (op.compare("JR")==0))
		ss <<op<<" R["<<instruction_data[1]<<"]";
		if (op.compare("JALR")==0)
		ss <<op<<" R["<<instruction_data[3]<<"] , R["<<instruction_data[1]<<"]";
		if ((op.compare("MFHI")==0) || (op.compare("MFLO")==0))
		ss <<op<<" R["<<instruction_data[3]<<"]";
		if ((op.compare("SLL")==0)  || (op.compare("SRL")==0) || (op.compare("SRA")==0))
		ss <<op<<" R["<<instruction_data[3]<<"] , R["<<instruction_data[2]<<"], #"<<instruction_data[4];
		if ((op.compare("SLLV")==0) || (op.compare("SRAV")==0) || (op.compare("SRLV")==0))
		ss <<op<<" R["<<instruction_data[3]<<"] , R["<<instruction_data[2]<<"] , R["<<instruction_data[1]<<"]";
		if ((op.compare("SLT")==0) || (op.compare("SLTU")==0))
		ss <<op<<" R["<<instruction_data[3]<<"] , R["<<instruction_data[1]<<"] , R["<<instruction_data[2]<<"]";
		if ((op.compare("MULT")==0) || (op.compare("MULTU")==0) || (op.compare("DIV")==0) || (op.compare("DIVU")==0))
		ss <<op<<" R["<<instruction_data[1]<<"] , R["<<instruction_data[2]<<"]";
		if (ss.str().empty())
		ss <<op<<" R["<<instruction_data[3]<<"] , R["<<instruction_data[1]<<"] , R["<<instruction_data[2]<<"]";
		instruction = ss.str();
	} else
		instruction = "Invalid instruction";


	delete source1; delete source2;
	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31b0
movl $0x2005, -0x1c4(%rbp)   # imm = 0x2005
movl $0x4, %edi
callq 0x3270
movq %rax, -0x250(%rbp)
jmp 0xbd94
movq -0x250(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movl $0x4, %edi
callq 0x3270
movq %rax, -0x258(%rbp)
jmp 0xbdb5
movq -0x258(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1ec(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x1f0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x1d0(%rbp), %rdx
callq 0x7c70
movl %eax, -0x25c(%rbp)
jmp 0xbdfc
movl -0x25c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
cmpl $0x0, -0x1c4(%rbp)
jne 0xbe61
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x1e8(%rbp), %rdx
callq 0x7c70
movl %eax, -0x260(%rbp)
jmp 0xbe30
movl -0x260(%rbp), %eax
movl %eax, -0x1c4(%rbp)
jmp 0xbe61
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31d0
jmp 0xce81
cmpl $0x0, -0x1c4(%rbp)
je 0xbe80
movl $0x2004, -0x4(%rbp)     # imm = 0x2004
movl $0x1, -0x1f4(%rbp)
jmp 0xce69
movq -0x30(%rbp), %rdi
leaq 0x6709(%rip), %rsi      # 0x12594
callq 0x30d0
cmpl $0x0, %eax
jne 0xbecc
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
addl %eax, %edx
callq 0x7cc0
movl %eax, -0x264(%rbp)
jmp 0xbec0
movl -0x264(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6ae3(%rip), %rsi      # 0x129ba
callq 0x30d0
cmpl $0x0, %eax
jne 0xbf15
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movb -0x1f0(%rbp), %cl
shrl %cl, %edx
callq 0x7cc0
movl %eax, -0x268(%rbp)
jmp 0xbf09
movl -0x268(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6a5a(%rip), %rsi      # 0x1297a
callq 0x30d0
cmpl $0x0, %eax
jne 0xbf5e
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movb -0x1f0(%rbp), %cl
sarl %cl, %edx
callq 0x7cc0
movl %eax, -0x26c(%rbp)
jmp 0xbf52
movl -0x26c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6a2c(%rip), %rsi      # 0x12995
callq 0x30d0
cmpl $0x0, %eax
jne 0xbfaa
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movq -0x1d0(%rbp), %rax
movb (%rax), %cl
sarl %cl, %edx
callq 0x7cc0
movl %eax, -0x270(%rbp)
jmp 0xbf9e
movl -0x270(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6a1d(%rip), %rsi      # 0x129d2
callq 0x30d0
cmpl $0x0, %eax
jne 0xbff6
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movq -0x1d0(%rbp), %rax
movb (%rax), %cl
shrl %cl, %edx
callq 0x7cc0
movl %eax, -0x274(%rbp)
jmp 0xbfea
movl -0x274(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x68b1(%rip), %rsi      # 0x128b2
callq 0x30d0
cmpl $0x0, %eax
jne 0xc03f
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movb -0x1f0(%rbp), %cl
shll %cl, %edx
callq 0x7cc0
movl %eax, -0x278(%rbp)
jmp 0xc033
movl -0x278(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x687f(%rip), %rsi      # 0x128c9
callq 0x30d0
cmpl $0x0, %eax
jne 0xc08b
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1e8(%rbp), %rax
movl (%rax), %edx
movq -0x1d0(%rbp), %rax
movb (%rax), %cl
shll %cl, %edx
callq 0x7cc0
movl %eax, -0x27c(%rbp)
jmp 0xc07f
movl -0x27c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x696b(%rip), %rsi      # 0x12a01
callq 0x30d0
cmpl $0x0, %eax
jne 0xc0d7
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
subl %eax, %edx
callq 0x7cc0
movl %eax, -0x280(%rbp)
jmp 0xc0cb
movl -0x280(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6912(%rip), %rsi      # 0x129f4
callq 0x30d0
cmpl $0x0, %eax
jne 0xc15c
movq -0x1d0(%rbp), %rax
movl (%rax), %edi
movq -0x1e8(%rbp), %rax
movl (%rax), %esi
callq 0xe510
movb %al, -0x281(%rbp)
jmp 0xc10b
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0xc150
jmp 0xc117
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
subl %eax, %edx
callq 0x7cc0
movl %eax, -0x288(%rbp)
jmp 0xc142
movl -0x288(%rbp), %eax
movl %eax, -0x1c4(%rbp)
jmp 0xc15a
movl $0x2006, -0x1c4(%rbp)   # imm = 0x2006
jmp 0xc15c
movq -0x30(%rbp), %rdi
leaq 0x644d(%rip), %rsi      # 0x125b4
callq 0x30d0
cmpl $0x0, %eax
jne 0xc1a8
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
andl %eax, %edx
callq 0x7cc0
movl %eax, -0x28c(%rbp)
jmp 0xc19c
movl -0x28c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6874(%rip), %rsi      # 0x12a27
callq 0x30d0
cmpl $0x0, %eax
jne 0xc1f4
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
orl %eax, %edx
callq 0x7cc0
movl %eax, -0x290(%rbp)
jmp 0xc1e8
movl -0x290(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6827(%rip), %rsi      # 0x12a26
callq 0x30d0
cmpl $0x0, %eax
jne 0xc240
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
xorl %eax, %edx
callq 0x7cc0
movl %eax, -0x294(%rbp)
jmp 0xc234
movl -0x294(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x669f(%rip), %rsi      # 0x128ea
callq 0x30d0
cmpl $0x0, %eax
jne 0xc292
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
movl (%rcx), %ecx
subl %ecx, %eax
setl %al
movzbl %al, %edx
callq 0x7cc0
movl %eax, -0x298(%rbp)
jmp 0xc286
movl -0x298(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x66be(%rip), %rsi      # 0x1295b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc2e4
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
movl (%rcx), %ecx
subl %ecx, %eax
setb %al
movzbl %al, %edx
callq 0x7cc0
movl %eax, -0x29c(%rbp)
jmp 0xc2d8
movl -0x29c(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x623f(%rip), %rsi      # 0x1252e
callq 0x30d0
cmpl $0x0, %eax
jne 0xc369
movq -0x1d0(%rbp), %rax
movl (%rax), %edi
movq -0x1e8(%rbp), %rax
movl (%rax), %esi
callq 0xe590
movb %al, -0x29d(%rbp)
jmp 0xc318
movb -0x29d(%rbp), %al
testb $0x1, %al
jne 0xc35d
jmp 0xc324
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x1d0(%rbp), %rax
movl (%rax), %edx
movq -0x1e8(%rbp), %rax
movl (%rax), %eax
addl %eax, %edx
callq 0x7cc0
movl %eax, -0x2a4(%rbp)
jmp 0xc34f
movl -0x2a4(%rbp), %eax
movl %eax, -0x1c4(%rbp)
jmp 0xc367
movl $0x2006, -0x1c4(%rbp)   # imm = 0x2006
jmp 0xc369
movq -0x30(%rbp), %rdi
leaq 0x64a5(%rip), %rsi      # 0x12819
callq 0x30d0
cmpl $0x0, %eax
jne 0xc3a7
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x20(%rbp), %rax
movl (%rax), %edx
callq 0x7cc0
movl %eax, -0x2a8(%rbp)
jmp 0xc39b
movl -0x2a8(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6489(%rip), %rsi      # 0x1283b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc3d5
movq -0x1d0(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x6427(%rip), %rsi      # 0x12807
callq 0x30d0
cmpl $0x0, %eax
jne 0xc413
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq -0x18(%rbp), %rax
movl (%rax), %edx
callq 0x7cc0
movl %eax, -0x2ac(%rbp)
jmp 0xc407
movl -0x2ac(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x640d(%rip), %rsi      # 0x1282b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc441
movq -0x1d0(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x63ff(%rip), %rsi      # 0x1284b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc4b3
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
movl (%rcx), %ecx
imulq %rcx, %rax
movq %rax, -0x200(%rbp)
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq -0x200(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq -0x200(%rbp), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x639b(%rip), %rsi      # 0x12859
callq 0x30d0
cmpl $0x0, %eax
jne 0xc51e
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
movl (%rcx), %ecx
imulq %rcx, %rax
movq %rax, -0x208(%rbp)
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq -0x208(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x208(%rbp), %rax
shrq $0x20, %rax
movl %eax, %ecx
andl $-0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x1c4(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x61d9(%rip), %rsi      # 0x12702
callq 0x30d0
cmpl $0x0, %eax
jne 0xc58b
movq -0x1e8(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc57f
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
cltd
idivl (%rcx)
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
cltd
idivl (%rcx)
movq -0x18(%rbp), %rax
movl %edx, (%rax)
movl $0x0, -0x1c4(%rbp)
jmp 0xc589
movl $0x2005, -0x1c4(%rbp)   # imm = 0x2005
jmp 0xc58b
movq -0x30(%rbp), %rdi
leaq 0x6177(%rip), %rsi      # 0x1270d
callq 0x30d0
cmpl $0x0, %eax
jne 0xc5fa
movq -0x1e8(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc5ee
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
xorl %edx, %edx
divl (%rcx)
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x1d0(%rbp), %rax
movl (%rax), %eax
movq -0x1e8(%rbp), %rcx
xorl %edx, %edx
divl (%rcx)
movq -0x18(%rbp), %rax
movl %edx, (%rax)
movl $0x0, -0x1c4(%rbp)
jmp 0xc5f8
movl $0x2005, -0x1c4(%rbp)   # imm = 0x2005
jmp 0xc5fa
movq -0x30(%rbp), %rdi
leaq 0x6152(%rip), %rsi      # 0x12757
callq 0x30d0
cmpl $0x0, %eax
jne 0xc634
movq 0x10(%rbp), %rax
movl (%rax), %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x1d0(%rbp), %rax
movl (%rax), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x2000, -0x1c4(%rbp)   # imm = 0x2000
movq -0x30(%rbp), %rdi
leaq 0x60fc(%rip), %rsi      # 0x1273b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc688
movq -0x10(%rbp), %rdi
movl -0x1ec(%rbp), %esi
movq 0x18(%rbp), %rax
movl (%rax), %edx
addl $0x8, %edx
callq 0x7cc0
jmp 0xc663
movq 0x10(%rbp), %rax
movl (%rax), %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x1d0(%rbp), %rax
movl (%rax), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x2000, -0x1c4(%rbp)   # imm = 0x2000
cmpl $0x0, -0x1c4(%rbp)
je 0xc6a1
cmpl $0x2000, -0x1c4(%rbp)   # imm = 0x2000
jne 0xcdf8
movq -0x30(%rbp), %rdi
leaq 0x617f(%rip), %rsi      # 0x1282b
callq 0x30d0
cmpl $0x0, %eax
je 0xc6e0
movq -0x30(%rbp), %rdi
leaq 0x617a(%rip), %rsi      # 0x1283b
callq 0x30d0
cmpl $0x0, %eax
je 0xc6e0
movq -0x30(%rbp), %rdi
leaq 0x6081(%rip), %rsi      # 0x12757
callq 0x30d0
cmpl $0x0, %eax
jne 0xc748
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x2b8(%rbp)
jmp 0xc6f9
movq -0x2b8(%rbp), %rdi
leaq 0x659c(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x2c0(%rbp)
jmp 0xc715
movq -0x2c0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x2c8(%rbp)
jmp 0xc731
movq -0x2c8(%rbp), %rdi
leaq 0x6395(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xc746
jmp 0xc748
movq -0x30(%rbp), %rdi
leaq 0x5fe8(%rip), %rsi      # 0x1273b
callq 0x30d0
cmpl $0x0, %eax
jne 0xc801
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x2d0(%rbp)
jmp 0xc77a
movq -0x2d0(%rbp), %rdi
leaq 0x651b(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x2d8(%rbp)
jmp 0xc796
movq -0x2d8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x2e0(%rbp)
jmp 0xc7b2
movq -0x2e0(%rbp), %rdi
leaq 0x64e0(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x2e8(%rbp)
jmp 0xc7ce
movq -0x2e8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x2f0(%rbp)
jmp 0xc7ea
movq -0x2f0(%rbp), %rdi
leaq 0x62dc(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xc7ff
jmp 0xc801
movq -0x30(%rbp), %rdi
leaq 0x5ffb(%rip), %rsi      # 0x12807
callq 0x30d0
cmpl $0x0, %eax
je 0xc82b
movq -0x30(%rbp), %rdi
leaq 0x5ff8(%rip), %rsi      # 0x12819
callq 0x30d0
cmpl $0x0, %eax
jne 0xc893
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x2f8(%rbp)
jmp 0xc844
movq -0x2f8(%rbp), %rdi
leaq 0x6451(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x300(%rbp)
jmp 0xc860
movq -0x300(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x308(%rbp)
jmp 0xc87c
movq -0x308(%rbp), %rdi
leaq 0x624a(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xc891
jmp 0xc893
movq -0x30(%rbp), %rdi
leaq 0x6014(%rip), %rsi      # 0x128b2
callq 0x30d0
cmpl $0x0, %eax
je 0xc8d6
movq -0x30(%rbp), %rdi
leaq 0x6107(%rip), %rsi      # 0x129ba
callq 0x30d0
cmpl $0x0, %eax
je 0xc8d6
movq -0x30(%rbp), %rdi
leaq 0x60b2(%rip), %rsi      # 0x1297a
callq 0x30d0
cmpl $0x0, %eax
jne 0xc992
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x310(%rbp)
jmp 0xc8ef
movq -0x310(%rbp), %rdi
leaq 0x63a6(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x318(%rbp)
jmp 0xc90b
movq -0x318(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x320(%rbp)
jmp 0xc927
movq -0x320(%rbp), %rdi
leaq 0x636b(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x328(%rbp)
jmp 0xc943
movq -0x328(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3390
movq %rax, -0x330(%rbp)
jmp 0xc95f
movq -0x330(%rbp), %rdi
leaq 0x633a(%rip), %rsi      # 0x12ca7
callq 0x3260
movq %rax, -0x338(%rbp)
jmp 0xc97b
movq -0x338(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x3390
jmp 0xc990
jmp 0xc992
movq -0x30(%rbp), %rdi
leaq 0x5f2c(%rip), %rsi      # 0x128c9
callq 0x30d0
cmpl $0x0, %eax
je 0xc9d5
movq -0x30(%rbp), %rdi
leaq 0x5fe3(%rip), %rsi      # 0x12995
callq 0x30d0
cmpl $0x0, %eax
je 0xc9d5
movq -0x30(%rbp), %rdi
leaq 0x600b(%rip), %rsi      # 0x129d2
callq 0x30d0
cmpl $0x0, %eax
jne 0xcaad
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x340(%rbp)
jmp 0xc9ee
movq -0x340(%rbp), %rdi
leaq 0x62a7(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x348(%rbp)
jmp 0xca0a
movq -0x348(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x350(%rbp)
jmp 0xca26
movq -0x350(%rbp), %rdi
leaq 0x626c(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x358(%rbp)
jmp 0xca42
movq -0x358(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3390
movq %rax, -0x360(%rbp)
jmp 0xca5e
movq -0x360(%rbp), %rdi
leaq 0x6234(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x368(%rbp)
jmp 0xca7a
movq -0x368(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x370(%rbp)
jmp 0xca96
movq -0x370(%rbp), %rdi
leaq 0x6030(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xcaab
jmp 0xcaad
movq -0x30(%rbp), %rdi
leaq 0x5e32(%rip), %rsi      # 0x128ea
callq 0x30d0
cmpl $0x0, %eax
je 0xcadb
movq -0x30(%rbp), %rdi
leaq 0x5e8e(%rip), %rsi      # 0x1295b
callq 0x30d0
cmpl $0x0, %eax
jne 0xcbb3
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x378(%rbp)
jmp 0xcaf4
movq -0x378(%rbp), %rdi
leaq 0x61a1(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x380(%rbp)
jmp 0xcb10
movq -0x380(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x388(%rbp)
jmp 0xcb2c
movq -0x388(%rbp), %rdi
leaq 0x6166(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x390(%rbp)
jmp 0xcb48
movq -0x390(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x398(%rbp)
jmp 0xcb64
movq -0x398(%rbp), %rdi
leaq 0x612e(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x3a0(%rbp)
jmp 0xcb80
movq -0x3a0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3390
movq %rax, -0x3a8(%rbp)
jmp 0xcb9c
movq -0x3a8(%rbp), %rdi
leaq 0x5f2a(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xcbb1
jmp 0xcbb3
movq -0x30(%rbp), %rdi
leaq 0x5c8d(%rip), %rsi      # 0x1284b
callq 0x30d0
cmpl $0x0, %eax
je 0xcc0b
movq -0x30(%rbp), %rdi
leaq 0x5c86(%rip), %rsi      # 0x12859
callq 0x30d0
cmpl $0x0, %eax
je 0xcc0b
movq -0x30(%rbp), %rdi
leaq 0x5b1a(%rip), %rsi      # 0x12702
callq 0x30d0
cmpl $0x0, %eax
je 0xcc0b
movq -0x30(%rbp), %rdi
leaq 0x5b10(%rip), %rsi      # 0x1270d
callq 0x30d0
cmpl $0x0, %eax
jne 0xccab
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x3b0(%rbp)
jmp 0xcc24
movq -0x3b0(%rbp), %rdi
leaq 0x6071(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x3b8(%rbp)
jmp 0xcc40
movq -0x3b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x3c0(%rbp)
jmp 0xcc5c
movq -0x3c0(%rbp), %rdi
leaq 0x6036(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x3c8(%rbp)
jmp 0xcc78
movq -0x3c8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3390
movq %rax, -0x3d0(%rbp)
jmp 0xcc94
movq -0x3d0(%rbp), %rdi
leaq 0x5e32(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xcca9
jmp 0xccab
leaq -0x228(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3250
jmp 0xccc0
leaq -0x228(%rbp), %rdi
callq 0x3420
movb %al, -0x3d1(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x3170
movb -0x3d1(%rbp), %al
testb $0x1, %al
jne 0xcced
jmp 0xcdc5
leaq -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3240
movq %rax, -0x3e0(%rbp)
jmp 0xcd06
movq -0x3e0(%rbp), %rdi
leaq 0x5f8f(%rip), %rsi      # 0x12ca3
callq 0x3260
movq %rax, -0x3e8(%rbp)
jmp 0xcd22
movq -0x3e8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x3390
movq %rax, -0x3f0(%rbp)
jmp 0xcd3e
movq -0x3f0(%rbp), %rdi
leaq 0x5f54(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x3f8(%rbp)
jmp 0xcd5a
movq -0x3f8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3390
movq %rax, -0x400(%rbp)
jmp 0xcd76
movq -0x400(%rbp), %rdi
leaq 0x5f1c(%rip), %rsi      # 0x12ca0
callq 0x3260
movq %rax, -0x408(%rbp)
jmp 0xcd92
movq -0x408(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x3390
movq %rax, -0x410(%rbp)
jmp 0xcdae
movq -0x410(%rbp), %rdi
leaq 0x5d18(%rip), %rsi      # 0x12ad4
callq 0x3260
jmp 0xcdc3
jmp 0xcdc5
leaq -0x248(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3250
jmp 0xcdda
movq -0x38(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3330
leaq -0x248(%rbp), %rdi
callq 0x3170
jmp 0xce0c
movq -0x38(%rbp), %rdi
leaq 0x5ea9(%rip), %rsi      # 0x12cac
callq 0x33a0
jmp 0xce0a
jmp 0xce0c
movq -0x1d0(%rbp), %rax
movq %rax, -0x418(%rbp)
cmpq $0x0, %rax
je 0xce31
movq -0x418(%rbp), %rdi
movl $0x4, %esi
callq 0x3280
movq -0x1e8(%rbp), %rax
movq %rax, -0x420(%rbp)
cmpq $0x0, %rax
je 0xce56
movq -0x420(%rbp), %rdi
movl $0x4, %esi
callq 0x3280
movl -0x1c4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x1f4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31d0
movl -0x4(%rbp), %eax
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
movq -0x1d8(%rbp), %rdi
callq 0x3440
nopl (%rax)