// File: /workspace/github_c_makefile_star2_O3/dalnefre[P]kernel_abe/emit.c
// Function: str_to_cons
CONS*
str_to_cons(char* in)
{
	int state = 1;
	int c;
	char* tk;
	int n;
	CONS* out = NIL;
	char buf[256];
	
	XDBUG_ENTER("str_to_cons");
	assert(in != NULL);
	strncpy(buf, "", sizeof(buf));
	tk = in;
	XDBUG_PRINT("", ("in=%s", in));
	while (state) {
		c = *in;			/* get character */
		XDBUG_PRINT("", ("state=%d c=%d", state, c));
		XDBUG_PRINT("", ("in=%s", in));
		XDBUG_PRINT("", ("tk=%s", tk));
		switch (state) {
		case 1:				/* initial state (optional whitespace) */
			if (c == '\0') {
				state = -1;		/* fail */
			} else if (isspace(c)) {
				state = 1;
			} else if (isdigit(c) || (c == '-')) {
				tk = in;
				n = ((c == '-') ? 0 : (c - '0'));
				state = 2;
			} else if (isprint(c) && !is_reserved(c)) {
				tk = in;
				state = 3;
			} else if (c == '"') {
				tk = in;
				state = 4;
			} else if (c == '(') {
				CONS* q = cons(NIL, NIL);
				CONS* p = NIL;

				XDBUG_PRINT("", ("list begin"));
				++in;		/* consume character */
				for (;;) {
					while (isspace((int)(*in))) {
						++in;		/* consume character */
					}
					if (*in == ')') {
						++in;		/* consume character */
						XDBUG_PRINT("", ("list end"));
						break;
					} else if (*in == ':') {
						XDBUG_PRINT("", ("pair split"));
						++in;		/* consume character */
						p = str_to_cons(in);
						if (p == NULL) {
							break;
						}
						CQ_PUT(q, p);
						in = nextptr;
						while (isspace((int)(*in))) {
							++in;		/* consume character */
						}
						if (*in == ')') {
							++in;		/* consume character */
							XDBUG_PRINT("", ("pair end"));
							break;
						} else {
							p = NULL;
							break;
						}
					}
					p = str_to_cons(in);
					if (p == NULL) {
						break;
					}
					CQ_PUT(q, cons(p, NIL));
					in = nextptr;
				}
				out = CQ_PEEK(q);
				state = ((p == NULL) ? -1 : 0);		/* done */
			} else if (c == '\'') {
				CONS* p;

				XDBUG_PRINT("", ("quoted literal"));
				++in;		/* consume character */
				p = str_to_cons(in);
				if (p != NULL) {
					out = cons(ATOM("literal"), cons(p, NIL));
					in = nextptr;
					state = 0;		/* done */
				} else {
					state = -1;		/* fail */
				}
			} else {
				state = -1;		/* fail */
			}
			break;
		case 2:				/* numeric token */
			if ((c == '\0') || isspace(c) || is_reserved(c)) {
				if (*tk == '-') {
					if ((in - tk) > 1) {
						n = -n;
					} else {
						--in;		/* push back charactrer */
						state = 3;	/* re-interpret as an atom */
						break;
					}
				}
				out = NUMBER(n);
				state = 0;		/* done */
			} else if (isdigit(c)) {
				n = (n * 10) + (c - '0');
				state = 2;
			} else if (isprint(c)) {
				state = 3;
			} else {
				state = -1;		/* fail */
			}
			break;
		case 3:				/* atomic token */
			if ((c == '\0') || isspace(c) || is_reserved(c)) {
				if ((in - tk) < sizeof(buf)) {
					strncpy(buf, tk, (in - tk));
					XDBUG_PRINT("", ("ATOM(%s) c=%d", buf, c));
					out = ATOM(buf);
					if (out == ATOM("NIL")) {
						out = NIL;
					}
					state = 0;		/* done */
				} else {
					DBUG_PRINT("", ("token buffer overflow! %d >= %d", (in - tk), sizeof(buf)));
					state = -1;
				}
			} else if (isprint(c)) {
				state = 3;
			} else {
				state = -1;		/* fail */
			}
			break;
		case 4:				/* quoted token */
			if ((c == '\0') || !isprint(c)) {
				state = -1;		/* fail */
			} else if (c == '"') {
				if (*tk != '"') {
					state = -1;
				} else if ((in - tk) < sizeof(buf)) {
					++tk;	/* skip leading quote */
					strncpy(buf, tk, (in - tk));
					XDBUG_PRINT("", ("ATOM(\"%s\") c=%d", buf, c));
					out = ATOM(buf);
					if (out == ATOM("NIL")) {
						out = NIL;
					}
					++in;	/* skip trailing quote */
					state = 0;		/* done */
				} else {
					DBUG_PRINT("", ("token buffer overflow! %d >= %d", (in - tk), sizeof(buf)));
					state = -1;
				}
			} else {
				state = 4;
			}
			break;
		default:
			DBUG_PRINT("", ("PARSE FAIL -->%s", in));
			TRACE(printf("PARSE FAIL -->%s\n", in));
			XDBUG_RETURN NULL;	/* parse error */
		}
		if (state >= 0) {
			nextptr = in;
			++in;				/* move to next character */
		}
	}
	XDBUG_PRINT("", ("out=%s", cons_to_str(out)));
	XDBUG_PRINT("", ("next=%s", nextptr));
	XDBUG_RETURN out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
testq %rdi, %rdi
je 0x15c49
movq %rdi, %r12
leaq 0x20(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2110
movl $0x1, %r15d
leaq 0xdbff(%rip), %rax      # 0x232a0
leaq 0x7a88(%rip), %rbx      # 0x1d130
movq %rax, 0x8(%rsp)
movq %rax, 0x18(%rsp)
movq %r12, 0x10(%rsp)
decl %r15d
cmpl $0x3, %r15d
ja 0x15bcb
movsbl (%r12), %r13d
movslq %r13d, %rbp
movslq (%rbx,%r15,4), %rax
addq %rbx, %rax
jmpq *%rax
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x159b9
callq 0x2260
movq %rax, %r14
movq (%rax), %rax
movzwl (%rax,%rbp,2), %ecx
movl $0x1, %eax
btl $0xd, %ecx
jb 0x159ac
btl $0xb, %ecx
jb 0x15a30
cmpb $0x2d, %bpl
je 0x15a30
btl $0xe, %ecx
jae 0x15741
cmpb $0x27, %bpl
je 0x15741
cmpb $0x22, %bpl
je 0x15741
cmpb $0x3a, %bpl
je 0x15741
andb $-0x2, %r13b
movl $0x3, %eax
cmpb $0x28, %r13b
jne 0x15a4b
movl $0x4, %eax
cmpb $0x22, %bpl
je 0x15a4b
cmpb $0x28, %bpl
jne 0x15adc
leaq 0xdb3f(%rip), %rdi      # 0x232a0
movq %rdi, %rsi
callq 0x19c50
movq %rax, %rbp
incq %r12
movq (%r14), %rax
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x15772
movzbl %cl, %eax
cmpl $0x29, %eax
je 0x15b6f
cmpl $0x3a, %eax
je 0x15b39
decq %r12
movq %r12, %rdi
callq 0x15666
testq %rax, %rax
je 0x15bb9
movq %rax, %r13
movq %rbp, %rdi
callq 0x19c72
leaq 0xdae4(%rip), %r12      # 0x232a0
cmpq %r12, %rax
je 0x157e4
movq %rbp, %rdi
callq 0x19d11
movq %r12, %rsi
movq %rax, %r12
movq %r13, %rdi
callq 0x19c50
movq %r12, %rdi
movq %rax, %rsi
callq 0x19dbe
jmp 0x157fa
movq %r13, %rdi
movq %r12, %rsi
callq 0x19c50
movq %rbp, %rdi
movq %rax, %rsi
callq 0x19db0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x19dbe
movq 0xdff4(%rip), %r12      # 0x23800
jmp 0x1576f
testb %bpl, %bpl
je 0x1584a
callq 0x2260
movq (%rax), %rax
movzwl (%rax,%rbp,2), %ecx
btl $0xd, %ecx
jb 0x1584a
cmpb $0x3a, %r13b
ja 0x15a5b
movzbl %r13b, %eax
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rax, %rdx
jae 0x15a5b
movq %r12, %r14
movq 0x10(%rsp), %rsi
subq %rsi, %r14
cmpq $0xff, %r14
ja 0x159c7
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x2070
movq %r15, %rdi
callq 0x170ff
movq %rax, %r14
leaq 0x8c05(%rip), %rdi      # 0x1e489
callq 0x170ff
cmpq %rax, %r14
jne 0x15895
leaq 0xda0b(%rip), %r14      # 0x232a0
movq %r14, 0x8(%rsp)
jmp 0x159aa
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x159b9
callq 0x2260
movq (%rax), %rax
testb $0x40, 0x1(%rax,%rbp,2)
je 0x159b9
movl $0x4, %eax
cmpb $0x22, %r13b
jne 0x159ac
movq 0x10(%rsp), %rsi
cmpb $0x22, (%rsi)
jne 0x159b9
movq %r12, %r14
subq %rsi, %r14
cmpq $0xff, %r14
ja 0x15a75
incq %rsi
movq %r12, %rdx
subq %rsi, %rdx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x10(%rsp)
callq 0x2070
movq %r14, %rdi
callq 0x170ff
movq %rax, %r14
leaq 0x8b6b(%rip), %rdi      # 0x1e489
callq 0x170ff
cmpq %rax, %r14
jne 0x1592f
leaq 0xd971(%rip), %r14      # 0x232a0
movq %r14, 0x8(%rsp)
incq %r12
jmp 0x159aa
testb %bpl, %bpl
je 0x15972
callq 0x2260
movq (%rax), %rax
movzwl (%rax,%rbp,2), %ecx
btl $0xd, %ecx
jb 0x15972
cmpb $0x3a, %bpl
ja 0x15a55
movzbl %bpl, %eax
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rax, %rdx
jae 0x15a55
movq 0x10(%rsp), %rcx
cmpb $0x2d, (%rcx)
jne 0x15998
movq %r12, %rax
subq %rcx, %rax
cmpq $0x2, %rax
jl 0x15a23
movq 0x18(%rsp), %rax
negl %eax
movq %rax, 0x18(%rsp)
movslq 0x18(%rsp), %rax
leaq 0x3(,%rax,4), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq %r12, 0xde4d(%rip)      # 0x23800
incq %r12
movl %eax, %r15d
testl %r15d, %r15d
jne 0x156b7
jmp 0x15c32
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0xdf5c(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
je 0x159b9
leaq 0xd950(%rip), %r13      # 0x23330
movq (%r13), %rax
movq 0x50(%rax), %rax
leaq 0x695b(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b188
testl %eax, %eax
je 0x159b9
movq (%r13), %rax
movq 0x50(%rax), %rax
movl $0x25a, 0xc(%rax)       # imm = 0x25A
movl $0x100, %edx            # imm = 0x100
leaq 0x7cbc(%rip), %rdi      # 0x1d6d3
movq %r14, %rsi
xorl %eax, %eax
callq 0x1ba97
jmp 0x159b9
decq %r12
movl $0x3, %eax
jmp 0x159ac
addl $-0x30, %r13d
cmpb $0x2d, %bpl
movl $0x0, %eax
cmovel %eax, %r13d
movl $0x2, %eax
movq %r13, 0x18(%rsp)
movq %r12, 0x10(%rsp)
jmp 0x159ac
btl $0xb, %ecx
jb 0x15ac0
movl $0x3, %eax
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
btl $0xe, %ecx
jb 0x159ac
jmp 0x159b9
leaq 0xdeb4(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
je 0x159b9
leaq 0xd8a4(%rip), %r13      # 0x23330
movq (%r13), %rax
movq 0x50(%rax), %rax
leaq 0x68af(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b188
testl %eax, %eax
je 0x159b9
movq (%r13), %rax
movq 0x50(%rax), %rax
movl $0x274, 0xc(%rax)       # imm = 0x274
jmp 0x15a0b
movq 0x18(%rsp), %rax
leal (%rax,%rax,4), %eax
leal -0x30(%r13,%rax,2), %eax
movq %rax, 0x18(%rsp)
movl $0x2, %eax
jmp 0x159ac
cmpb $0x27, %bpl
jne 0x159b9
incq %r12
movq %r12, %rdi
callq 0x15666
testq %rax, %rax
je 0x159b9
movq %rax, %r14
leaq 0x7bc7(%rip), %rdi      # 0x1d6cb
callq 0x170ff
movq %rax, %r15
movq %r14, %rdi
leaq 0xd78a(%rip), %rsi      # 0x232a0
callq 0x19c50
movq %r15, %rdi
movq %rax, %rsi
callq 0x19c50
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq 0xdccc(%rip), %r12      # 0x23800
jmp 0x159ac
movq %r12, %rdi
callq 0x15666
testq %rax, %rax
je 0x15bb9
movq %rax, %r13
movq %rbp, %rdi
callq 0x19c72
movq %rbp, %rdi
cmpq 0xd465(%rip), %rax      # 0x22fc0
je 0x15b74
callq 0x19d11
movq %rax, %rdi
movq %r13, %rsi
callq 0x19dbe
jmp 0x15b7c
decq %r12
jmp 0x15ba9
movq %r13, %rsi
callq 0x19db0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x19dbe
movq 0xdc72(%rip), %r12      # 0x23800
movq (%r14), %rax
decq %r12
movsbq 0x1(%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x15b94
cmpb $0x29, %cl
jne 0x15bb9
incq %r12
movq %rbp, %rdi
callq 0x19c72
jmp 0x159a5
movq %rbp, %rdi
callq 0x19c72
movq %rax, 0x8(%rsp)
jmp 0x159b9
leaq 0xdd5e(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
leaq 0xd754(%rip), %rbx      # 0x23330
je 0x15c18
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0x675e(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b188
testl %eax, %eax
je 0x15c18
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0x27c, 0xc(%rax)       # imm = 0x27C
leaq 0x7ae5(%rip), %rdi      # 0x1d6f3
movq %r12, %rsi
xorl %eax, %eax
callq 0x1ba97
leaq 0x7ae5(%rip), %rdi      # 0x1d704
movq $0x0, 0x8(%rsp)
movq %r12, %rsi
xorl %eax, %eax
callq 0x20e0
movq 0x8(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7a56(%rip), %rdi      # 0x1d6a6
leaq 0x751d(%rip), %rsi      # 0x1d174
leaq 0x7a53(%rip), %rcx      # 0x1d6b1
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x2100