// File: sthapliyal37[P]Microprocessor_8085_Updated/Essential.cpp
// Function: hexAdd16bit(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 hexAdd16bit (string arg1,string arg2,bool* flag,bool check)
{
	int l1=arg1.length();
	int l2=arg2.length();
	string hex="";
	if(l1==1&&l2==4)
	{
		int value1[4]={0,0,0,0};
		for(int i=0;i<l1;i++)
		{
			if(arg1[i]>='0'&&arg1[i]<='9')
				value1[i]=(int)(arg1[i]-'0');
			else if(arg1[i]>='A'&&arg1[i]<='Z')
				value1[i]=(int)(arg1[i]-'A');
		}
		int i=l1-1;
		value1[l1-1]++;
		while(value1[i]>=16)
		{
			value1[i]=value1[i]%16;
			if(i==0)
			{
				flag[0]=true;
				break;
			}
			else
				value1[--i]++;
		}
		int value=value1[0]*16*16*16+value1[1]*16*16+value1[2]*16+value1[3];
		bitset<16>str(value);
		flag[7]=str[15];
		int parity=str.count();
		if(parity==0)
			flag[6]=true;
		else if(parity%2==0)
			flag[2]=true;
		else if(parity%2==1)
			flag[2]=false;
		for(int i=0;i<l1;i++)
		{
			if(value1[i]>=0&&value1[i]<=9)
				hex+=(char)value1[i];
			else if(value1[i]>=10&&value1[i]<=15)
				hex+=(char)('A'+(value1[i]-10));
		}
	}
	return hex;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdx, -0x98(%rbp)
movq %rsi, -0xa8(%rbp)
movq %rdi, %rsi
movq -0xa8(%rbp), %rdi
movq %rsi, -0x90(%rbp)
movb %r8b, %al
movq %rsi, %r8
movq %r8, -0xa0(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
callq 0x33b0
movq -0x98(%rbp), %rdi
movl %eax, -0x28(%rbp)
callq 0x33b0
movl %eax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
leaq -0x2e(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x3440
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0xdec6(%rip), %rsi      # 0x15202
callq 0x50d0
jmp 0x7343
leaq -0x2e(%rbp), %rdi
callq 0x32f0
cmpl $0x1, -0x28(%rbp)
jne 0x7673
cmpl $0x4, -0x2c(%rbp)
jne 0x7673
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3150
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x74d1
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xb0(%rbp)
jmp 0x739c
movq -0xb0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x7441
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xb8(%rbp)
jmp 0x73c8
movq -0xb8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0x7441
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xc0(%rbp)
jmp 0x73f0
movq -0xc0(%rbp), %rax
movsbl (%rax), %ecx
subl $0x30, %ecx
movslq -0x54(%rbp), %rax
movl %ecx, -0x50(%rbp,%rax,4)
jmp 0x74c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x32f0
jmp 0x7699
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x3190
jmp 0x7699
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xc8(%rbp)
jmp 0x745a
movq -0xc8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0x74bf
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xd0(%rbp)
jmp 0x7482
movq -0xd0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5a, %eax
jg 0x74bf
movq -0xa8(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x34a0
movq %rax, -0xd8(%rbp)
jmp 0x74aa
movq -0xd8(%rbp), %rax
movsbl (%rax), %ecx
subl $0x41, %ecx
movslq -0x54(%rbp), %rax
movl %ecx, -0x50(%rbp,%rax,4)
jmp 0x74c1
jmp 0x74c3
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x7377
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x28(%rbp), %eax
subl $0x1, %eax
cltq
movl -0x50(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
movslq -0x58(%rbp), %rax
cmpl $0x10, -0x50(%rbp,%rax,4)
jl 0x7537
movslq -0x58(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movslq -0x58(%rbp), %rax
movl %edx, -0x50(%rbp,%rax,4)
cmpl $0x0, -0x58(%rbp)
jne 0x751f
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
jmp 0x7537
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
cltq
movl -0x50(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
jmp 0x74ed
movl -0x50(%rbp), %eax
movl -0x4c(%rbp), %ecx
shll $0xc, %eax
shll $0x8, %ecx
addl %ecx, %eax
movl -0x48(%rbp), %ecx
shll $0x4, %ecx
addl %ecx, %eax
movl -0x44(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x5c(%rbp)
movslq -0x5c(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x82f0
movq -0xe0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movl $0xf, %edx
callq 0x8340
jmp 0x7580
leaq -0x78(%rbp), %rdi
callq 0x8380
movb %al, %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x7(%rax)
leaq -0x78(%rbp), %rdi
callq 0x83c0
leaq -0x68(%rbp), %rdi
callq 0x83d0
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jne 0x75ba
movq -0x20(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0x75f0
movl -0x7c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x75d4
movq -0x20(%rbp), %rax
movb $0x1, 0x2(%rax)
jmp 0x75ee
movl -0x7c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x75ec
movq -0x20(%rbp), %rax
movb $0x0, 0x2(%rax)
jmp 0x75ee
jmp 0x75f0
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x7671
movslq -0x80(%rbp), %rax
cmpl $0x0, -0x50(%rbp,%rax,4)
jl 0x762e
movslq -0x80(%rbp), %rax
cmpl $0x9, -0x50(%rbp,%rax,4)
jg 0x762e
movq -0x90(%rbp), %rdi
movslq -0x80(%rbp), %rax
movsbl -0x50(%rbp,%rax,4), %esi
callq 0x31a0
jmp 0x762c
jmp 0x7664
movslq -0x80(%rbp), %rax
cmpl $0xa, -0x50(%rbp,%rax,4)
jl 0x7662
movslq -0x80(%rbp), %rax
cmpl $0xf, -0x50(%rbp,%rax,4)
jg 0x7662
movq -0x90(%rbp), %rdi
movslq -0x80(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
addl $0x37, %eax
movsbl %al, %esi
callq 0x31a0
jmp 0x7660
jmp 0x7662
jmp 0x7664
jmp 0x7666
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x75f7
jmp 0x7673
movb $0x1, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0x7689
movq -0x90(%rbp), %rdi
callq 0x3190
movq -0xa0(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3430
nopw %cs:(%rax,%rax)