// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movl %ecx, -0x7c(%rbp)
movl %edx, %r14d
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
callq 0x31231
movq %rax, %r13
movq %rbx, %rdi
callq 0x311eb
movq %rax, %r12
movq %rbx, %rdi
callq 0x311eb
testq %r13, %r13
sete %dl
testq %r12, %r12
sete %cl
orb %dl, %cl
movq %rax, -0x70(%rbp)
testq %rax, %rax
sete %dl
orb %cl, %dl
movq %rbx, -0x78(%rbp)
movq 0x60(%rbx), %rax
cmpb $0x1, %dl
jne 0x5bbdf
movq -0x78(%rbp), %rbx
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x1a724(%rip), %rcx     # 0x762d0
movq %rax, %rdi
movl $0x1, %edx
callq 0x40afa
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
jmp 0x5c335
movq %r12, -0x50(%rbp)
leaq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x44d43
testl %r14d, %r14d
movq -0x30(%rbp), %r8
je 0x5c31d
movl %r14d, %r12d
addq %r8, %r12
movq %r13, -0x48(%rbp)
movq %r8, %r15
movsbq (%r15), %r14
cmpq $-0x41, %r14
ja 0x5bc26
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
jne 0x5bc56
cmpb $0x3b, %r14b
je 0x5bc35
movzbl %r14b, %eax
cmpl $0x23, %eax
jne 0x5bc63
incq %r15
cmpq %r12, %r15
jae 0x5c31d
leaq 0x1(%r15), %rax
cmpb $0xa, (%r15)
movq %rax, %r15
jne 0x5bc38
decq %rax
movq %rax, %r15
jmp 0x5bc0c
incq %r15
cmpq %r12, %r15
jb 0x5bc0c
jmp 0x5c31d
movq -0x50(%rbp), %rax
movl $0x0, 0x28(%rax)
movl 0x30(%rax), %eax
testb $0x4, %al
je 0x5bc8e
movq -0x50(%rbp), %rcx
movq $0x0, 0x20(%rcx)
movl $0x0, 0x2c(%rcx)
andl $-0x5, %eax
movl %eax, 0x30(%rcx)
movb (%r15), %cl
cmpb $0x5b, %cl
jne 0x5bcc6
leaq 0x1(%r15), %rbx
cmpq %r12, %rbx
jae 0x5bced
movq %r12, %rax
subq %r15, %rax
movl $0x1, %r8d
cmpb $0x5d, (%r15,%r8)
je 0x5bd14
leaq (%r15,%r8), %rcx
incq %rcx
incq %r8
cmpq %r12, %rcx
jb 0x5bcab
addq %r15, %r8
jmp 0x5bd1a
cmpq %r12, %r15
movq %r13, -0x58(%rbp)
jae 0x5bd00
cmpb $0x3d, %cl
jne 0x5bd71
xorl %r14d, %r14d
movb $0x1, %cl
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %r15, %r8
jmp 0x5bf47
movq %rbx, %r8
movq -0x48(%rbp), %r14
incq %r8
movq %r14, -0x48(%rbp)
jmp 0x5c314
movb $0x1, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %r15, %r8
jmp 0x5bf96
movq %r8, %rax
addq %r15, %r8
cmpl $0x0, -0x7c(%rbp)
je 0x5bcf0
cmpq $0x2, %rax
jb 0x5bcf0
movq %r13, -0x58(%rbp)
decl %eax
leaq (%rbx,%rax), %rcx
movq %rcx, -0x38(%rbp)
movq %r8, -0x30(%rbp)
movq %rax, %r14
testl %r14d, %r14d
je 0x5c136
movsbq (%rbx), %r13
cmpq $-0x41, %r13
ja 0x5c13c
incq %r15
callq 0xc170
movq (%rax), %rcx
leaq -0x1(%r14), %rax
incq %rbx
testb $0x20, 0x1(%rcx,%r13,2)
jne 0x5bd38
jmp 0x5c13f
xorl %eax, %eax
movq -0x48(%rbp), %rdx
movq %rdx, -0x68(%rbp)
movq %r15, %r8
xorl %r14d, %r14d
cmpb $0x5b, %cl
setne %cl
testl %eax, %eax
setne %dl
orb %cl, %dl
jne 0x5bf2e
movl %r8d, %r14d
subl %r15d, %r14d
testl %r14d, %r14d
jle 0x5bf1b
movq %r15, %rsi
movl %r14d, -0x40(%rbp)
movl %r14d, %r13d
movq %r8, -0x30(%rbp)
movsbq (%rsi), %r14
cmpq $-0x41, %r14
ja 0x5bde1
movq %rsi, %rbx
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
je 0x5bdde
movq %rbx, %rsi
incq %rsi
decl %r13d
jne 0x5bdb1
xorl %r13d, %r13d
jmp 0x5bde1
movq %rbx, %rsi
movl %r13d, %r13d
movq %rsi, -0x60(%rbp)
movq %r13, %rax
subq $0x1, %r13
jb 0x5be44
movq %rax, -0x38(%rbp)
movsbq -0x1(%rsi,%rax), %r14
cmpq $-0x41, %r14
ja 0x5be17
movq %rsi, %rbx
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
movq %rbx, %rsi
jne 0x5bde8
cmpl $0x0, -0x98(%rbp)
je 0x5be4c
leaq -0xc0(%rbp), %rdi
movq -0x38(%rbp), %rbx
movl %ebx, %edx
callq 0x448fa
testq %rax, %rax
movl -0x40(%rbp), %r14d
je 0x5be54
movq 0x10(%rax), %rcx
jmp 0x5bf08
xorl %ebx, %ebx
movl -0x40(%rbp), %r14d
jmp 0x5be54
movl -0x40(%rbp), %r14d
movq -0x38(%rbp), %rbx
movq -0x78(%rbp), %rdi
callq 0x31231
testq %rax, %rax
je 0x5bf06
leaq -0xc0(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl %ebx, %edx
movq %rax, -0x38(%rbp)
movq %rax, %rcx
callq 0x445f4
movq -0x50(%rbp), %r14
movl $0x0, 0x28(%r14)
movl 0x30(%r14), %eax
testb $0x4, %al
je 0x5beaa
movq $0x0, 0x20(%r14)
movl $0x0, 0x2c(%r14)
andl $-0x5, %eax
movl %eax, 0x30(%r14)
movq %r14, %rdi
movq -0x60(%rbp), %rsi
movl %ebx, %edx
callq 0x302f6
movq -0x68(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5bed1
movq (%rax), %rdi
movq %r14, %rsi
movq -0x38(%rbp), %rdx
callq 0x3ef1d
movl $0x0, 0x28(%r14)
movl 0x30(%r14), %eax
testb $0x4, %al
movq -0x38(%rbp), %rcx
je 0x5befc
movq $0x0, 0x20(%r14)
movl $0x0, 0x2c(%r14)
andl $-0x5, %eax
movl %eax, 0x30(%r14)
movq -0x30(%rbp), %r8
movl -0x40(%rbp), %r14d
jmp 0x5bf0c
xorl %ecx, %ecx
movq -0x30(%rbp), %r8
testq %rcx, %rcx
movq -0x68(%rbp), %rax
cmovneq %rcx, %rax
movq %rax, -0x68(%rbp)
movl $0x1, %eax
cmpb $0x5d, (%r8)
je 0x5bf2e
incq %r8
cmpq %r12, %r8
jb 0x5bf1b
incq %r8
cmpq %r12, %r8
jae 0x5bf42
movb (%r8), %cl
cmpb $0x3d, %cl
jne 0x5bd81
testl %eax, %eax
sete %cl
movl %r8d, %ebx
subl %r15d, %ebx
movb %cl, -0x60(%rbp)
testb %cl, %cl
cmovel %r14d, %ebx
testl %ebx, %ebx
je 0x5bf96
leal -0x1(%rbx), %eax
addq %r15, %rax
incq %rax
movq %rax, -0x30(%rbp)
movsbq (%r15), %r13
cmpq $-0x41, %r13
ja 0x5bf9e
movq %r8, %r14
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
je 0x5bf9b
incq %r15
decl %ebx
movq %r14, %r8
jne 0x5bf67
xorl %ebx, %ebx
movq -0x30(%rbp), %r15
jmp 0x5bf9e
xorl %r14d, %r14d
jmp 0x5bfa1
movq %r14, %r8
movl %ebx, %r14d
movq %r8, -0x30(%rbp)
movq %r14, %rbx
subq $0x1, %r14
jb 0x5c0e6
movsbq -0x1(%r15,%rbx), %r13
cmpq $-0x41, %r13
ja 0x5bfd2
callq 0xc170
movq -0x30(%rbp), %r8
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
jne 0x5bfa5
cmpb $0x0, -0x60(%rbp)
je 0x5bfea
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x302f6
movq -0x30(%rbp), %r8
movq -0x70(%rbp), %rax
movl $0x0, 0x28(%rax)
movl 0x30(%rax), %eax
testb $0x4, %al
movq -0x58(%rbp), %r13
je 0x5c019
movq -0x70(%rbp), %rcx
movq $0x0, 0x20(%rcx)
movl $0x0, 0x2c(%rcx)
andl $-0x5, %eax
movl %eax, 0x30(%rcx)
leaq 0x1(%r8), %rax
leal 0x1(%r8), %ecx
addq $0x3, %r8
movq %rax, %r15
cmpq %r12, %rax
jae 0x5c12e
movl %ecx, %ebx
movq %r8, %r14
movsbq (%r15), %rdi
cmpq $-0x41, %rdi
ja 0x5c06e
movq %r15, -0x38(%rbp)
movq %r13, %r15
movq %rdi, %r13
callq 0xc170
movq %r13, %rdi
movq %r15, %r13
movq -0x38(%rbp), %r15
movq (%rax), %rdx
leaq 0x1(%r15), %rax
leal 0x1(%rbx), %ecx
leaq 0x1(%r14), %r8
testb $0x20, 0x1(%rdx,%rdi,2)
jne 0x5c025
cmpb $0x22, %dil
je 0x5c080
movzbl %dil, %eax
movq %r15, %r8
cmpl $0x27, %eax
jne 0x5c0b2
leaq 0x1(%r15), %r8
cmpq %r12, %r8
jae 0x5c1d3
cmpb %dil, -0x1(%r14)
jne 0x5c09e
cmpb $0x5c, -0x2(%r14)
jne 0x5c1d0
leaq 0x1(%r14), %r8
cmpq %r12, %r14
movq %r8, %r14
jb 0x5c08d
decq %r8
jmp 0x5c1d3
movzbl (%r8), %eax
cmpl $0xa, %eax
je 0x5c0ce
cmpl $0x23, %eax
je 0x5c1d3
cmpl $0x3b, %eax
jne 0x5c0d9
jmp 0x5c1d3
cmpb $0x5c, -0x1(%r8)
jne 0x5c1d3
incq %r8
cmpq %r12, %r8
jb 0x5c0b2
jmp 0x5c1d3
cmpq %r12, %r8
movq -0x58(%rbp), %r13
jae 0x5c314
movsbq (%r8), %r14
cmpq $-0x41, %r14
ja 0x5c314
movq %r8, %r15
callq 0xc170
cmpb $0x3d, %r14b
je 0x5c11e
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
andl $0x2000, %eax           # imm = 0x2000
je 0x5c12e
movq %r15, %r8
incq %r8
cmpq %r12, %r8
jb 0x5c0f3
jmp 0x5c314
movq %r15, %r8
jmp 0x5c314
movq -0x38(%rbp), %r15
jmp 0x5c13f
movq %rbx, %r15
movq %r14, %rbx
subq $0x1, %r14
jb 0x5c1a0
movsbq -0x1(%r15,%rbx), %r13
cmpq $-0x41, %r13
ja 0x5c164
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
jne 0x5c13f
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x302f6
movq -0x78(%rbp), %rdi
callq 0x31231
testq %rax, %rax
je 0x5c1bf
movq %rax, %r14
movq -0x58(%rbp), %r13
testb $0x40, 0x8(%r13)
je 0x5c1c7
movq (%r13), %rdi
movq -0x50(%rbp), %rsi
movq %r14, %rdx
callq 0x3ef1d
jmp 0x5c1c7
movq -0x50(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x302f6
movq -0x30(%rbp), %r8
movq -0x48(%rbp), %r14
movq -0x58(%rbp), %r13
jmp 0x5bcf4
movq -0x48(%rbp), %r14
movq -0x58(%rbp), %r13
movq -0x30(%rbp), %r8
jmp 0x5bcf4
movq %r14, %r8
movl %r8d, %r14d
subl %ebx, %r14d
movq %r8, -0x30(%rbp)
movq %rdi, -0x40(%rbp)
jne 0x5c1e7
xorl %edx, %edx
jmp 0x5c233
movq %r15, -0x38(%rbp)
movsbq (%r15), %r15
cmpq $-0x41, %r15
ja 0x5c21e
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
je 0x5c224
movq -0x38(%rbp), %r15
incq %r15
decl %r14d
movq -0x30(%rbp), %r8
movq -0x40(%rbp), %rdi
jne 0x5c1e7
xorl %r14d, %r14d
jmp 0x5c230
movq -0x38(%rbp), %r15
jmp 0x5c230
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %rdi
movl %r14d, %edx
movl %edx, %r14d
notl %r14d
movq %rdx, %r13
movq %r15, -0x38(%rbp)
subq $0x1, %r13
jb 0x5c27c
movsbq -0x1(%r15,%rdx), %r15
cmpq $-0x41, %r15
ja 0x5c280
callq 0xc170
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %r8
movq (%rax), %rax
incl %r14d
testb $0x20, 0x1(%rax,%r15,2)
movq %r13, %rdx
movq -0x38(%rbp), %r15
jne 0x5c240
negl %r14d
movl %r14d, %edx
jmp 0x5c284
xorl %edx, %edx
jmp 0x5c284
movq -0x38(%rbp), %r15
cmpb $0x27, %dil
movq -0x58(%rbp), %r13
movb -0x60(%rbp), %r14b
je 0x5c29b
movzbl %dil, %eax
cmpl $0x22, %eax
jne 0x5c2bd
testl %edx, %edx
je 0x5c2c3
leal -0x1(%rdx), %eax
addq %r15, %rax
incq %rax
cmpb %dil, (%r15)
jne 0x5c2b9
incq %r15
decl %edx
jne 0x5c2a8
xorl %edx, %edx
movq %rax, %r15
movl %edx, %eax
jmp 0x5c2c5
testl %edx, %edx
jne 0x5c2dd
jmp 0x5c2ed
xorl %eax, %eax
leal 0x1(%rax), %edx
movq %rax, %rcx
subq $0x1, %rcx
jb 0x5c2ed
decl %edx
cmpb %dil, -0x1(%r15,%rax)
movq %rcx, %rax
je 0x5c2cb
movq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x302f6
movq -0x30(%rbp), %r8
movq -0x68(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5c314
testb %r14b, %r14b
movl $0x0, %esi
cmovneq -0x50(%rbp), %rsi
movq (%rax), %rdi
movq -0x70(%rbp), %rdx
callq 0x3ef1d
movq -0x30(%rbp), %r8
cmpq %r12, %r8
jb 0x5bc09
leaq -0xc0(%rbp), %rdi
callq 0x44db2
movq -0x78(%rbp), %rdi
movq %r13, %rsi
callq 0x307f4
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq