// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9MemObjAdd
JX9_PRIVATE sxi32 jx9MemObjAdd(jx9_value *pObj1, jx9_value *pObj2, int bAddStore)
{
	if( ((pObj1->iFlags|pObj2->iFlags) & MEMOBJ_HASHMAP) == 0 ){
			/* Arithemtic operation */
			jx9MemObjToNumeric(pObj1);
			jx9MemObjToNumeric(pObj2);
			if( (pObj1->iFlags|pObj2->iFlags) & MEMOBJ_REAL ){
				/* Floating point arithmetic */
				jx9_real a, b;
				if( (pObj1->iFlags & MEMOBJ_REAL) == 0 ){
					jx9MemObjToReal(pObj1);
				}
				if( (pObj2->iFlags & MEMOBJ_REAL) == 0 ){
					jx9MemObjToReal(pObj2);
				}
				a = pObj1->x.rVal;
				b = pObj2->x.rVal;
				pObj1->x.rVal = a+b;
				MemObjSetType(pObj1, MEMOBJ_REAL);
				/* Try to get an integer representation also */
				MemObjTryIntger(&(*pObj1));
			}else{
				/* Integer arithmetic */
				sxi64 a, b;
				a = pObj1->x.iVal;
				b = pObj2->x.iVal;
				pObj1->x.iVal = a+b;
				MemObjSetType(pObj1, MEMOBJ_INT);
			}
	}else{
		if( (pObj1->iFlags|pObj2->iFlags) & MEMOBJ_HASHMAP ){
			jx9_hashmap *pMap;
			sxi32 rc;
			if( bAddStore ){
				/* Do not duplicate the hashmap, use the left one since its an add&store operation.
				 */
				if( (pObj1->iFlags & MEMOBJ_HASHMAP) == 0 ){				
					/* Force a hashmap cast */
					rc = jx9MemObjToHashmap(pObj1);
					if( rc != SXRET_OK ){
						jx9VmThrowError(pObj1->pVm, 0, JX9_CTX_ERR, "JX9 is running out of memory while creating array");
						return rc;
					}
				}
				/* Point to the structure that describe the hashmap */
				pMap = (jx9_hashmap *)pObj1->x.pOther;
			}else{
				/* Create a new hashmap */
				pMap = jx9NewHashmap(pObj1->pVm, 0, 0);
				if( pMap == 0){
					jx9VmThrowError(pObj1->pVm, 0, JX9_CTX_ERR, "JX9 is running out of memory while creating array");
					return SXERR_MEM;
				}
			}
			if( !bAddStore ){
				if(pObj1->iFlags & MEMOBJ_HASHMAP ){
					/* Perform a hashmap duplication */
					jx9HashmapDup((jx9_hashmap *)pObj1->x.pOther, pMap);
				}else{
					if((pObj1->iFlags & MEMOBJ_NULL) == 0 ){
						/* Simple insertion */
						jx9HashmapInsert(pMap, 0, pObj1);
					}
				}
			}
			/* Perform the union */
			if(pObj2->iFlags & MEMOBJ_HASHMAP ){
				jx9HashmapUnion(pMap, (jx9_hashmap *)pObj2->x.pOther);
			}else{
				if((pObj2->iFlags & MEMOBJ_NULL) == 0 ){
					/* Simple insertion */
					jx9HashmapInsert(pMap, 0, pObj2);
				}
			}
			/* Reflect the change */
			if( pObj1->iFlags & MEMOBJ_STRING ){
				SyBlobRelease(&pObj1->sBlob);
			}
			pObj1->x.pOther = pMap;
			MemObjSetType(pObj1, MEMOBJ_HASHMAP);
		}
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0x8(%rsi), %ecx
orl %eax, %ecx
testb $0x40, %cl
jne 0x44e59
movq %rbx, %rdi
callq 0x4494c
movq %r15, %rdi
callq 0x4494c
movl 0x8(%rbx), %eax
movl 0x8(%r15), %ecx
orl %eax, %ecx
testb $0x4, %cl
jne 0x44e80
movq (%r15), %rcx
addq %rcx, (%rbx)
andl $0xfffffe90, %eax       # imm = 0xFFFFFE90
orl $0x2, %eax
jmp 0x4509e
movl %edx, %r12d
testl %edx, %edx
je 0x44f17
testb $0x40, %al
jne 0x44e78
movq %rbx, %rdi
callq 0x44a28
testl %eax, %eax
jne 0x44f47
movq (%rbx), %r14
jmp 0x44f28
testb $0x4, %al
jne 0x44e8c
movq %rbx, %rdi
callq 0x44891
testb $0x4, 0x8(%r15)
jne 0x44e9b
movq %r15, %rdi
callq 0x44891
movsd (%rbx), %xmm0
addsd (%r15), %xmm0
movsd %xmm0, (%rbx)
movl $0xfffffe90, %ecx       # imm = 0xFFFFFE90
andl 0x8(%rbx), %ecx
orl $0x4, %ecx
movapd 0x30705(%rip), %xmm1    # 0x755c0
andpd %xmm0, %xmm1
ucomisd 0x30789(%rip), %xmm1    # 0x75650
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
cvttsd2si %xmm0, %rax
leaq 0x1(%rdx), %rsi
cmovaq %rsi, %rax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm1, %xmm0
movl %ecx, 0x8(%rbx)
setp %cl
setne %sil
orb %cl, %sil
addq %rax, %rdx
cmpq $-0x2, %rdx
setae %cl
orb %sil, %cl
jne 0x450a1
movq %rax, (%rbx)
movl $0x2, %eax
jmp 0x4509e
movq 0x10(%rbx), %rdi
callq 0x3f840
movq %rax, %r14
testq %rax, %rax
je 0x44f47
testl %r12d, %r12d
jne 0x44f7a
movl 0x8(%rbx), %eax
testb $0x40, %al
jne 0x44f6f
testb $0x20, %al
jne 0x44f7a
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3f924
jmp 0x44f7a
addq $0x10, %rbx
movq (%rbx), %rdi
leaq 0x3161a(%rip), %rcx     # 0x7656f
xorl %esi, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4153c
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x45959
movl 0x8(%r15), %eax
testb $0x40, %al
jne 0x44f9c
testb $0x20, %al
jne 0x45081
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x3f924
jmp 0x45081
movq (%r15), %r15
cmpq %r15, %r14
je 0x45081
cmpl $0x0, 0x2c(%r15)
je 0x45081
leaq 0x10(%r15), %r12
xorl %r13d, %r13d
movq (%r12), %r12
cmpl $0x2, 0x8(%r12)
jne 0x45006
movq 0x18(%r12), %rsi
movl 0x20(%r12), %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3fba1
testl %eax, %eax
je 0x45070
movq (%r12), %rax
movq (%rax), %rax
movl 0x38(%r12), %ecx
cmpl %ecx, 0x218(%rax)
jbe 0x4503d
imull 0x220(%rax), %ecx
addq 0x210(%rax), %rcx
jmp 0x4503f
movq 0x10(%r12), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3fe39
testl %eax, %eax
je 0x45070
movq (%r12), %rax
movq (%rax), %rax
movl 0x38(%r12), %edx
cmpl %edx, 0x218(%rax)
jbe 0x45058
imull 0x220(%rax), %edx
addq 0x210(%rax), %rdx
jmp 0x4505a
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x45070
movq 0x18(%r12), %rsi
movl 0x20(%r12), %edx
movq %r14, %rdi
callq 0x3fc41
jmp 0x4506c
xorl %edx, %edx
testq %rdx, %rdx
je 0x45070
movq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x3fea3
testl %eax, %eax
jne 0x45081
addq $0x48, %r12
incl %r13d
cmpl 0x2c(%r15), %r13d
jb 0x44fba
testb $0x1, 0x8(%rbx)
je 0x45090
leaq 0x18(%rbx), %rdi
callq 0x31d8f
movq %r14, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x40, %eax
movl %eax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq