// File: sthapliyal37[P]Microprocessor_8085_Updated/Branch.cpp
// Function: JC(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*)
string JC(string instruction,string pc,string* registers,bool* flag){
	if(flag[0] == true)
		return instruction;
	else{
		string resultant = "";
		int value16bit[4];
		int returnValue[] = {0,0,0,3};
		int carry = 0;
		hexToDecimal(pc,value16bit);	  
		for(int i = 3;i>=0;i--){
					
			int value = value16bit[i] + returnValue[i] + carry;
			carry = value / 16;
			value = value % 16;
			if(value>=0 && value<=9)
				resultant = (char)('0'+value) + resultant;
			else{
				resultant = (char)('A'+(value-10)) + resultant;
			}
		}
		if(validityAddress(resultant))
			return resultant;
		
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdx, -0x118(%rbp)
movq %rsi, -0x110(%rbp)
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x28(%rbp), %rax
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x102c6
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdi
callq 0x3170
jmp 0x10543
movb $0x0, -0x29(%rbp)
leaq -0x2a(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x3440
movq -0x108(%rbp), %rdi
movq -0x120(%rbp), %rdx
leaq 0x4f13(%rip), %rsi      # 0x15202
callq 0x50d0
jmp 0x102f6
leaq -0x2a(%rbp), %rdi
callq 0x32f0
movq -0x118(%rbp), %rsi
movaps 0x4f33(%rip), %xmm0     # 0x15240
movaps %xmm0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3110
jmp 0x10326
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7a50
jmp 0x10338
leaq -0x88(%rbp), %rdi
callq 0x3190
movl $0x3, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
jl 0x1049c
movslq -0x8c(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
movslq -0x8c(%rbp), %rcx
addl -0x60(%rbp,%rcx,4), %eax
addl -0x64(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, -0x64(%rbp)
movl -0x90(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %edx, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
jl 0x10446
cmpl $0x9, -0x90(%rbp)
jg 0x10446
movq -0x108(%rbp), %rdx
movl -0x90(%rbp), %eax
addl $0x30, %eax
movsbl %al, %esi
leaq -0xb0(%rbp), %rdi
callq 0x84f0
jmp 0x103da
movq -0x108(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3330
leaq -0xb0(%rbp), %rdi
callq 0x3190
jmp 0x10486
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2a(%rbp), %rdi
callq 0x32f0
jmp 0x10553
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x10533
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3190
jmp 0x10533
movq -0x108(%rbp), %rdx
movl -0x90(%rbp), %eax
addl $0x37, %eax
movsbl %al, %esi
leaq -0xd0(%rbp), %rdi
callq 0x84f0
jmp 0x10467
movq -0x108(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3330
leaq -0xd0(%rbp), %rdi
callq 0x3190
jmp 0x10488
movl -0x8c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x1034e
movq -0x108(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x3110
jmp 0x104b1
leaq -0xf0(%rbp), %rdi
callq 0x3db0
movb %al, -0x121(%rbp)
jmp 0x104c5
leaq -0xf0(%rbp), %rdi
callq 0x3190
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x104dd
jmp 0x10507
movb $0x1, -0x29(%rbp)
movl $0x1, -0xf4(%rbp)
jmp 0x10511
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3190
jmp 0x10533
movl $0x0, -0xf4(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x10523
movq -0x108(%rbp), %rdi
callq 0x3190
movl -0xf4(%rbp), %eax
testl %eax, %eax
je 0x10531
jmp 0x1052f
jmp 0x10543
jmp 0x10541
movq -0x108(%rbp), %rdi
callq 0x3190
jmp 0x10553
ud2
movq -0x100(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3430
nopl (%rax)