// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movl $0x1, 0x24(%rsp)
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rcx), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x4753
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rcx), %ecx
movb (%rax,%rcx), %al
movb %al, 0x17(%rsp)
movsbl 0x17(%rsp), %eax
addl $-0x9, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x74, %eax
ja 0x4733
movq 0x8(%rsp), %rax
leaq 0x3b51(%rip), %rcx      # 0x8000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl 0x34(%rsp), %eax
movl %eax, %edx
callq 0x4890
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x44e7
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x4883
movq 0x18(%rsp), %rax
movb 0x10(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x10(%rax)
movq 0x48(%rsp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x4531
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq 0x48(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x18(%rax)
movsbl 0x17(%rsp), %edx
movl $0x2, %ecx
movl $0x1, %eax
cmpl $0x7b, %edx
cmovel %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
movq 0x48(%rsp), %rax
movl (%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x48(%rsp), %rax
movl 0x4(%rax), %ecx
subl $0x1, %ecx
movq 0x48(%rsp), %rax
movl %ecx, 0x8(%rax)
movl $0x1, 0x24(%rsp)
jmp 0x4740
movsbl 0x17(%rsp), %edx
movl $0x2, %eax
movl $0x1, %ecx
cmpl $0x7d, %edx
cmovel %ecx, %eax
movl %eax, 0x10(%rsp)
movq 0x48(%rsp), %rax
cmpl $0x1, 0x4(%rax)
jge 0x45ad
movl $0xfffffffe, 0x54(%rsp) # imm = 0xFFFFFFFE
jmp 0x4883
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpl $-0x1, 0x4(%rax)
je 0x4620
movq 0x18(%rsp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x4620
movq 0x18(%rsp), %rax
movl (%rax), %eax
cmpl 0x10(%rsp), %eax
je 0x45fc
movl $0xfffffffe, 0x54(%rsp) # imm = 0xFFFFFFFE
jmp 0x4883
movq 0x48(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x48(%rsp), %rax
movl %ecx, 0x8(%rax)
jmp 0x4649
movq 0x18(%rsp), %rax
cmpl $-0x1, 0x18(%rax)
jne 0x462d
jmp 0x4649
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movslq 0x18(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
jmp 0x45cc
movl $0x1, 0x24(%rsp)
jmp 0x4740
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdx
movl 0x24(%rsp), %ecx
movl 0x34(%rsp), %eax
movl %eax, %r8d
callq 0x4940
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
jge 0x468d
movl 0x30(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x4883
movq 0x48(%rsp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x46b6
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x4740
movl $0x0, 0x24(%rsp)
jmp 0x4740
movl $0x1, 0x24(%rsp)
jmp 0x4740
jmp 0x4740
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdx
movl 0x24(%rsp), %ecx
movl 0x34(%rsp), %eax
movl %eax, %r8d
callq 0x4ac0
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x30(%rsp)
jge 0x4708
movl 0x30(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x4883
movq 0x48(%rsp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x4731
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x4740
movl $0xfffffffe, 0x54(%rsp) # imm = 0xFFFFFFFE
jmp 0x4883
jmp 0x4742
movq 0x48(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x445f
movq 0x48(%rsp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
jl 0x487b
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x4(%rax)
je 0x47a8
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
jne 0x47a8
movl $0xfffffffd, 0x54(%rsp) # imm = 0xFFFFFFFD
jmp 0x4883
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
je 0x47d8
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x4869
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, 0x28(%rsp)
cmpl $-0x1, 0x28(%rsp)
je 0x4867
movq 0x38(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq 0x38(%rsp), %rax
movslq 0x28(%rsp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movq 0x38(%rsp), %rax
movslq 0x28(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, 0x28(%rsp)
jmp 0x481b
jmp 0x4869
jmp 0x486b
movl 0x2c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x4762
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)