// File: /workspace/github_c_makefile_star2_O1/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 0x15bd2
movq %rdi, %r12
leaq 0x20(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2110
movl $0x1, %r13d
leaq 0xdcb8(%rip), %rax      # 0x232a0
leaq 0x7b41(%rip), %rbx      # 0x1d130
movq %rax, 0x8(%rsp)
movq %rax, 0x18(%rsp)
movq %r12, 0x10(%rsp)
decl %r13d
cmpl $0x3, %r13d
ja 0x15b54
movsbl (%r12), %r15d
movslq %r15d, %rbp
movslq (%rbx,%r13,4), %rax
addq %rbx, %rax
jmpq *%rax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x15b3a
callq 0x2260
movq %rax, %r14
movq (%rax), %rax
movzwl (%rax,%rbp,2), %eax
btl $0xd, %eax
jb 0x1589a
btl $0xb, %eax
jb 0x158b3
cmpb $0x2d, %bpl
je 0x158b3
btl $0xe, %eax
jae 0x158e4
cmpb $0x27, %bpl
je 0x158e4
cmpb $0x22, %bpl
je 0x158e4
cmpb $0x3a, %bpl
je 0x158e4
andb $-0x2, %r15b
cmpb $0x28, %r15b
je 0x158e4
movl $0x3, %r13d
jmp 0x158f0
testb %bpl, %bpl
je 0x156d2
callq 0x2260
movq (%rax), %rax
movzwl (%rax,%rbp,2), %eax
btl $0xd, %eax
jb 0x156d2
cmpb $0x3a, %r15b
ja 0x15904
movzbl %r15b, %ecx
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rcx, %rdx
jae 0x15904
movq %r12, %r14
movq 0x10(%rsp), %rsi
subq %rsi, %r14
cmpq $0xff, %r14
ja 0x15835
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x2070
movq %r15, %rdi
callq 0x1707c
movq %rax, %r14
leaq 0x8d7d(%rip), %rdi      # 0x1e489
callq 0x1707c
cmpq %rax, %r14
jne 0x1571d
leaq 0xdb83(%rip), %r14      # 0x232a0
movq %r14, 0x8(%rsp)
jmp 0x1582d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x15b3a
callq 0x2260
movq (%rax), %rax
testb $0x40, 0x1(%rax,%rbp,2)
je 0x15b3a
cmpb $0x22, %r15b
jne 0x158d9
movq 0x10(%rsp), %rsi
cmpb $0x22, (%rsi)
jne 0x15b3a
movq %r12, %r14
subq %rsi, %r14
cmpq $0xff, %r14
ja 0x1591b
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 0x1707c
movq %rax, %r14
leaq 0x8ce8(%rip), %rdi      # 0x1e489
callq 0x1707c
cmpq %rax, %r14
jne 0x157b2
leaq 0xdaee(%rip), %r14      # 0x232a0
movq %r14, 0x8(%rsp)
incq %r12
jmp 0x1582d
testb %bpl, %bpl
je 0x157f5
callq 0x2260
movq (%rax), %rax
movzwl (%rax,%rbp,2), %eax
btl $0xd, %eax
jb 0x157f5
cmpb $0x3a, %bpl
ja 0x158fa
movzbl %bpl, %ecx
movabsq $0x400038400000000, %rdx # imm = 0x400038400000000
btq %rcx, %rdx
jae 0x158fa
movq 0x10(%rsp), %rcx
cmpb $0x2d, (%rcx)
jne 0x1581b
movq %r12, %rax
subq %rcx, %rax
cmpq $0x2, %rax
jl 0x158a5
movq 0x18(%rsp), %rax
negl %eax
movq %rax, 0x18(%rsp)
movslq 0x18(%rsp), %rax
leaq 0x3(,%rax,4), %rax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
jmp 0x15b3a
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
leaq 0xe0ee(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
je 0x15b3a
leaq 0xdade(%rip), %r15      # 0x23330
movq (%r15), %rax
movq 0x50(%rax), %rax
leaq 0x6aea(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b084
testl %eax, %eax
je 0x15b3a
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x25a, 0xc(%rax)       # imm = 0x25A
movl $0x100, %edx            # imm = 0x100
leaq 0x7e48(%rip), %rdi      # 0x1d6d3
movq %r14, %rsi
xorl %eax, %eax
callq 0x1b983
jmp 0x15b3a
movl $0x1, %r13d
jmp 0x15b3a
decq %r12
movl $0x3, %r13d
jmp 0x15b3a
addl $-0x30, %r15d
cmpb $0x2d, %bpl
movl $0x0, %eax
cmovel %eax, %r15d
movl $0x2, %r13d
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
jmp 0x15b3a
movl $0x4, %r13d
jmp 0x15b3a
cmpb $0x22, %bpl
jne 0x15964
movl $0x4, %r13d
movq %r12, 0x10(%rsp)
jmp 0x15b3a
btl $0xb, %eax
jb 0x15a25
btl $0xe, %eax
movl $0x0, %r13d
adcl $-0x1, %r13d
orl $0x3, %r13d
jmp 0x15b3a
leaq 0xe00e(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
je 0x15b3a
leaq 0xd9fe(%rip), %r15      # 0x23330
movq (%r15), %rax
movq 0x50(%rax), %rax
leaq 0x6a0a(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b084
testl %eax, %eax
je 0x15b3a
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x274, 0xc(%rax)       # imm = 0x274
jmp 0x1587f
cmpb $0x28, %bpl
jne 0x15a44
leaq 0xd92b(%rip), %rdi      # 0x232a0
movq %rdi, %rsi
callq 0x19b84
movq %rax, %r15
incq %r12
movq (%r14), %rax
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x15986
movzbl %cl, %eax
cmpl $0x3a, %eax
je 0x15aaa
cmpl $0x29, %eax
je 0x15aa2
decq %r12
movq %r12, %rdi
callq 0x155ad
testq %rax, %rax
je 0x15ae0
movq %rax, %r13
movq %r15, %rdi
callq 0x19ba6
leaq 0xd8d0(%rip), %r12      # 0x232a0
cmpq %r12, %rax
je 0x159f8
movq %r15, %rdi
callq 0x19c45
movq %r12, %rsi
movq %rax, %r12
movq %r13, %rdi
callq 0x19b84
movq %r12, %rdi
movq %rax, %rsi
callq 0x19cf2
jmp 0x15a0e
movq %r13, %rdi
movq %r12, %rsi
callq 0x19b84
movq %r15, %rdi
movq %rax, %rsi
callq 0x19ce4
movq %r15, %rdi
movq %rax, %rsi
callq 0x19cf2
movq 0xdde0(%rip), %r12      # 0x23800
jmp 0x15983
movq 0x18(%rsp), %rax
leal (%rax,%rax,4), %eax
leal (%r15,%rax,2), %eax
addl $-0x30, %eax
movq %rax, 0x18(%rsp)
movl $0x2, %r13d
jmp 0x15b3a
cmpb $0x27, %bpl
jne 0x15b3a
incq %r12
movq %r12, %rdi
callq 0x155ad
testq %rax, %rax
je 0x15b3a
movq %rax, %r14
leaq 0x7c5f(%rip), %rdi      # 0x1d6cb
callq 0x1707c
movq %rax, %r15
movq %r14, %rdi
leaq 0xd822(%rip), %rsi      # 0x232a0
callq 0x19b84
movq %r15, %rdi
movq %rax, %rsi
callq 0x19b84
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
movq 0xdd63(%rip), %r12      # 0x23800
jmp 0x15b3a
xorl %r13d, %r13d
jmp 0x15b2d
movq %r12, %rdi
callq 0x155ad
testq %rax, %rax
je 0x15ae0
movq %rax, %r13
movq %r15, %rdi
callq 0x19ba6
movq %r15, %rdi
cmpq 0xd4f4(%rip), %rax      # 0x22fc0
je 0x15ae8
callq 0x19c45
movq %rax, %rdi
movq %r13, %rsi
callq 0x19cf2
jmp 0x15af0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x15b2d
movq %r13, %rsi
callq 0x19ce4
movq %r15, %rdi
movq %rax, %rsi
callq 0x19cf2
movq 0xdcfe(%rip), %r12      # 0x23800
movq (%r14), %rax
decq %r12
movsbq 0x1(%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x15b08
xorl %r13d, %r13d
xorl %eax, %eax
cmpb $0x29, %cl
setne %r13b
sete %al
addq %rax, %r12
negl %r13d
movq %r15, %rdi
callq 0x19ba6
movq %rax, 0x8(%rsp)
testl %r13d, %r13d
js 0x15b49
movq %r12, 0xdcba(%rip)      # 0x23800
incq %r12
testl %r13d, %r13d
jne 0x155fe
jmp 0x15bbb
leaq 0xddd5(%rip), %rax      # 0x23930
cmpl $0x0, (%rax)
leaq 0xd7cb(%rip), %rbx      # 0x23330
je 0x15ba1
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0x67d5(%rip), %rdi      # 0x1c34a
movq %rdi, 0x10(%rax)
callq 0x1b084
testl %eax, %eax
je 0x15ba1
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0x27c, 0xc(%rax)       # imm = 0x27C
leaq 0x7b5c(%rip), %rdi      # 0x1d6f3
movq %r12, %rsi
xorl %eax, %eax
callq 0x1b983
leaq 0x7b5c(%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 0x7acd(%rip), %rdi      # 0x1d6a6
leaq 0x7594(%rip), %rsi      # 0x1d174
leaq 0x7aca(%rip), %rcx      # 0x1d6b1
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x2100