// File: /workspace/github_c_makefile_star2_O1/Cotix[P]cReddit/libreddit/jsmn.c
// Function: jsmn_parse
jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, jsmntok_t *tokens,
		unsigned int num_tokens) {
	jsmnerr_t r;
	int i;
#ifdef JSMN_PARENT_LINKS
	int k;
#endif
	int on_key = 1;
	jsmntok_t *token;

	for (; js[parser->pos] != '\0'; parser->pos++) {
		char c;
		jsmntype_t type;

		c = js[parser->pos];
		switch (c) {
			case '{': case '[':
				token = jsmn_alloc_token(parser, tokens, num_tokens);
				if (token == NULL)
					return JSMN_ERROR_NOMEM;
				token->is_key = 0; /* Objects can't be keys */
				if (parser->toksuper != -1) {
					tokens[parser->toksuper].size++;
#ifdef JSMN_PARENT_LINKS
					token->parent = parser->toksuper;
#endif
				}
				token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
				token->start = parser->pos;
				parser->toksuper = parser->toknext - 1;
				/*
				 * The start of a new object or array means we'll encounter a key next
				 * We reset this to show that
				 */
				on_key = 1;
				break;
			case '}': case ']':
				type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
#ifdef JSMN_PARENT_LINKS
				if (parser->toknext < 1) {
					return JSMN_ERROR_INVAL;
				}
				token = &tokens[parser->toknext - 1];
				for (;;) {
					if (token->start != -1 && token->end == -1) {
						if (token->type != type) {
							return JSMN_ERROR_INVAL;
						}
						token->end = parser->pos + 1;
						parser->toksuper = token->parent;
						break;
					}
					if (token->parent == -1) {
						break;
					}
					token = &tokens[token->parent];
				}
#else
				for (i = parser->toknext - 1; i >= 0; i--) {
					token = &tokens[i];
					if (token->start != -1 && token->end == -1) {
						if (token->type != type) {
							return JSMN_ERROR_INVAL;
						}
						parser->toksuper = -1;
						token->end = parser->pos + 1;
						break;
					}
				}
				/* Error if unmatched closing bracket */
				if (i == -1) return JSMN_ERROR_INVAL;
				for (; i >= 0; i--) {
					token = &tokens[i];
					if (token->start != -1 && token->end == -1) {
						parser->toksuper = i;
						break;
					}
				}
#endif
				/*
				 * The end of an object/array also means we'll encounter a key next
				 * We change the variable againt o show this
				 *
				 * Technically this shouldn't be nessisary (Since a comma should be soon)
				 * But better to have it then not.
				 */
				on_key = 1;
				break;
			case '\"':
				r = jsmn_parse_string(parser, js, tokens, on_key, num_tokens);
				if (r < 0) return r;
				if (parser->toksuper != -1)
					tokens[parser->toksuper].size++;
				break;

			/*
			 * The next two cases represent a change between whether or not the token
			 * is a key
			 */
			case ':':
				on_key = 0;
				break;
			case ',':
				on_key = 1;
				break;
			case '\t' : case '\r' : case '\n' : case ' ':
				break;
#ifdef JSMN_STRICT
			/* In strict mode primitives are: numbers and booleans */
			case '-': case '0': case '1' : case '2': case '3' : case '4':
			case '5': case '6': case '7' : case '8': case '9':
			case 't': case 'f': case 'n' :
#else
			/* In non-strict mode every unquoted value is a primitive */
			default:
#endif
				r = jsmn_parse_primitive(parser, js, tokens, on_key, num_tokens);
				if (r < 0) return r;
				if (parser->toksuper != -1)
					tokens[parser->toksuper].size++;
				break;

#ifdef JSMN_STRICT
			/* Unexpected char in strict mode */
			default:
				return JSMN_ERROR_INVAL;
#endif

		}
	}

	for (i = parser->toknext - 1; i >= 0; i--) {
		/* Unmatched opened object or array */
		if (tokens[i].start != -1 && tokens[i].end == -1) {
			return JSMN_ERROR_PART;
		}
#ifdef JSMN_PARENT_LINKS
		if (tokens[i].type == JSMN_OBJECT || tokens[i].type == JSMN_ARRAY) {
			tokens[i].full_size += tokens[i].size;
			for (k = tokens[i].parent; k != -1; k = tokens[k].parent) {
				tokens[k].full_size += tokens[i].size;
			}
		}
#endif
	}

	return JSMN_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq -0x1c(%rdx), %rax
movq %rax, -0x8(%rsp)
movl %ecx, %ecx
movl $0x1, %r13d
movabsq $0x100100002600, %r14   # imm = 0x100100002600
leaq 0x2a5c(%rip), %r15      # 0x6000
movl (%rdi), %ebx
movb (%rsi,%rbx), %al
movzbl %al, %r10d
xorl %r12d, %r12d
cmpl $0x1f, %r10d
jg 0x35d5
leal -0x9(%r10), %eax
cmpl $0x2, %eax
jb 0x35c5
cmpl $0xd, %r10d
jne 0x35ef
movb $0x1, %r12b
testb %r12b, %r12b
je 0x3a54
incl (%rdi)
jmp 0x35a4
leal -0x20(%r10), %r9d
cmpl $0x1a, %r9d
ja 0x35ff
movslq (%r15,%r9,4), %rax
addq %r15, %rax
jmpq *%rax
movl %ebx, %ebp
jmp 0x369a
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
testl %r10d, %r10d
jne 0x35c8
jmp 0x39db
addl $-0x5b, %r10d
cmpl $0x22, %r10d
ja 0x399b
movl $0x2080800, %r9d        # imm = 0x2080800
btq %r10, %r9
movl %ebx, %ebp
jb 0x369a
movabsq $0x100000001, %r9       # imm = 0x100000001
btq %r10, %r9
jb 0x3763
movabsq $0x400000004, %r9       # imm = 0x400000004
btq %r10, %r9
jae 0x399b
xorl %r10d, %r10d
cmpb $0x7d, %al
setne %r9b
movslq 0x4(%rdi), %rax
testq %rax, %rax
jle 0x3998
movb %r9b, %r10b
incl %r10d
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq -0x8(%rsp), %rax
addq %r9, %rax
cmpl $-0x1, 0x4(%rax)
je 0x367f
cmpl $-0x1, 0x8(%rax)
je 0x3989
movslq 0x18(%rax), %rax
cmpq $-0x1, %rax
je 0x396d
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rdx, %rax
jmp 0x366c
movl %ebp, %eax
movzbl (%rsi,%rax), %eax
movb $0x1, %r10b
cmpq $0x2c, %rax
ja 0x36b8
btq %rax, %r14
jb 0x36d2
testq %rax, %rax
je 0x37b3
cmpl $0x5d, %eax
je 0x36d2
cmpl $0x7d, %eax
je 0x36d2
addb $-0x7f, %al
cmpb $-0x5f, %al
jb 0x37ba
incl %ebp
movl %ebp, (%rdi)
jmp 0x369a
movslq 0x4(%rdi), %rax
cmpq %rcx, %rax
jae 0x371b
leal 0x1(%rax), %r9d
movl %r9d, 0x4(%rdi)
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
leaq (%rdx,%r9), %rax
movq $-0x1, 0x4(%rdx,%r9)
movl $0x0, 0xc(%rdx,%r9)
andb $-0x2, 0x10(%rdx,%r9)
movabsq $-0x100000000, %r11     # imm = 0xFFFFFFFF00000000
movq %r11, 0x14(%rdx,%r9)
jmp 0x371d
xorl %eax, %eax
testq %rax, %rax
je 0x375c
movl (%rdi), %r9d
xorl %r10d, %r10d
movl %r10d, (%rax)
movl %ebx, 0x4(%rax)
movl %r9d, 0x8(%rax)
movl %r10d, 0xc(%rax)
movb 0x10(%rax), %r9b
movl %r13d, %r11d
andb $0x1, %r11b
andb $-0x2, %r9b
orb %r11b, %r9b
movb %r9b, 0x10(%rax)
movl 0x8(%rdi), %r9d
movl %r9d, 0x18(%rax)
movl (%rdi), %ebx
decl %ebx
xorl %eax, %eax
jmp 0x37bf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x37bf
movslq 0x4(%rdi), %r9
cmpq %rcx, %r9
jae 0x3925
leal 0x1(%r9), %r10d
movl %r10d, 0x4(%rdi)
leaq (%r9,%r9,8), %r10
leaq (%r10,%r10,2), %r11
addq %r9, %r11
leaq (%rdx,%r11), %r10
movq $-0x1, 0x4(%rdx,%r11)
movl $0x0, 0xc(%rdx,%r11)
andb $-0x2, 0x10(%rdx,%r11)
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
movq %r9, 0x14(%rdx,%r11)
jmp 0x3928
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0x37bf
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %ebx, (%rdi)
testb %r10b, %r10b
je 0x39b5
xorl %r12d, %r12d
movl %eax, %r8d
jmp 0x35c8
movb $0x1, %r12b
xorl %r13d, %r13d
jmp 0x35c8
leal 0x1(%rbx), %eax
movl %r13d, %r10d
andb $0x1, %r10b
movl %eax, -0xc(%rsp)
movl %eax, %r9d
movl %r9d, (%rdi)
movl %r9d, %r11d
movzbl (%rsi,%r11), %r11d
cmpl $0x22, %r11d
je 0x3880
movb $0x1, %bpl
cmpl $0x5c, %r11d
je 0x3819
testl %r11d, %r11d
jne 0x3911
jmp 0x39a6
incl %r9d
movl %r9d, (%rdi)
movzbl (%rsi,%r9), %r9d
leal -0x62(%r9), %r11d
cmpl $0x13, %r11d
ja 0x3856
movq %rcx, %r12
movq %r14, %rcx
movq %r15, %r14
movl %r13d, %r15d
movl $0xd1011, %r13d         # imm = 0xD1011
btl %r11d, %r13d
movl %r15d, %r13d
movq %r14, %r15
movq %rcx, %r14
movq %r12, %rcx
jb 0x3911
addl $-0x22, %r9d
cmpl $0x3a, %r9d
ja 0x3874
movabsq $0x400000000002001, %r11 # imm = 0x400000000002001
btq %r9, %r11
jb 0x3911
movl %ebx, (%rdi)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x390f
movslq 0x4(%rdi), %rax
cmpq %rcx, %rax
jae 0x38c9
leal 0x1(%rax), %r9d
movl %r9d, 0x4(%rdi)
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
leaq (%rdx,%r9), %rax
movq $-0x1, 0x4(%rdx,%r9)
movl $0x0, 0xc(%rdx,%r9)
andb $-0x2, 0x10(%rdx,%r9)
movabsq $-0x100000000, %r11     # imm = 0xFFFFFFFF00000000
movq %r11, 0x14(%rdx,%r9)
jmp 0x38cb
xorl %eax, %eax
testq %rax, %rax
je 0x3908
movl (%rdi), %r9d
movl $0x3, (%rax)
movl -0xc(%rsp), %r11d
movl %r11d, 0x4(%rax)
movl %r9d, 0x8(%rax)
movl $0x0, 0xc(%rax)
movb 0x10(%rax), %r9b
andb $-0x2, %r9b
orb %r10b, %r9b
movb %r9b, 0x10(%rax)
movl 0x8(%rdi), %r9d
movl %r9d, 0x18(%rax)
xorl %eax, %eax
jmp 0x390f
movl %ebx, (%rdi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x39ad
movl (%rdi), %r9d
incl %r9d
jmp 0x37f1
xorl %r10d, %r10d
testq %r10, %r10
je 0x397b
andb $-0x2, 0x10(%r10)
movslq 0x8(%rdi), %r9
cmpq $-0x1, %r9
je 0x3950
leaq (%r9,%r9,8), %r11
leaq (%r11,%r11,2), %r11
addq %r9, %r11
incl 0xc(%rdx,%r11)
movl %r9d, 0x18(%r10)
xorl %r9d, %r9d
cmpb $0x7b, %al
setne %r9b
incl %r9d
movl %r9d, (%r10)
movl (%rdi), %eax
movl %eax, 0x4(%r10)
movl 0x4(%rdi), %eax
decl %eax
movl %eax, 0x8(%rdi)
movb $0x1, %r12b
movl $0x1, %r13d
jmp 0x35c8
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
jmp 0x35c8
cmpl %r10d, (%rax)
jne 0x3998
incl %ebx
movl %ebx, 0x8(%rax)
movl 0x18(%rax), %eax
jmp 0x396a
xorl %r12d, %r12d
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
jmp 0x35c8
movl %ebx, (%rdi)
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
testl %eax, %eax
js 0x37ca
movslq 0x8(%rdi), %rax
movb $0x1, %r12b
cmpq $-0x1, %rax
je 0x35c8
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
incl 0xc(%rdx,%r9)
jmp 0x35c8
movslq 0x4(%rdi), %rax
xorl %r8d, %r8d
testq %rax, %rax
jle 0x3a54
movq %rax, %rcx
decq %rax
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rdi
leaq (%rcx,%rdi), %rsi
decq %rsi
leaq (%rdx,%rsi), %r9
cmpl $-0x1, 0x4(%rdx,%rsi)
je 0x3a0e
cmpl $-0x1, 0x8(%r9)
je 0x3a4e
movl (%r9), %esi
decl %esi
cmpl $0x1, %esi
ja 0x3a46
movl 0xc(%r9), %esi
addl %esi, 0x14(%r9)
addq %rax, %rdi
movl 0x18(%rdx,%rdi), %edi
cmpl $-0x1, %edi
je 0x3a46
movslq %edi, %rdi
leaq (%rdi,%rdi,8), %r9
leaq (%r9,%r9,2), %r9
addq %rdi, %r9
addl %esi, 0x14(%rdx,%r9)
movl 0x18(%rdx,%r9), %edi
jmp 0x3a27
cmpq $0x1, %rcx
jg 0x39e7
jmp 0x3a54
movl $0xfffffffd, %r8d       # imm = 0xFFFFFFFD
movl %r8d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq