// File: /workspace/github_c_makefile_star2_O3/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 0x44021
movq %rbx, %rdi
callq 0x43b00
movq %r15, %rdi
callq 0x43b00
movl 0x8(%rbx), %ecx
movl 0x8(%r15), %eax
movl %eax, %edx
orl %ecx, %edx
testb $0x4, %dl
jne 0x44045
movq (%r15), %rax
addq %rax, (%rbx)
andl $0xfffffe90, %ecx       # imm = 0xFFFFFE90
orl $0x2, %ecx
movl %ecx, 0x8(%rbx)
jmp 0x44261
testl %edx, %edx
je 0x440e0
testb $0x40, %al
jne 0x4403d
movq %rbx, %rdi
callq 0x43bf7
testl %eax, %eax
jne 0x4410b
movq (%rbx), %r14
jmp 0x4413b
testb $0x4, %cl
jne 0x44056
movq %rbx, %rdi
callq 0x43a31
movl 0x8(%r15), %eax
testb $0x4, %al
jne 0x44062
movq %r15, %rdi
callq 0x43a31
movsd (%rbx), %xmm0
addsd (%r15), %xmm0
movsd %xmm0, (%rbx)
movl $0xfffffe90, %ecx       # imm = 0xFFFFFE90
andl 0x8(%rbx), %ecx
orl $0x4, %ecx
movapd 0x2f59e(%rip), %xmm1    # 0x73620
andpd %xmm0, %xmm1
ucomisd 0x2f56a(%rip), %xmm1    # 0x735f8
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 0x44261
movq %rax, (%rbx)
movl $0x2, 0x8(%rbx)
jmp 0x44261
movq 0x10(%rbx), %rdi
callq 0x3ee3d
testq %rax, %rax
je 0x4410b
movq %rax, %r14
movl 0x8(%rbx), %eax
testb $0x40, %al
jne 0x44130
testb $0x20, %al
jne 0x4413b
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3ef1d
jmp 0x4413b
movq 0x10(%rbx), %rdi
leaq 0x30461(%rip), %rcx     # 0x74577
xorl %esi, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40afa
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x44b13
movl 0x8(%r15), %eax
testb $0x40, %al
jne 0x4415d
testb $0x20, %al
jne 0x44240
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x3ef1d
jmp 0x44240
movq (%r15), %r15
cmpq %r15, %r14
je 0x44240
cmpl $0x0, 0x2c(%r15)
je 0x44240
leaq 0x10(%r15), %r12
xorl %r13d, %r13d
movq (%r12), %r12
cmpl $0x2, 0x8(%r12)
jne 0x441e1
movq 0x18(%r12), %rsi
movl 0x20(%r12), %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3f1b7
testl %eax, %eax
je 0x4422f
movq (%r12), %rcx
movl 0x38(%r12), %eax
movq (%rcx), %rdx
cmpl %eax, 0x218(%rdx)
jbe 0x4422f
movq 0x210(%rdx), %rcx
testq %rcx, %rcx
je 0x4422f
imull 0x220(%rdx), %eax
addq %rax, %rcx
movq 0x18(%r12), %rsi
movl 0x20(%r12), %edx
movq %r14, %rdi
callq 0x3f257
jmp 0x4422b
movq 0x10(%r12), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3f43c
testl %eax, %eax
je 0x4422f
movq (%r12), %rcx
movl 0x38(%r12), %eax
movq (%rcx), %rcx
cmpl %eax, 0x218(%rcx)
jbe 0x4422f
movq 0x210(%rcx), %rdx
testq %rdx, %rdx
je 0x4422f
imull 0x220(%rcx), %eax
addq %rax, %rdx
movq 0x10(%r12), %rsi
movq %r14, %rdi
callq 0x3f4a6
testl %eax, %eax
jne 0x44240
addq $0x48, %r12
incl %r13d
cmpl 0x2c(%r15), %r13d
jb 0x4417b
movl 0x8(%rbx), %eax
testb $0x1, %al
je 0x44253
leaq 0x18(%rbx), %rdi
callq 0x317be
movl 0x8(%rbx), %eax
movq %r14, (%rbx)
andl $0xfffffe90, %eax       # imm = 0xFFFFFE90
orl $0x40, %eax
movl %eax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq