// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: StrModeToFlags
static int StrModeToFlags(jx9_context *pCtx, const char *zMode, int nLen)
{
	const char *zEnd = &zMode[nLen];
	int iFlag = 0;
	int c;
	if( nLen < 1 ){
		/* Open in a read-only mode */
		return JX9_IO_OPEN_RDONLY;
	}
	c = zMode[0];
	if( c == 'r' || c == 'R' ){
		/* Read-only access */
		iFlag = JX9_IO_OPEN_RDONLY;
		zMode++; /* Advance */
		if( zMode < zEnd ){
			c = zMode[0];
			if( c == '+' || c == 'w' || c == 'W' ){
				/* Read+Write access */
				iFlag = JX9_IO_OPEN_RDWR;
			}
		}
	}else if( c == 'w' || c == 'W' ){
		/* Overwrite mode.
		 * If the file does not exists, try to create it
		 */
		iFlag = JX9_IO_OPEN_WRONLY|JX9_IO_OPEN_TRUNC|JX9_IO_OPEN_CREATE;
		zMode++; /* Advance */
		if( zMode < zEnd ){
			c = zMode[0];
			if( c == '+' || c == 'r' || c == 'R' ){
				/* Read+Write access */
				iFlag &= ~JX9_IO_OPEN_WRONLY;
				iFlag |= JX9_IO_OPEN_RDWR;
			}
		}
	}else if( c == 'a' || c == 'A' ){
		/* Append mode (place the file pointer at the end of the file).
		 * Create the file if it does not exists.
		 */
		iFlag = JX9_IO_OPEN_WRONLY|JX9_IO_OPEN_APPEND|JX9_IO_OPEN_CREATE;
		zMode++; /* Advance */
		if( zMode < zEnd ){
			c = zMode[0];
			if( c == '+' ){
				/* Read-Write access */
				iFlag &= ~JX9_IO_OPEN_WRONLY;
				iFlag |= JX9_IO_OPEN_RDWR;
			}
		}
	}else if( c == 'x' || c == 'X' ){
		/* Exclusive access.
		 * If the file already exists, return immediately with a failure code.
		 * Otherwise create a new file.
		 */
		iFlag = JX9_IO_OPEN_WRONLY|JX9_IO_OPEN_EXCL;
		zMode++; /* Advance */
		if( zMode < zEnd ){
			c = zMode[0];
			if( c == '+' || c == 'r' || c == 'R' ){
				/* Read-Write access */
				iFlag &= ~JX9_IO_OPEN_WRONLY;
				iFlag |= JX9_IO_OPEN_RDWR;
			}
		}
	}else if( c == 'c' || c == 'C' ){
		/* Overwrite mode.Create the file if it does not exists.*/
		iFlag = JX9_IO_OPEN_WRONLY|JX9_IO_OPEN_CREATE;
		zMode++; /* Advance */
		if( zMode < zEnd ){
			c = zMode[0];
			if( c == '+' ){
				/* Read-Write access */
				iFlag &= ~JX9_IO_OPEN_WRONLY;
				iFlag |= JX9_IO_OPEN_RDWR;
			}
		}
	}else{
		/* Invalid mode. Assume a read only open */
		jx9_context_throw_error(pCtx, JX9_CTX_NOTICE, "Invalid open mode, JX9 is assuming a Read-Only open");
		iFlag = JX9_IO_OPEN_RDONLY;
	}
	while( zMode < zEnd ){
		c = zMode[0];
		if( c == 'b' || c == 'B' ){
			iFlag &= ~JX9_IO_OPEN_TEXT;
			iFlag |= JX9_IO_OPEN_BINARY;
		}else if( c == 't' || c == 'T' ){
			iFlag &= ~JX9_IO_OPEN_BINARY;
			iFlag |= JX9_IO_OPEN_TEXT;
		}
		zMode++;
	}
	return iFlag;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jge 0xab11b
movl $0x1, -0x4(%rbp)
jmp 0xab368
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x72, -0x30(%rbp)
je 0xab131
cmpl $0x52, -0x30(%rbp)
jne 0xab178
movl $0x1, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab173
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x2b, -0x30(%rbp)
je 0xab16a
cmpl $0x77, -0x30(%rbp)
je 0xab16a
cmpl $0x57, -0x30(%rbp)
jne 0xab171
movl $0x4, -0x2c(%rbp)
jmp 0xab173
jmp 0xab2f6
cmpl $0x77, -0x30(%rbp)
je 0xab184
cmpl $0x57, -0x30(%rbp)
jne 0xab1d6
movl $0x1a, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab1d1
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x2b, -0x30(%rbp)
je 0xab1bd
cmpl $0x72, -0x30(%rbp)
je 0xab1bd
cmpl $0x52, -0x30(%rbp)
jne 0xab1cf
movl -0x2c(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x2c(%rbp)
jmp 0xab1d1
jmp 0xab2f4
cmpl $0x61, -0x30(%rbp)
je 0xab1e2
cmpl $0x41, -0x30(%rbp)
jne 0xab228
movl $0x2a, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab223
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x2b, -0x30(%rbp)
jne 0xab221
movl -0x2c(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x2c(%rbp)
jmp 0xab223
jmp 0xab2f2
cmpl $0x78, -0x30(%rbp)
je 0xab234
cmpl $0x58, -0x30(%rbp)
jne 0xab283
movl $0x42, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab281
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x2b, -0x30(%rbp)
je 0xab26d
cmpl $0x72, -0x30(%rbp)
je 0xab26d
cmpl $0x52, -0x30(%rbp)
jne 0xab27f
movl -0x2c(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x2c(%rbp)
jmp 0xab281
jmp 0xab2f0
cmpl $0x63, -0x30(%rbp)
je 0xab28f
cmpl $0x43, -0x30(%rbp)
jne 0xab2d2
movl $0xa, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab2d0
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x2b, -0x30(%rbp)
jne 0xab2ce
movl -0x2c(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x2c(%rbp)
jmp 0xab2d0
jmp 0xab2ee
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x1aad5(%rip), %rdx     # 0xc5db7
callq 0x580b0
movl $0x1, -0x2c(%rbp)
jmp 0xab2f0
jmp 0xab2f2
jmp 0xab2f4
jmp 0xab2f6
jmp 0xab2f8
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xab362
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x62, -0x30(%rbp)
je 0xab318
cmpl $0x42, -0x30(%rbp)
jne 0xab330
movl -0x2c(%rbp), %eax
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x2c(%rbp)
jmp 0xab354
cmpl $0x74, -0x30(%rbp)
je 0xab33c
cmpl $0x54, -0x30(%rbp)
jne 0xab352
movl -0x2c(%rbp), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x2c(%rbp)
jmp 0xab354
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xab2f8
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)