// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/json.c
// Function: escape_char
static int escape_char(json_reader *reader, struct json_string *str,
	size_t *cap)
{
	/* Whether an extra hex-escaped codepoint was read which did not match
	 * the proceeding high surrogate: */
	int read_extra_cp = 0;
	/* Whether an extra non-hex escape was read: */
	int read_extra_escape = 0;
	/* The UTF-16 code units read (up to 2 are possible): */
	long utf16[2] = {-1, -1};
	/* The unicode codepoint if one was read, possibly from a surrogate
	 * pair: */
	long codepoint;
	/* The extra unpaired codepoint if it was read (-1 otherwise): */
	long extracp = -1;
	/* The UTF-8 version of a codepoint if it was read: */
	char utf8[4];
	/* The buffer of hex digits: */
	char buf[4];
	/* The amount some call to next_chars read: */
	long read;
	int ch = next_char(reader);
	if (ch < 0) goto error;
	switch (ch) {
	case 'b': ch = '\b'; break;
	case 'f': ch = '\f'; break;
	case 'n': ch = '\n'; break;
	case 'r': ch = '\r'; break;
	case 't': ch = '\t'; break;
	case '"': ch =  '"'; break;
	case'\\':/*Same as */break;
	case '/':/*escaped.*/break;
	case 'u':
		read = next_chars(reader, buf, 4);
		if (read < 4) goto error;
		utf16[0] = hex_short(buf);
		if (utf16[0] < 0) goto error;
		codepoint = utf16_to_codepoint(utf16[0]);
		if (is_high_surrogate(utf16[0])) {
			/* It wants a partner. */
			NEXT_CHAR(reader, ch, goto error);
			if (ch != '\\') {
				/* No partner; only normal chars were found: */
				reexamine_char(reader);
			} else {
				/* Escape follows. */
				NEXT_CHAR(reader, ch, goto error);
				if (ch == 'u') {
					/* Hex escape follows. */
					read = next_chars(reader, buf,
						4);
					if (read < 0) goto error;
					if (read < 4) goto error;
					utf16[1] = hex_short(buf);
					if (utf16[1] < 0) goto error;
					if (is_low_surrogate(utf16[1])) {
						/* Partner found. */
						codepoint =
							utf16_pair_to_codepoint(
							utf16[0], utf16[1]);
					} else {
						/* Extra codepoint found. */
						read_extra_cp = 1;
						extracp = utf16_to_codepoint(
								utf16[1]);
					}
				} else {
					/* Extra other escape was found, will be
					 * parsed below. (read_extra_escape) */
					reexamine_char(reader);
					read_extra_escape = 1;
				}
			}
		}
		if (push_bytes(reader, &str->bytes, &str->len, cap,
			utf8, codepoint_to_utf8(codepoint, utf8))) goto error;
		if (read_extra_cp) {
			if (push_bytes(reader, &str->bytes, &str->len, cap,
					utf8, codepoint_to_utf8(extracp, utf8)))
				goto error;
		} else if (read_extra_escape) {
			/* This will only every recurse once, since this can
			 * only occur for \uXXXX, but that is handled non-
			 * recursively. */
			if (escape_char(reader, str, cap)) goto error;
		}
		return 0;
	default:
		goto error;
	}
	if (push_byte(reader, &str->bytes, &str->len, cap, ch)) goto error;
	return 0;

error:
	set_error(reader, JSON_ERROR_ESCAPE);
	reexamine_char(reader);
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x87b4(%rip), %rax      # 0x11690
movq %rax, -0x40(%rbp)
movq 0x87b1(%rip), %rax      # 0x11698
movq %rax, -0x38(%rbp)
movq $-0x1, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x83e0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0x8f0a
jmp 0x921c
movl -0x64(%rbp), %eax
addl $-0x22, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x53, %eax
ja 0x91ed
movq -0x70(%rbp), %rax
leaq 0x8606(%rip), %rcx      # 0x11530
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x8, -0x64(%rbp)
jmp 0x91ef
movl $0xc, -0x64(%rbp)
jmp 0x91ef
movl $0xa, -0x64(%rbp)
jmp 0x91ef
movl $0xd, -0x64(%rbp)
jmp 0x91ef
movl $0x9, -0x64(%rbp)
jmp 0x91ef
movl $0x22, -0x64(%rbp)
jmp 0x91ef
jmp 0x91ef
jmp 0x91ef
movq -0x10(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x4, %edx
callq 0x88a0
movq %rax, -0x60(%rbp)
cmpq $0x4, -0x60(%rbp)
jge 0x8fa7
jmp 0x921c
leaq -0x58(%rbp), %rdi
callq 0x9250
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jge 0x8fc0
jmp 0x921c
movq -0x40(%rbp), %rax
movl %eax, %edi
callq 0x9320
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movl %eax, %edi
callq 0x9330
cmpl $0x0, %eax
je 0x90cf
jmp 0x8fe5
movq -0x10(%rbp), %rdi
callq 0x83e0
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jge 0x8ffb
jmp 0x921c
jmp 0x8ffd
cmpl $0x5c, -0x64(%rbp)
je 0x9011
movq -0x10(%rbp), %rdi
callq 0x8620
jmp 0x90cd
jmp 0x9013
movq -0x10(%rbp), %rdi
callq 0x83e0
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jge 0x9029
jmp 0x921c
jmp 0x902b
cmpl $0x75, -0x64(%rbp)
jne 0x90bb
movq -0x10(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x4, %edx
callq 0x88a0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jge 0x9057
jmp 0x921c
cmpq $0x4, -0x60(%rbp)
jge 0x9063
jmp 0x921c
leaq -0x58(%rbp), %rdi
callq 0x9250
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0x907c
jmp 0x921c
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x9350
cmpl $0x0, %eax
je 0x90a3
movq -0x40(%rbp), %rax
movl %eax, %edi
movq -0x38(%rbp), %rax
movl %eax, %esi
callq 0x9370
movq %rax, -0x48(%rbp)
jmp 0x90b9
movl $0x1, -0x24(%rbp)
movq -0x38(%rbp), %rax
movl %eax, %edi
callq 0x9320
movq %rax, -0x50(%rbp)
jmp 0x90cb
movq -0x10(%rbp), %rdi
callq 0x8620
movl $0x1, -0x28(%rbp)
jmp 0x90cd
jmp 0x90cf
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x54(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x9480
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rcx
movq -0x78(%rbp), %r8
movq %rax, %r9
callq 0x93a0
cmpl $0x0, %eax
je 0x9140
jmp 0x921c
cmpl $0x0, -0x24(%rbp)
je 0x91c2
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x54(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x9480
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq -0xa8(%rbp), %rcx
movq -0xa0(%rbp), %r8
movq %rax, %r9
callq 0x93a0
cmpl $0x0, %eax
je 0x91c0
jmp 0x921c
jmp 0x91e4
cmpl $0x0, -0x28(%rbp)
je 0x91e2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x8eb0
cmpl $0x0, %eax
je 0x91e0
jmp 0x921c
jmp 0x91e2
jmp 0x91e4
movl $0x0, -0x4(%rbp)
jmp 0x923a
jmp 0x921c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
movl -0x64(%rbp), %r8d
callq 0x87d0
cmpl $0x0, %eax
je 0x9213
jmp 0x921c
movl $0x0, -0x4(%rbp)
jmp 0x923a
movq -0x10(%rbp), %rdi
movl $0x10, %esi
callq 0x7d30
movq -0x10(%rbp), %rdi
callq 0x8620
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)