// File: /workspace/github_c_makefile_star2_O1/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, %r12d
movl %edx, %r14d
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
callq 0x317eb
movq %rax, %r15
movq %rbx, %rdi
callq 0x317a5
movq %rax, %r13
movq %rbx, %rdi
callq 0x317a5
testq %r15, %r15
sete %dl
testq %r13, %r13
sete %cl
orb %dl, %cl
movq %rax, -0x68(%rbp)
testq %rax, %rax
sete %dl
orb %cl, %dl
movq 0x60(%rbx), %rax
cmpb $0x1, %dl
jne 0x5d517
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0x1ade1(%rip), %rcx     # 0x782c5
movq %rax, %rdi
movl $0x1, %edx
callq 0x4153c
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x8, %eax
movl %eax, 0x8(%rbx)
jmp 0x5dc29
movq %r13, -0x50(%rbp)
movl %r12d, -0x7c(%rbp)
movq %r15, -0x78(%rbp)
movq %rbx, -0x70(%rbp)
leaq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x45b96
testl %r14d, %r14d
setne %r12b
movq -0x30(%rbp), %rbx
je 0x5dc10
movl %r14d, %r13d
addq %rbx, %r13
movq -0x78(%rbp), %r14
movq %rbx, %r15
movb (%r15), %bl
cmpb $-0x41, %bl
ja 0x5d58d
callq 0xc170
movq (%rax), %rax
incq %r15
movsbq %bl, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x5d58a
cmpq %r13, %r15
setb %r12b
jae 0x5dc10
movb (%r15), %bl
incq %r15
cmpb $-0x41, %bl
jbe 0x5d567
decq %r15
testb $0x1, %r12b
je 0x5dc10
movzbl (%r15), %eax
cmpl $0x3b, %eax
je 0x5d5a5
cmpl $0x23, %eax
jne 0x5d5cb
incq %r15
movq %r15, %rax
movq %rax, %r15
cmpq %r13, %rax
jae 0x5d5bd
leaq 0x1(%r15), %rax
cmpb $0xa, (%r15)
jne 0x5d5ab
cmpq %r13, %r15
setb %r12b
jb 0x5d554
jmp 0x5dc10
movq -0x50(%rbp), %rax
movl $0x0, 0x28(%rax)
movl 0x30(%rax), %eax
testb $0x4, %al
je 0x5d5f6
movq -0x50(%rbp), %rcx
movq $0x0, 0x20(%rcx)
movl $0x0, 0x2c(%rcx)
andl $-0x5, %eax
movl %eax, 0x30(%rcx)
cmpb $0x5b, (%r15)
movq %r14, -0x58(%rbp)
jne 0x5d6a2
leaq 0x1(%r15), %rax
movl $0x1, %r12d
movq %rax, %rbx
cmpq %r13, %rax
jae 0x5d630
cmpb $0x5d, (%r15,%r12)
je 0x5d62c
leaq (%r15,%r12), %rcx
incq %rcx
incq %r12
cmpq %r13, %rcx
jb 0x5d616
leaq (%r15,%r12), %rbx
cmpl $0x0, -0x7c(%rbp)
sete %cl
cmpq $0x2, %r12
setb %dl
orb %cl, %dl
jne 0x5daa9
movq %rbx, -0x30(%rbp)
leal -0x1(%r12), %ecx
movl %ecx, %ebx
movq %rax, %rsi
movq %r15, %r14
subl $0x1, %ebx
jb 0x5da22
movsbq (%rsi), %rax
movl %ecx, %edx
cmpq $-0x41, %rax
ja 0x5da24
movq %rsi, %r15
movq %rax, -0x40(%rbp)
callq 0xc170
movq %r15, %rsi
movq (%rax), %rcx
leaq 0x1(%r15), %rax
decl %r12d
leaq 0x1(%r14), %r15
movq -0x40(%rbp), %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
movl %ebx, %ecx
movl %r12d, %edx
jne 0x5d651
jmp 0x5da24
cmpq %r13, %r15
jae 0x5d88a
movl $0x0, -0x44(%rbp)
xorl %eax, %eax
movq %r15, %rbx
movb (%rbx), %cl
cmpb $0x3d, %cl
je 0x5d89c
cmpb $0x5b, %cl
setne %cl
testl %eax, %eax
setne %dl
orb %cl, %dl
je 0x5d6de
incq %rbx
cmpq %r13, %rbx
jb 0x5d6b7
jmp 0x5d89c
movl %ebx, %eax
subl %r15d, %eax
movl %eax, -0x44(%rbp)
testl %eax, %eax
jle 0x5d866
movq %r14, -0x60(%rbp)
movq %rbx, -0x30(%rbp)
movq %r15, %r14
movl -0x44(%rbp), %ecx
movsbq (%r14), %rbx
cmpq $-0x41, %rbx
ja 0x5d729
movl %ecx, %r12d
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x5d726
incq %r14
movl %r12d, %ecx
decl %ecx
jne 0x5d6fc
xorl %ecx, %ecx
jmp 0x5d729
movl %r12d, %ecx
movl %ecx, %ebx
notl %ecx
movq %r14, -0x40(%rbp)
movq %rbx, %rdx
subq $0x1, %rbx
jb 0x5d76e
movsbq -0x1(%r14,%rdx), %r12
cmpq $-0x41, %r12
ja 0x5d772
movq %rdx, -0x38(%rbp)
movl %ecx, %r14d
callq 0xc170
movl %r14d, %ecx
movq (%rax), %rax
incl %ecx
testb $0x20, 0x1(%rax,%r12,2)
movq -0x40(%rbp), %r14
jne 0x5d731
negl %ecx
movq -0x38(%rbp), %rdx
jmp 0x5d778
xorl %ecx, %ecx
jmp 0x5d778
movl %edx, %ecx
movq -0x40(%rbp), %r14
testq %rdx, %rdx
movq -0x30(%rbp), %rbx
je 0x5d7a9
cmpl $0x0, -0x98(%rbp)
movl $0x0, %eax
je 0x5d7ab
leaq -0xc0(%rbp), %rdi
movq %r14, %rsi
movl %ecx, -0x38(%rbp)
movl -0x38(%rbp), %edx
callq 0x4573a
movl -0x38(%rbp), %ecx
jmp 0x5d7ab
xorl %eax, %eax
testq %rax, %rax
je 0x5d7bd
movq 0x10(%rax), %r12
movq -0x60(%rbp), %r14
jmp 0x5d85f
movl %ecx, -0x38(%rbp)
movq -0x70(%rbp), %rdi
callq 0x317eb
testq %rax, %rax
je 0x5d882
movq %rax, %r12
leaq -0xc0(%rbp), %rdi
movq %r14, %rsi
movl -0x38(%rbp), %edx
movq %rax, %rcx
callq 0x4542b
movq -0x50(%rbp), %rbx
movl $0x0, 0x28(%rbx)
movl 0x30(%rbx), %eax
testb $0x4, %al
je 0x5d811
movq $0x0, 0x20(%rbx)
movl $0x0, 0x2c(%rbx)
andl $-0x5, %eax
movl %eax, 0x30(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
movl -0x38(%rbp), %edx
callq 0x3087c
movq -0x60(%rbp), %r14
testb $0x40, 0x8(%r14)
je 0x5d838
movq (%r14), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3f924
movl $0x0, 0x28(%rbx)
movl 0x30(%rbx), %eax
testb $0x4, %al
je 0x5d85b
movq $0x0, 0x20(%rbx)
movl $0x0, 0x2c(%rbx)
andl $-0x5, %eax
movl %eax, 0x30(%rbx)
movq -0x30(%rbp), %rbx
testq %r12, %r12
cmovneq %r12, %r14
movl $0x1, %eax
cmpq %r13, %rbx
jae 0x5d6d1
cmpb $0x5d, (%rbx)
je 0x5d6d1
incq %rbx
jmp 0x5d86b
xorl %r12d, %r12d
jmp 0x5d7b4
movl $0x0, -0x44(%rbp)
movb $0x1, %al
movq %r14, -0x60(%rbp)
movq %r15, %rbx
jmp 0x5d8a5
movq %r14, -0x60(%rbp)
testl %eax, %eax
sete %al
movq %rbx, -0x30(%rbp)
movl %ebx, %r14d
subl %r15d, %r14d
testb %al, %al
cmovel -0x44(%rbp), %r14d
testl %r14d, %r14d
movb %al, -0x38(%rbp)
je 0x5d8e2
movsbq (%r15), %rbx
cmpq $-0x41, %rbx
ja 0x5d8e2
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x5d8e2
incq %r15
decl %r14d
jne 0x5d8be
xorl %r14d, %r14d
movl %r14d, %ebx
movq %rbx, %r14
subq $0x1, %rbx
jb 0x5d9d4
movsbq -0x1(%r15,%r14), %r12
cmpq $-0x41, %r12
ja 0x5d90e
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r12,2)
jne 0x5d8e5
movb -0x38(%rbp), %al
testb %al, %al
je 0x5d924
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x3087c
movq -0x68(%rbp), %rax
movl $0x0, 0x28(%rax)
movl 0x30(%rax), %eax
testb $0x4, %al
movq -0x30(%rbp), %rdx
je 0x5d953
movq -0x68(%rbp), %rcx
movq $0x0, 0x20(%rcx)
movl $0x0, 0x2c(%rcx)
andl $-0x5, %eax
movl %eax, 0x30(%rcx)
leaq 0x1(%rdx), %rax
incl %edx
movq -0x58(%rbp), %r14
movq %rax, %r15
cmpq %r13, %rax
jae 0x5da1a
movl %edx, %r12d
movsbq (%r15), %rbx
cmpq $-0x41, %rbx
ja 0x5d98e
callq 0xc170
movq (%rax), %rcx
leaq 0x1(%r15), %rax
leal 0x1(%r12), %edx
testb $0x20, 0x1(%rcx,%rbx,2)
jne 0x5d95d
cmpb $0x22, %bl
je 0x5d99f
movzbl %bl, %eax
cmpl $0x27, %eax
jne 0x5dac7
leaq 0x1(%r15), %rcx
cmpq %r13, %rcx
setb %al
jae 0x5dac2
movq %rcx, %rdx
cmpb %bl, (%rcx)
jne 0x5d9c0
cmpb $0x5c, -0x1(%rdx)
jne 0x5daf3
leaq 0x1(%rdx), %rcx
movq %rdx, %rsi
cmpq %r13, %rcx
setb %al
jb 0x5d9af
jmp 0x5dafa
movq -0x30(%rbp), %rbx
cmpq %r13, %rbx
movq -0x58(%rbp), %r14
jae 0x5dab0
movq %rbx, %r15
movsbq (%rbx), %rbx
cmpq $-0x41, %rbx
ja 0x5da1a
callq 0xc170
cmpb $0x3d, %bl
je 0x5da0a
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
je 0x5da1a
movq %r15, %rbx
incq %rbx
cmpq %r13, %rbx
jb 0x5d9e5
jmp 0x5dab0
movq %r15, %rbx
jmp 0x5dab0
xorl %edx, %edx
movl %edx, %ebx
addq %rbx, %r14
movq %rbx, %rax
subq $0x1, %rbx
jb 0x5da9a
movq %rax, -0x40(%rbp)
movsbq (%r14), %r12
cmpq $-0x41, %r12
ja 0x5da59
movq %rsi, %r15
callq 0xc170
movq %r15, %rsi
movq (%rax), %rax
decq %r14
testb $0x20, 0x1(%rax,%r12,2)
jne 0x5da29
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rdx
callq 0x3087c
movq -0x70(%rbp), %rdi
callq 0x317eb
testq %rax, %rax
movq -0x30(%rbp), %rbx
je 0x5daa9
movq %rax, %r14
movq -0x78(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5da94
movq (%rax), %rdi
movq -0x50(%rbp), %rsi
movq %r14, %rdx
callq 0x3f924
movq %r14, -0x58(%rbp)
jmp 0x5daa9
movq -0x50(%rbp), %rdi
xorl %edx, %edx
callq 0x3087c
movq -0x30(%rbp), %rbx
incq %rbx
movq -0x58(%rbp), %r14
cmpq %r13, %rbx
setb %r12b
jb 0x5d551
jmp 0x5dc10
movq %r15, %rsi
jmp 0x5dafa
movq %r15, %rsi
cmpq %r13, %r15
jae 0x5db04
movzbl (%rsi), %eax
cmpl $0xa, %eax
je 0x5dae3
cmpl $0x23, %eax
je 0x5db04
cmpl $0x3b, %eax
jne 0x5dae9
jmp 0x5db04
cmpb $0x5c, -0x1(%rsi)
jne 0x5db04
incq %rsi
cmpq %r13, %rsi
jb 0x5dacf
jmp 0x5db04
leaq -0x1(%rdx), %rsi
movq %rdx, %rcx
addq $0x2, %rsi
testb $0x1, %al
cmoveq %rcx, %rsi
movq %rsi, -0x30(%rbp)
movl %esi, %r14d
subl %r12d, %r14d
movq %rbx, -0x40(%rbp)
je 0x5db38
movsbq (%r15), %rbx
cmpq $-0x41, %rbx
ja 0x5db38
callq 0xc170
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbx,2)
je 0x5db38
incq %r15
decl %r14d
jne 0x5db14
xorl %r14d, %r14d
movl %r14d, %edx
notl %r14d
movq %rdx, %rbx
subq $0x1, %rbx
jb 0x5db71
movsbq -0x1(%r15,%rdx), %r12
cmpq $-0x41, %r12
ja 0x5db73
callq 0xc170
movq (%rax), %rax
incl %r14d
testb $0x20, 0x1(%rax,%r12,2)
movq %rbx, %rdx
jne 0x5db41
negl %r14d
movl %r14d, %edx
jmp 0x5db73
xorl %edx, %edx
movq -0x40(%rbp), %rax
cmpb $0x27, %al
movq -0x58(%rbp), %r14
movq -0x30(%rbp), %rbx
je 0x5db8b
movzbl %al, %eax
cmpl $0x22, %eax
jne 0x5dbd3
testl %edx, %edx
je 0x5dbad
leal -0x1(%rdx), %eax
leaq (%r15,%rax), %rsi
incq %rsi
movq -0x40(%rbp), %rax
cmpb %al, (%r15)
jne 0x5dbad
incq %r15
decl %edx
jne 0x5db99
xorl %edx, %edx
jmp 0x5dbb0
movq %r15, %rsi
movl %edx, %eax
incl %edx
movq %rax, %rcx
subq $0x1, %rcx
jb 0x5dbcf
decl %edx
movq -0x40(%rbp), %rdi
cmpb %dil, -0x1(%rsi,%rax)
movq %rcx, %rax
je 0x5dbb7
jmp 0x5dbd6
xorl %edx, %edx
jmp 0x5dbd6
movq %r15, %rsi
testl %edx, %edx
je 0x5dbe3
movq -0x68(%rbp), %rdi
callq 0x3087c
movq -0x60(%rbp), %rax
testb $0x40, 0x8(%rax)
je 0x5dab0
cmpb $0x0, -0x38(%rbp)
movl $0x0, %esi
cmovneq -0x50(%rbp), %rsi
movq (%rax), %rdi
movq -0x68(%rbp), %rdx
callq 0x3f924
jmp 0x5dab0
leaq -0xc0(%rbp), %rdi
callq 0x45c05
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x30d83
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq