// File: /workspace/github_c_makefile_star2_O3/eiselekd[P]MinimalLisp/lf.c
// Function: main
int
main(int argc, char **argv) 
{
    lfctx _cctx; struct lfctx *lfctx = &_cctx; ctx *lctx = (ctx *)&_cctx; 
    fctx *cctx = (fctx*)&_cctx; int c, i, l; FILE *f; char v[32]; struct v *list;
    struct v *fx = 0, *r; char *m = 0; int ml = 0, o;
    memset(&_cctx,0,sizeof(struct lfctx));
    
    atexit(colreset);
    signal(SIGINT, sigint);
    
    /* input */
    cctx->fc = -1;
    for (i = argc-1; i >= 1; i--) {
        l = strlen(argv[i]);
        if (argv[i][l-1] == 'f') {
            if (f = fopen(argv[i],"r")) {
                cctx->f[++cctx->fc] = f;
            }
        } else if (argv[i][l-1] == 'l') {
            FILE *f;
            if (argv[i] && (f = fopen(argv[i],"r"))) {
                o = ml;
                fseek(f, 0, SEEK_END); 
                ml += (l = ftell(f));
                fseek(f, 0, SEEK_SET);
                if (m) {
                    m = (char *)realloc(m,ml+1);
                } else {
                    m = (char *)malloc(ml+1);
                }
                fread(&m[o], 1, l, f);
                m[ml] = 0;
                fclose(f);
            }
        }
    }
    
    lf_init(&_cctx) ;
    
    r = mkCons(g_QUIT, 0);
    cctx->ip = r;
    fx = NEXT(cctx);
    
    FPRINTF(FDBG, "Compile Forth interpreter\n");
    while(fx) {
        fx = fop(fx)(cctx);
    }
    
    lf_remap(&_cctx);
    
    /* scan lisp program */
    if (!m)
        return 0;
    
    list = scan((ctx *)cctx, m);
    
    PUSH(list);
    
    printh ((ctx*)cctx, stdout, list);
    
    if (!(r = find(cctx, unique((ctx *)cctx, "evlist", 6)))) {
        return 0;
    }
    
    cctx->ip = mkCons(cdr(r), mkCons(g_END,0));
    fx = NEXT(cctx);
    EPUSH(lctx->env);
    
    FPRINTF(FDBG, "Execute Forth Lisp interpreter\n");
    /* execute lisp interpreter */
    while(fx) {
        fx = fop(fx)(cctx);
    }
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r13
movl %edi, %ebx
leaq -0x1c0(%rbp), %r12
xorl %r15d, %r15d
movl $0x188, %edx            # imm = 0x188
movq %r12, %rdi
xorl %esi, %esi
callq 0x2080
leaq -0x5e(%rip), %rdi       # 0xec40
callq 0xef80
leaq -0x75(%rip), %rsi       # 0xec35
movl $0x2, %edi
callq 0x20b0
movq $-0x1, 0x90(%r12)
cmpl $0x2, %ebx
jl 0xedd4
movl %ebx, %r14d
incq %r14
movq $-0x1, -0x30(%rbp)
xorl %ebx, %ebx
movq %r13, -0x38(%rbp)
movq -0x10(%r13,%r14,8), %r12
movq %r12, %rdi
callq 0x2060
decl %eax
cltq
movzbl (%r12,%rax), %eax
cmpl $0x6c, %eax
je 0xed39
cmpl $0x66, %eax
jne 0xedc5
movq %r12, %rdi
leaq 0x5ed(%rip), %rsi       # 0xf2f8
callq 0x2160
testq %rax, %rax
je 0xedc5
movq -0x30(%rbp), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, -0x130(%rbp)
movq %rax, -0x1a8(%rbp,%rdx,8)
movq %rcx, -0x30(%rbp)
jmp 0xedc5
movq %r12, %rdi
leaq 0x5b5(%rip), %rsi       # 0xf2f8
callq 0x2160
testq %rax, %rax
je 0xedc5
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2140
movq %r12, %rdi
callq 0x20d0
movq %rax, %r13
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2140
leal (%r15,%r13), %eax
incl %eax
movslq %eax, %rsi
testq %rbx, %rbx
je 0xed8e
movq %rbx, %rdi
callq 0x2150
jmp 0xed96
movq %rsi, %rdi
callq 0x2100
movq %rax, %rbx
movslq %r15d, %rdi
addl %r13d, %r15d
addq %rax, %rdi
movslq %r13d, %rdx
movl $0x1, %esi
movq %r12, %rcx
callq 0x2040
movslq %r15d, %rax
movb $0x0, (%rbx,%rax)
movq %r12, %rdi
callq 0x2050
movq -0x38(%rbp), %r13
decq %r14
cmpq $0x2, %r14
ja 0xecdd
jmp 0xedd6
xorl %ebx, %ebx
leaq -0x1c0(%rbp), %r14
movq %r14, %rdi
callq 0xdc08
movq 0x48a4(%rip), %rax      # 0x13690
movq %rax, 0x138(%r14)
movq $0x0, 0x130(%r14)
testq %rax, %rax
je 0xee14
movq 0x8(%rax), %rax
testq %rax, %rax
je 0xee14
movq %r14, %rdi
callq *0x8(%rax)
jmp 0xee07
leaq -0x1c0(%rbp), %rdi
callq 0xeb2c
testq %rbx, %rbx
je 0xef69
leaq -0x1c0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x381a
movq %rax, %rbx
movq 0x120(%r14), %r15
movl $0x18, %edi
callq 0x2100
xorl %r12d, %r12d
movl %r12d, (%rax)
movq %rbx, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, 0x120(%r14)
movq 0x416d(%rip), %rax      # 0x12fd8
movq (%rax), %r15
movl $0x18, %edi
callq 0x2100
movl %r12d, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rax, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl $0x1, %ecx
movl $0x80, %r8d
xorl %r9d, %r9d
callq 0x2637
leaq 0x5fd(%rip), %rsi       # 0xf4a6
movq %r14, %rdi
movl $0x6, %edx
callq 0x3608
movq 0x148(%r14), %rcx
testq %rcx, %rcx
je 0xef69
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0xeed7
cmpq %rax, 0x8(%rdx)
jne 0xeee0
jmp 0xeee6
testq %rax, %rax
je 0xef69
movq 0x10(%rcx), %rcx
jmp 0xeebd
movq 0x10(%rdx), %rbx
movq 0x46ef(%rip), %r14      # 0x135e0
movl $0x18, %edi
callq 0x2100
movl $0x0, (%rax)
movq %r14, 0x8(%rax)
movq $0x0, 0x10(%rax)
movq %rbx, -0x88(%rbp)
movq %rax, -0x90(%rbp)
testq %rbx, %rbx
je 0xef26
movq 0x8(%rbx), %rbx
jmp 0xef28
xorl %ebx, %ebx
movq -0x1b8(%rbp), %r14
movq -0x48(%rbp), %r15
movl $0x18, %edi
callq 0x2100
movl $0x0, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, -0x48(%rbp)
testq %rbx, %rbx
je 0xef69
leaq -0x1c0(%rbp), %r14
movq %r14, %rdi
callq *0x8(%rbx)
movq %rax, %rbx
testq %rax, %rax
jne 0xef5b
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)