// File: /workspace/github_c_makefile_star2_O3/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 (%rdi), %ebx
movl $0x1, %r14d
xorl %ebp, %ebp
movabsq $0x100100002600, %r15   # imm = 0x100100002600
leaq 0x2a70(%rip), %r12      # 0x6000
movl $0xd1011, %r11d         # imm = 0xD1011
movabsq $0x400000000002001, %r8 # imm = 0x400000000002001
movl %ebx, %eax
movb (%rsi,%rax), %r10b
movzbl %r10b, %r13d
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpl $0x1f, %r13d
jg 0x35d2
leal -0x9(%r13), %r9d
cmpl $0x2, %r9d
jb 0x37a8
cmpl $0xd, %r13d
je 0x37a8
jmp 0x38d9
leal -0x20(%r13), %r9d
cmpl $0x1a, %r9d
ja 0x364d
movslq (%r12,%r9,4), %r9
addq %r12, %r9
xorl %r13d, %r13d
jmpq *%r9
leal 0x1(%rbx), %r10d
movl %r10d, %r13d
movl %r13d, (%rdi)
movl %r13d, %eax
movzbl (%rsi,%rax), %eax
cmpl $0x5c, %eax
je 0x3611
testl %eax, %eax
je 0x38c0
cmpl $0x22, %eax
jne 0x3648
jmp 0x3859
incl %r13d
movl %r13d, (%rdi)
movzbl (%rsi,%r13), %r9d
leal -0x62(%r9), %eax
cmpl $0x13, %eax
ja 0x362b
btl %eax, %r11d
jb 0x3648
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addl $-0x22, %r9d
cmpl $0x3a, %r9d
ja 0x38cc
btq %r9, %r8
jae 0x38cc
incl %r13d
jmp 0x35f0
addl $-0x5b, %r13d
cmpl $0x22, %r13d
ja 0x38ce
movl $0x2080800, %r9d        # imm = 0x2080800
btq %r13, %r9
jb 0x36ee
movabsq $0x100000001, %r9       # imm = 0x100000001
btq %r13, %r9
jb 0x37b9
movabsq $0x400000004, %r9       # imm = 0x400000004
btq %r13, %r9
jae 0x38ce
xorl %r14d, %r14d
cmpb $0x7d, %r10b
setne %r9b
movslq 0x4(%rdi), %r10
testq %r10, %r10
jle 0x38ce
movb %r9b, %r14b
incl %r14d
leaq (%r10,%r10,8), %r9
leaq (%r9,%r9,2), %r9
addq -0x8(%rsp), %r10
addq %r9, %r10
cmpl $-0x1, 0x4(%r10)
je 0x36d3
cmpl $-0x1, 0x8(%r10)
je 0x3838
movslq 0x18(%r10), %r10
cmpq $-0x1, %r10
je 0x384e
leaq (%r10,%r10,8), %r9
leaq (%r9,%r9,2), %r9
addq %rdx, %r10
jmp 0x36be
leal 0x1(%rbx), %eax
movzbl %r10b, %r13d
cmpb $0x2c, %r13b
ja 0x370a
btq %r13, %r15
jb 0x3731
testq %r13, %r13
je 0x38c0
cmpl $0x5d, %r13d
je 0x3731
cmpl $0x7d, %r13d
je 0x3731
addb $-0x7f, %r10b
cmpb $-0x5f, %r10b
jb 0x38c7
movl %eax, (%rdi)
movl %eax, %r9d
movb (%rsi,%r9), %r10b
incl %eax
jmp 0x36f1
movslq 0x4(%rdi), %rax
cmpq %rcx, %rax
jae 0x3955
leal 0x1(%rax), %r9d
movl %r9d, 0x4(%rdi)
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
movb 0x10(%rdx,%r9), %al
andb $-0x2, %al
movb %al, 0x10(%rdx,%r9)
movl %ebp, 0x14(%rdx,%r9)
movl (%rdi), %r10d
movl %ebp, (%rdx,%r9)
movl %ebx, 0x4(%rdx,%r9)
movl %r10d, 0x8(%rdx,%r9)
movl %ebp, 0xc(%rdx,%r9)
movl %r14d, %r10d
andb $0x1, %r10b
orb %al, %r10b
movb %r10b, 0x10(%rdx,%r9)
movslq 0x8(%rdi), %rax
movl %eax, 0x18(%rdx,%r9)
decl (%rdi)
cmpq $-0x1, %rax
je 0x37a8
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
incl 0xc(%rdx,%r9)
movl %r14d, %r13d
movl (%rdi), %ebx
incl %ebx
movl %ebx, (%rdi)
movl %r13d, %r14d
jmp 0x35a0
movslq 0x4(%rdi), %rax
cmpq %rcx, %rax
jae 0x3969
leal 0x1(%rax), %r9d
movl %r9d, 0x4(%rdi)
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x8(%rdx,%r9)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x14(%rdx,%r9)
andb $-0x2, 0x10(%rdx,%r9)
leaq (%rdx,%r9), %rax
movslq 0x8(%rdi), %r9
cmpq $-0x1, %r9
je 0x3819
leaq (%r9,%r9,8), %rbx
leaq (%rbx,%rbx,2), %rbx
addq %r9, %rbx
incl 0xc(%rdx,%rbx)
movl %r9d, 0x18(%rax)
xorl %r9d, %r9d
cmpb $0x7b, %r10b
setne %r9b
incl %r9d
movl %r9d, (%rax)
movl (%rdi), %r9d
movl %r9d, 0x4(%rax)
movl 0x4(%rdi), %eax
decl %eax
jmp 0x384b
cmpl %r14d, (%r10)
jne 0x38ce
incl %ebx
movl %ebx, 0x8(%r10)
movl 0x18(%r10), %eax
movl %eax, 0x8(%rdi)
movl $0x1, %r13d
jmp 0x37ab
movslq 0x4(%rdi), %rax
cmpq %rcx, %rax
jae 0x3955
leal 0x1(%rax), %r9d
movl %r9d, 0x4(%rdi)
leaq (%rax,%rax,8), %r9
leaq (%r9,%r9,2), %r9
addq %rax, %r9
movb 0x10(%rdx,%r9), %al
andb $-0x2, %al
movb %al, 0x10(%rdx,%r9)
movl %ebp, 0x14(%rdx,%r9)
movl (%rdi), %ebx
movl $0x3, (%rdx,%r9)
movl %r10d, 0x4(%rdx,%r9)
movl %ebx, 0x8(%rdx,%r9)
movl %ebp, 0xc(%rdx,%r9)
movl %r14d, %r10d
andb $0x1, %r10b
orb %al, %r10b
movb %r10b, 0x10(%rdx,%r9)
movslq 0x8(%rdi), %rax
movl %eax, 0x18(%rdx,%r9)
jmp 0x3792
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0x38cc
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %ebx, (%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r13d, %r13d
jne 0x38ce
movslq 0x4(%rdi), %rcx
xorl %eax, %eax
testq %rcx, %rcx
jle 0x38ce
movq %rcx, %rsi
decq %rcx
leaq (%rcx,%rcx,8), %rdi
leaq (%rdi,%rdi,2), %r8
leaq (%rsi,%r8), %rdi
decq %rdi
leaq (%rdx,%rdi), %r9
cmpl $-0x1, 0x4(%rdx,%rdi)
je 0x3910
cmpl $-0x1, 0x8(%r9)
je 0x395f
movl (%r9), %edi
decl %edi
cmpl $0x1, %edi
ja 0x394a
movl 0xc(%r9), %edi
addl %edi, 0x14(%r9)
addq %rcx, %r8
movl 0x18(%rdx,%r8), %r8d
cmpl $-0x1, %r8d
je 0x394a
movslq %r8d, %r8
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
addl %edi, 0x14(%rdx,%r9)
movl 0x18(%rdx,%r9), %r8d
jmp 0x392a
cmpq $0x1, %rsi
jg 0x38e9
jmp 0x38ce
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x38cc
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0x38ce
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x38ce