// File: /workspace/github_cpp_makefile_star2_O3/sthapliyal37[P]Microprocessor_8085_Updated/Essential.cpp
// Function: hexAdd(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*, bool)
string hexAdd(string arg1,string arg2,bool* flag,bool carry){
	
	string resultant = "";
	int variable;
	int value1[5] = {0,0};
	int value2[5] = {0,0};
	int tempAnswer[2];
	hexToDecimal(arg1,value1);
	hexToDecimal(arg2,value2);
	
	tempAnswer[1] = value1[1] + value2[1];
	if(tempAnswer[1]>=16){
	
		tempAnswer[1] = tempAnswer[1]%16;
		value1[0]++;
		flag[4] = true;
		}
	tempAnswer[0] = value1[0] + value2[0];
	if(tempAnswer[0]>=16){
	
		tempAnswer[0] = tempAnswer[0]%16;
		if(carry == true)
			flag[0] = true;
	}
	
	variable = tempAnswer[0]*16 + tempAnswer[1];
	bitset<8> dataInBinary(variable);
	int parity = dataInBinary.count();
	if(parity%2 == 0 && parity!=0)
		flag[2] = true;
	else
		flag[2] = false;
	flag[7] = dataInBinary[7];
	if(parity == 0)
		flag[6] = true;
	
	for(int i = 1;i>=0;--i){
		
		if(tempAnswer[i]>=0 && tempAnswer[i]<=9)
			resultant = char('0' + tempAnswer[i]) + resultant;
		else if(tempAnswer[i]>=10 && tempAnswer[i]<=15)
			resultant = (char)('A'+(tempAnswer[i] - 10)) + resultant;
		}
	//cout<<resultant<<endl;
	return resultant;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %r8d, -0x34(%rbp)
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, -0x40(%rbp)
movq %rax, (%rdi)
leaq 0x9d3d(%rip), %rdx      # 0xe202
movq %rdx, %rsi
callq 0x328a
xorl %eax, %eax
movl %eax, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movl %eax, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
leaq -0xd0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x31ec
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rax
testl %eax, %eax
jle 0x453d
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movsbl (%rdi,%rcx), %edx
leal -0x30(%rdx), %esi
leal -0x37(%rdx), %r8d
addl $-0x30, %edx
cmpb $0xa, %sil
cmovael %r8d, %edx
movl %edx, -0x80(%rbp,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x451b
cmpq %r15, %rdi
je 0x4551
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2210
leaq -0xb0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x31ec
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rax
testl %eax, %eax
jle 0x45af
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movsbl (%rdi,%rcx), %edx
leal -0x30(%rdx), %esi
leal -0x37(%rdx), %r8d
addl $-0x30, %edx
cmpb $0xa, %sil
cmovael %r8d, %edx
movl %edx, -0x60(%rbp,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x458d
cmpq %r15, %rdi
je 0x45c3
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2210
movl -0x5c(%rbp), %eax
addl -0x7c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x80(%rbp), %ecx
cmpl $0x10, %eax
jl 0x45e1
andl $0xf, %eax
movl %eax, -0x2c(%rbp)
incl %ecx
movb $0x1, 0x4(%r14)
addl -0x60(%rbp), %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x10, %ecx
jl 0x45fc
andl $0xf, %ecx
movl %ecx, -0x30(%rbp)
cmpb $0x0, -0x34(%rbp)
je 0x45fc
movb $0x1, (%r14)
shll $0x4, %ecx
addl %eax, %ecx
movzbl %cl, %eax
xorl %edx, %edx
testb %al, %al
setnp %sil
cmpl $0x7f, %eax
seta %cl
testl %eax, %eax
je 0x4628
movb %sil, %dl
testl %edx, %edx
jne 0x4628
movb $0x1, 0x2(%r14)
movb %cl, 0x7(%r14)
jmp 0x463a
movb $0x0, 0x2(%r14)
movb %cl, 0x7(%r14)
testl %eax, %eax
jne 0x463a
movb $0x1, 0x6(%r14)
leaq -0x90(%rbp), %r15
movl $0x1, %r12d
leaq -0xa0(%rbp), %r14
movl -0x30(%rbp,%r12,4), %eax
cmpl $0x9, %eax
ja 0x466a
orb $0x30, %al
movsbl %al, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4bc8
jmp 0x4682
leal -0xa(%rax), %ecx
cmpl $0x5, %ecx
ja 0x46a8
addb $0x37, %al
movsbl %al, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4bc8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2270
movq -0xa0(%rbp), %rdi
cmpq %r15, %rdi
je 0x46a8
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2210
addq $-0x1, %r12
jb 0x464e
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x46c7
jmp 0x46c7
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x40(%rbp), %rdi
je 0x46e2
movq -0x40(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2320