// File: /workspace/github_c_makefile_star2_O1/TurkeyMcMac[P]ts3d/src/json.c
// Function: json_read_item
int json_read_item(json_reader *reader, struct json_item *result)
{
	if (has_error(reader)) goto error;
	result->type = JSON_EMPTY;
	result->key.len = 0;
	result->key.bytes = NULL;
	if (!is_in_range(reader)) {
		if (reader->flags & SOURCE_DEPLETED) {
			if (((reader->flags & SMALL_STACK) != 0
					&& reader->stack.small.size == 0)
				|| ((reader->flags & SMALL_STACK) == 0
					&& reader->stack.big.size == 0))
			{
				/* All brackets have been closed. */
				return 0;
			} else {
				set_error(reader, JSON_ERROR_BRACKETS);
				goto error;
			}
		} else if (refill(reader)) {
			goto error;
		}
	}
	switch (peek_frame(reader)) {
	case FRAME_EMPTY:
		if (skip_spaces(reader)) goto error;
		if (is_in_range(reader) && parse_value(reader, result))
			goto error;
		return 0;
	case FRAME_LIST:
		if (skip_spaces(reader)) goto error;
		if (reader->flags & STARTED_COMPOUND) {
			if (try_compound_end(reader, ']', JSON_END_LIST,
				result)) goto error;
			reader->flags &= ~STARTED_COMPOUND;
		} else {
			if (parse_after_elem(reader, ']', JSON_END_LIST,
				result)) goto error;
		}
		if (result->type == JSON_END_LIST) return 0;
		(void)(
			skip_spaces(reader) ||
			parse_value(reader, result)
		);
		break;
	case FRAME_MAP:
		if (skip_spaces(reader)) goto error;
		if (reader->flags & STARTED_COMPOUND) {
			if (try_compound_end(reader, '}', JSON_END_MAP,result))
				goto error;
			reader->flags &= ~STARTED_COMPOUND;
		} else {
			if (parse_after_elem(reader, '}', JSON_END_MAP, result))
				goto error;
		}
		if (result->type == JSON_END_MAP) return 0;
		(void)(
			skip_spaces(reader) ||
			parse_string(reader, &result->key) ||
			skip_spaces(reader) ||
			parse_colon(reader) ||
			skip_spaces(reader) ||
			parse_value(reader, result)
		);
		break;
	}
	if (has_error(reader)) goto error;
	return 0;

error:
	json_get_last_error(reader, &result->type, &result->val.erridx);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0x58(%rdi), %eax
testb %al, %al
je 0x56df
movzbl 0x58(%r14), %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x56d8
movq 0x38(%r14), %rcx
movq %rcx, 0x18(%rbx)
movl %eax, 0x10(%rbx)
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movq 0x38(%r14), %rcx
cmpq 0x28(%r14), %rcx
jae 0x5712
testb $0x4, 0x59(%r14)
jne 0x5726
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x576c
movq 0x40(%r14), %rcx
addq %rcx, %rax
decq %rax
jmp 0x5739
btl $0x8, %eax
jb 0x573e
movq %r14, %rdi
callq 0x58fd
testl %eax, %eax
jne 0x56bf
jmp 0x56f6
movzbl 0x57(%r14), %eax
testq %rax, %rax
je 0x576c
decl %eax
addq %r14, %rax
addq $0x40, %rax
movsbl (%rax), %eax
jmp 0x576e
btl $0xa, %eax
jae 0x5755
cmpb $0x0, 0x57(%r14)
je 0x58f6
btl $0xa, %eax
jb 0x5760
cmpq $0x0, 0x48(%r14)
je 0x58f6
orl $0xe, %eax
movl %eax, 0x58(%r14)
jmp 0x56bf
xorl %eax, %eax
cmpl $0x2, %eax
je 0x57ee
cmpl $0x1, %eax
je 0x57b8
testl %eax, %eax
jne 0x58eb
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x56bf
movq 0x38(%r14), %rax
xorl %ebp, %ebp
cmpq 0x28(%r14), %rax
jae 0x56d8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59c9
testl %eax, %eax
jne 0x56bf
jmp 0x56d8
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x56bf
testb $0x2, 0x59(%r14)
jne 0x5824
movq %r14, %rdi
movl $0x5d, %esi
movl $0x5, %edx
movq %rbx, %rcx
callq 0x5ee6
testl %eax, %eax
jne 0x56bf
jmp 0x5846
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x56bf
testb $0x2, 0x59(%r14)
jne 0x586d
movq %r14, %rdi
movl $0x7d, %esi
movl $0x3, %edx
movq %rbx, %rcx
callq 0x5ee6
testl %eax, %eax
jne 0x56bf
jmp 0x588f
movq %r14, %rdi
movl $0x5d, %esi
movl $0x5, %edx
movq %rbx, %rcx
callq 0x5e9e
testl %eax, %eax
jne 0x56bf
andb $-0x3, 0x59(%r14)
cmpl $0x5, 0x10(%rbx)
je 0x58f6
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x58eb
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59c9
jmp 0x58eb
movq %r14, %rdi
movl $0x7d, %esi
movl $0x3, %edx
movq %rbx, %rcx
callq 0x5e9e
testl %eax, %eax
jne 0x56bf
andb $-0x3, 0x59(%r14)
cmpl $0x3, 0x10(%rbx)
je 0x58f6
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x58eb
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5f45
testl %eax, %eax
jne 0x58eb
movq %r14, %rdi
callq 0x5959
testl %eax, %eax
jne 0x58eb
movq 0x20(%r14), %rax
movq 0x38(%r14), %rcx
movb (%rax,%rcx), %al
cmpb $0x3a, %al
jne 0x58d4
incq %rcx
movq %rcx, 0x38(%r14)
jmp 0x58e3
movl 0x58(%r14), %ecx
testb %cl, %cl
jne 0x58e3
orl $0xd, %ecx
movl %ecx, 0x58(%r14)
cmpb $0x3a, %al
je 0x5850
cmpb $0x0, 0x58(%r14)
jne 0x56bf
xorl %ebp, %ebp
jmp 0x56d8