// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9ParseIniString
JX9_PRIVATE sxi32 jx9ParseIniString(jx9_context *pCtx, const char *zIn, sxu32 nByte, int bProcessSection)
{
	jx9_value *pCur, *pArray, *pSection, *pWorker, *pValue;
	const char *zCur, *zEnd = &zIn[nByte];
	SyHashEntry *pEntry;
	SyString sEntry;
	SyHash sHash;
	int c;
	/* Create an empty array and worker variables */
	pArray = jx9_context_new_array(pCtx);
	pWorker = jx9_context_new_scalar(pCtx);
	pValue = jx9_context_new_scalar(pCtx);
	if( pArray == 0 || pWorker == 0 || pValue == 0){
		/* Out of memory */
		jx9_context_throw_error(pCtx, JX9_CTX_ERR, "JX9 is running out of memory");
		/* Return FALSE */
		jx9_result_bool(pCtx, 0);
		return JX9_OK;
	}
	SyHashInit(&sHash, &pCtx->pVm->sAllocator, 0, 0);
	pCur = pArray;
	/* Start the parse process */
	for(;;){
		/* Ignore leading white spaces */
		while( zIn < zEnd && (unsigned char)zIn[0] < 0xc0 && SyisSpace(zIn[0])){
			zIn++;
		}
		if( zIn >= zEnd ){
			/* No more input to process */
			break;
		}
		if( zIn[0] == ';' || zIn[0] == '#' ){
			/* Comment til the end of line */
			zIn++;
			while(zIn < zEnd && zIn[0] != '\n' ){
				zIn++;
			}
			continue;
		}
		/* Reset the string cursor of the working variable */
		jx9_value_reset_string_cursor(pWorker);
		if( zIn[0] == '[' ){
			/* Section: Extract the section name */
			zIn++;
			zCur = zIn;
			while( zIn < zEnd && zIn[0] != ']' ){
				zIn++;
			}
			if( zIn > zCur && bProcessSection ){
				/* Save the section name */
				SyStringInitFromBuf(&sEntry, zCur, (int)(zIn-zCur));
				SyStringFullTrim(&sEntry);
				jx9_value_string(pWorker, sEntry.zString, (int)sEntry.nByte);
				if( sEntry.nByte > 0 ){
					/* Associate an array with the section */
					pSection = jx9_context_new_array(pCtx);
					if( pSection ){
						jx9_array_add_elem(pArray, pWorker/*Section name*/, pSection);
						pCur = pSection;
					}
				}
			}
			zIn++; /* Trailing square brackets ']' */
		}else{
			jx9_value *pOldCur;
			int is_array;
			int iLen;
			/* Properties */
			is_array = 0;
			zCur = zIn;
			iLen = 0; /* cc warning */
			pOldCur = pCur;
			while( zIn < zEnd && zIn[0] != '=' ){
				if( zIn[0] == '[' && !is_array ){
					/* Array */
					iLen = (int)(zIn-zCur);
					is_array = 1;
					if( iLen > 0 ){
						jx9_value *pvArr = 0; /* cc warning */
						/* Query the hashtable */
						SyStringInitFromBuf(&sEntry, zCur, iLen);
						SyStringFullTrim(&sEntry);
						pEntry = SyHashGet(&sHash, (const void *)sEntry.zString, sEntry.nByte);
						if( pEntry ){
							pvArr = (jx9_value *)SyHashEntryGetUserData(pEntry);
						}else{
							/* Create an empty array */
							pvArr = jx9_context_new_array(pCtx);
							if( pvArr ){
								/* Save the entry */
								SyHashInsert(&sHash, (const void *)sEntry.zString, sEntry.nByte, pvArr);
								/* Insert the entry */
								jx9_value_reset_string_cursor(pWorker);
								jx9_value_string(pWorker, sEntry.zString, (int)sEntry.nByte);
								jx9_array_add_elem(pCur, pWorker, pvArr);
								jx9_value_reset_string_cursor(pWorker);
							}
						}
						if( pvArr ){
							pCur = pvArr;
						}
					}
					while ( zIn < zEnd && zIn[0] != ']' ){
						zIn++;
					}
				}
				zIn++;
			}
			if( !is_array ){
				iLen = (int)(zIn-zCur);
			}
			/* Trim the key */
			SyStringInitFromBuf(&sEntry, zCur, iLen);
			SyStringFullTrim(&sEntry);
			if( sEntry.nByte > 0 ){
				if( !is_array ){
					/* Save the key name */
					jx9_value_string(pWorker, sEntry.zString, (int)sEntry.nByte);
				}
				/* extract key value */
				jx9_value_reset_string_cursor(pValue);
				zIn++; /* '=' */
				while( zIn < zEnd && (unsigned char)zIn[0] < 0xc0 && SyisSpace(zIn[0]) ){
					zIn++;
				}
				if( zIn < zEnd ){
					zCur = zIn;
					c = zIn[0];
					if( c == '"' || c == '\'' ){
						zIn++;
						/* Delimit the value */
						while( zIn < zEnd ){
							if ( zIn[0] == c && zIn[-1] != '\\' ){
								break;
							}
							zIn++;
						}
						if( zIn < zEnd ){
							zIn++;
						}
					}else{
						while( zIn < zEnd ){
							if( zIn[0] == '\n' ){
								if( zIn[-1] != '\\' ){
									break;
								}
							}else if( zIn[0] == ';' || zIn[0] == '#' ){
								/* Inline comments */
								break;
							}
							zIn++;
						}
					}
					/* Trim the value */
					SyStringInitFromBuf(&sEntry, zCur, (int)(zIn-zCur));
					SyStringFullTrim(&sEntry);
					if( c == '"' || c == '\'' ){
						SyStringTrimLeadingChar(&sEntry, c);
						SyStringTrimTrailingChar(&sEntry, c);
					}
					if( sEntry.nByte > 0 ){
						jx9_value_string(pValue, sEntry.zString, (int)sEntry.nByte);
					}
					/* Insert the key and it's value */
					jx9_array_add_elem(pCur, is_array ? 0 /*Automatic index assign */: pWorker, pValue);
				}
			}else{
				while( zIn < zEnd && (unsigned char)zIn[0] < 0xc0 && ( SyisSpace(zIn[0]) || zIn[0] == '=' ) ){
					zIn++;
				}
			}
			pCur = pOldCur;
		}
	}
	SyHashRelease(&sHash);
	/* Return the parse of the INI string */
	jx9_result_value(pCtx, pArray);
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %ecx, -0x74(%rbp)
movl %edx, %r13d
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
callq 0x2a2b0
movq %rax, %r15
movq %r14, %rdi
callq 0x2a26a
movq %rax, %rbx
movq %r14, %rdi
callq 0x2a26a
movq %rax, %r12
testq %r15, %r15
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
testq %r12, %r12
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x4f21e
leaq 0x170b8(%rip), %rdx     # 0x662b0
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2a0db
movq %r14, %rdi
xorl %esi, %esi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x298b2
movl %r13d, %r13d
addq -0x40(%rbp), %r13
movq %r14, -0x68(%rbp)
movq 0x60(%r14), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x3bcf0
leaq 0x18(%rbx), %rax
movq %rax, -0x60(%rbp)
movq %r12, %rax
addq $0x18, %rax
movq %rax, -0xa8(%rbp)
movq %r15, -0x90(%rbp)
movq %r15, -0x80(%rbp)
movq %rbx, -0x48(%rbp)
movq %r12, -0xa0(%rbp)
movq %r13, %r12
movq %r13, -0x58(%rbp)
movq -0x40(%rbp), %r14
movq %r14, %r15
cmpq %r12, %r15
jae 0x4f89a
movsbq (%r15), %r14
cmpq $-0x41, %r14
ja 0x4f296
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
jne 0x4f2c3
cmpb $0x3b, %r14b
je 0x4f2a5
movzbl %r14b, %eax
cmpl $0x23, %eax
jne 0x4f2c8
incq %r15
movq %r15, %rax
cmpq %r12, %rax
jae 0x4f2be
cmpb $0xa, (%rax)
movq %rax, %r15
leaq 0x1(%rax), %rax
jne 0x4f2ab
jmp 0x4f273
movq %rax, %r15
jmp 0x4f273
incq %r15
jmp 0x4f273
movq -0x60(%rbp), %rdi
callq 0x31b1e
cmpb $0x5b, (%r15)
je 0x4f771
movl $0x0, -0x38(%rbp)
movq -0x80(%rbp), %r13
movq %r15, %r14
movq $0x0, -0x50(%rbp)
cmpq %r12, %r14
jae 0x4f466
movb (%r14), %al
cmpb $0x3d, %al
je 0x4f466
cmpb $0x5b, %al
setne %al
cmpl $0x0, -0x38(%rbp)
setne %cl
orb %al, %cl
jne 0x4f45e
movq %r14, %rax
subq %r15, %rax
testl %eax, %eax
movq %rax, -0x50(%rbp)
jle 0x4f448
movq %r13, -0x70(%rbp)
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %r15, %rcx
movq %rcx, -0x30(%rbp)
movl %eax, %r12d
movq %r15, %r13
movq %r14, -0x40(%rbp)
testl %r12d, %r12d
je 0x4f36f
movsbq (%r13), %rbx
cmpq $-0x41, %rbx
ja 0x4f373
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x4f373
incq %r13
decq %r12
jmp 0x4f348
movq -0x30(%rbp), %r13
movq %r13, -0x30(%rbp)
leaq -0x1(%r13), %r14
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x4f3ab
movsbq (%r14,%r12), %rbx
cmpq $-0x41, %rbx
ja 0x4f3b0
callq 0xc190
movq (%rax), %rax
incq %r13
decq %r14
testb $0x20, 0x1(%rax,%rbx,2)
jne 0x4f37e
subl %r13d, %r12d
incl %r12d
jmp 0x4f3b3
xorl %r12d, %r12d
jmp 0x4f3b3
subl %r13d, %r12d
leaq -0xf0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl %r12d, %edx
callq 0x3ae09
testq %rax, %rax
movq -0x48(%rbp), %rbx
movq -0x40(%rbp), %r14
movq -0x70(%rbp), %r13
je 0x4f3dd
movq 0x10(%rax), %rax
jmp 0x4f43d
movq -0x68(%rbp), %rdi
callq 0x2a2b0
testq %rax, %rax
je 0x4f43b
leaq -0xf0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl %r12d, %edx
movq %rax, %rcx
movq %rax, -0x38(%rbp)
callq 0x3b67d
movq -0x60(%rbp), %rdi
callq 0x31b1e
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movl %r12d, %edx
callq 0x29588
movq %r13, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
callq 0x29c4b
movq -0x60(%rbp), %rdi
callq 0x31b1e
movq -0x38(%rbp), %rax
jmp 0x4f43d
xorl %eax, %eax
testq %rax, %rax
cmovneq %rax, %r13
movq -0x58(%rbp), %r12
cmpq %r12, %r14
jae 0x4f458
cmpb $0x5d, (%r14)
je 0x4f458
incq %r14
jmp 0x4f448
pushq $0x1
popq %rax
movl %eax, -0x38(%rbp)
incq %r14
jmp 0x4f2f1
movl %r14d, %eax
subl %r15d, %eax
cmpl $0x0, -0x38(%rbp)
movq -0x50(%rbp), %r12
cmovel %eax, %r12d
leaq (%r15,%r12), %rax
movq %rax, -0x30(%rbp)
testl %r12d, %r12d
je 0x4f4aa
movsbq (%r15), %rbx
cmpq $-0x41, %rbx
ja 0x4f4a6
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x4f4a6
incq %r15
decq %r12
jmp 0x4f480
movq %r15, -0x30(%rbp)
movq %r12, %r15
subq $0x1, %r12
jb 0x4f5c6
movq -0x30(%rbp), %rax
movsbq -0x1(%rax,%r15), %rbx
cmpq $-0x41, %rbx
ja 0x4f4d6
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
jne 0x4f4aa
movq %r13, -0x70(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x4f4f0
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl %r15d, %edx
callq 0x29588
movq -0xa8(%rbp), %rdi
callq 0x31b1e
leaq 0x1(%r14), %rax
leaq 0x3(%r14), %rcx
movl %r14d, %r8d
notl %r8d
movl %r14d, %r9d
negl %r9d
movq -0x58(%rbp), %r12
movq %rax, %rsi
movq %r14, -0x50(%rbp)
cmpq %r12, %rax
jae 0x4f6cd
movq %rcx, %r13
movl %r8d, %edx
movl %r9d, %r15d
movsbq (%rsi), %rdi
cmpq $-0x41, %rdi
movq %rdi, -0x30(%rbp)
ja 0x4f577
movq %rdx, %rbx
movq %rsi, %r14
callq 0xc190
movq %r14, %rsi
movq %rbx, %rdx
movq (%rax), %rdi
leaq 0x1(%r14), %rax
leaq 0x1(%r13), %rcx
leal -0x1(%rbx), %r8d
leal -0x1(%r15), %r9d
movq -0x50(%rbp), %r10
leaq 0x1(%r10), %r14
movq -0x30(%rbp), %r10
testb $0x20, 0x1(%rdi,%r10,2)
movq -0x30(%rbp), %rdi
jne 0x4f514
movzbl %dil, %eax
cmpl $0x22, %eax
je 0x4f588
movq %rsi, %rcx
cmpl $0x27, %eax
jne 0x4f5a5
leaq -0x1(%r13), %rax
cmpq %r12, %rax
jae 0x4f602
cmpb %dil, (%rax)
jne 0x4f59d
cmpb $0x5c, -0x2(%r13)
jne 0x4f602
incq %r13
jmp 0x4f588
incq %rcx
cmpq %r12, %rcx
jae 0x4f60c
movzbl (%rcx), %eax
cmpl $0xa, %eax
je 0x4f5be
cmpl $0x23, %eax
je 0x4f60c
cmpl $0x3b, %eax
jne 0x4f5a2
jmp 0x4f60c
cmpb $0x5c, -0x1(%rcx)
je 0x4f5a2
jmp 0x4f60c
movq -0x58(%rbp), %r12
cmpq %r12, %r14
jae 0x4f6d0
movsbq (%r14), %rbx
cmpq $-0x41, %rbx
ja 0x4f6d0
callq 0xc190
cmpb $0x3d, %bl
je 0x4f5fd
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
je 0x4f6d0
incq %r14
jmp 0x4f5ca
cmpq %r12, %rax
cmovaeq %rax, %r13
movq %r13, %rcx
movq %rcx, -0x40(%rbp)
addl %ecx, %edx
xorl %r13d, %r13d
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
xorl %r12d, %r12d
movq %rdx, -0x98(%rbp)
cmpl %r12d, %edx
je 0x4f669
movsbq (%rsi,%r12), %rbx
cmpq $-0x41, %rbx
ja 0x4f669
movq %rsi, %r14
callq 0xc190
movq %r14, %rsi
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x4f669
incq %r12
incl %r13d
incq -0x88(%rbp)
jmp 0x4f62a
addq %r12, %rsi
addq %rdx, -0x50(%rbp)
subq %rdx, %r12
xorl %r14d, %r14d
movq %r15, -0xb0(%rbp)
cmpq %r14, %r12
je 0x4f6d9
movq -0x50(%rbp), %rax
movsbq (%rax,%r14), %rbx
cmpq $-0x41, %rbx
ja 0x4f6dd
movq %rsi, %r15
callq 0xc190
movq %r15, %rsi
movq -0xb0(%rbp), %r15
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq (%rax), %rax
incl %r13d
decq %r14
testb $0x20, 0x1(%rax,%rbx,2)
jne 0x4f67d
movq -0x40(%rbp), %r14
addl %r14d, %r15d
subl %r13d, %r15d
movl %r15d, %edx
jmp 0x4f6e4
movq %rsi, %r14
movq -0x48(%rbp), %rbx
jmp 0x4f270
xorl %edx, %edx
jmp 0x4f6e0
subl %r13d, %edx
movq -0x40(%rbp), %r14
cmpb $0x27, %dil
movq -0x48(%rbp), %r13
movq -0xa0(%rbp), %rbx
movq -0x58(%rbp), %r12
movq -0x70(%rbp), %r15
movq -0x88(%rbp), %r8
je 0x4f70d
movzbl %dil, %eax
cmpl $0x22, %eax
jne 0x4f745
movl %edx, %eax
movq %rax, %rdx
testl %edx, %edx
je 0x4f723
cmpb %dil, (%rsi)
jne 0x4f723
incq %rsi
decq %rdx
jmp 0x4f712
addq %rax, %r8
pushq $0x1
popq %rax
leaq (%rdx,%rax), %rcx
cmpq $0x1, %rcx
je 0x4f751
leaq -0x1(%rax), %rcx
cmpb %dil, -0x1(%r8,%rax)
movq %rcx, %rax
je 0x4f729
addl %ecx, %edx
jmp 0x4f749
testl %edx, %edx
je 0x4f751
movq %rbx, %rdi
callq 0x29588
cmpl $0x0, -0x38(%rbp)
movl $0x0, %esi
cmoveq %r13, %rsi
movq %r15, %rdi
movq %rbx, %rdx
movq %r13, %rbx
callq 0x29c4b
jmp 0x4f270
leaq 0x1(%r15), %r14
xorl %eax, %eax
xorl %r13d, %r13d
leaq (%r14,%r13), %rcx
cmpq %r12, %rcx
jae 0x4f78f
cmpb $0x5d, (%rcx)
je 0x4f78f
incq %r13
incl %eax
jmp 0x4f77a
cmpl $0x0, -0x74(%rbp)
sete %cl
leaq 0x1(%r13), %rdx
cmpq $0x2, %rdx
setb %dl
orb %cl, %dl
jne 0x4f88d
movl %r13d, %ecx
addq %r15, %rcx
incq %rcx
movq %rcx, -0x40(%rbp)
movl %eax, %eax
movq %r15, -0x30(%rbp)
movq %r13, -0x38(%rbp)
movq %rax, %r12
testl %r12d, %r12d
je 0x4f7f4
movsbq (%r14), %r13
cmpq $-0x41, %r13
ja 0x4f7fe
incq -0x30(%rbp)
callq 0xc190
movq (%rax), %rcx
leaq -0x1(%r12), %rax
incq %r14
testb $0x20, 0x1(%rcx,%r13,2)
movq -0x48(%rbp), %rbx
jne 0x4f7c0
jmp 0x4f806
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x4f806
movq %r14, -0x30(%rbp)
movq -0x48(%rbp), %rbx
movq %rbx, %r13
movq %r12, %r14
subq $0x1, %r12
jb 0x4f874
movq -0x30(%rbp), %rax
movsbq -0x1(%rax,%r14), %rbx
cmpq $-0x41, %rbx
ja 0x4f831
callq 0xc190
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
jne 0x4f809
movq %r13, %rbx
movq %r13, %rdi
movq -0x30(%rbp), %rsi
movl %r14d, %edx
callq 0x29588
movq -0x68(%rbp), %rdi
callq 0x2a2b0
testq %rax, %rax
movq -0x58(%rbp), %r12
movq -0x38(%rbp), %r13
je 0x4f88d
movq %rax, %r14
movq -0x90(%rbp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x29c4b
movq %r14, -0x80(%rbp)
jmp 0x4f88d
movq %r13, %rbx
movq %r13, %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0x29588
movq -0x58(%rbp), %r12
movq -0x38(%rbp), %r13
leaq (%r15,%r13), %r14
addq $0x2, %r14
jmp 0x4f270
leaq -0xf0(%rbp), %rdi
callq 0x3bd5c
movq -0x68(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x299d3
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq