// File: /workspace/github_c_makefile_star2_O2/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, %r14
movl %edi, %r15d
leaq -0x1d0(%rbp), %r12
movq $0x0, -0x30(%rbp)
movl $0x188, %edx            # imm = 0x188
movq %r12, %rdi
xorl %esi, %esi
callq 0x2080
leaq -0x6e(%rip), %rdi       # 0xb85e
callq 0xbb80
leaq -0x85(%rip), %rsi       # 0xb853
pushq $0x2
popq %rdi
callq 0x20b0
orq $-0x1, 0x90(%r12)
movl %r15d, %ebx
pushq $-0x1
popq %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movl %ebx, %r12d
decq %rbx
cmpl $0x2, %r12d
jl 0xba04
movq (%r14,%rbx,8), %r15
movq %r15, %rdi
callq 0x2060
decl %eax
cltq
movzbl (%r15,%rax), %eax
cmpl $0x6c, %eax
je 0xb940
cmpl $0x66, %eax
jne 0xb954
movq %r15, %rdi
leaq 0x9ac(%rip), %rsi       # 0xc2e0
callq 0x2160
testq %rax, %rax
je 0xb954
jmp 0xb959
movq %r15, %rdi
leaq 0x996(%rip), %rsi       # 0xc2e0
callq 0x2160
testq %rax, %rax
jne 0xb976
decl %r12d
jmp 0xb8fe
movq -0x40(%rbp), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, -0x140(%rbp)
movq %rax, -0x1b8(%rbp,%rdx,8)
movq %rcx, -0x40(%rbp)
jmp 0xb8fb
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
pushq $0x2
popq %rdx
callq 0x2140
movq %r13, %rdi
callq 0x20d0
movq %rax, %r15
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2140
movq -0x38(%rbp), %rax
addl %r15d, %eax
incl %eax
movslq %eax, %rsi
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
movq %r15, -0x48(%rbp)
je 0xb9bd
callq 0x2150
jmp 0xb9c5
movq %rsi, %rdi
callq 0x2100
movq %rax, %r12
movq -0x38(%rbp), %r15
movslq %r15d, %rdi
movq -0x48(%rbp), %rax
addl %eax, %r15d
addq %r12, %rdi
movslq %eax, %rdx
pushq $0x1
popq %rsi
movq %r13, %rcx
callq 0x2040
movq %r15, -0x38(%rbp)
movslq %r15d, %rax
movq %r12, -0x30(%rbp)
movb $0x0, (%r12,%rax)
movq %r13, %rdi
callq 0x2050
jmp 0xb8fb
leaq -0x1d0(%rbp), %rdi
callq 0xadcc
movq 0x4c79(%rip), %rdi      # 0x10690
xorl %esi, %esi
callq 0x2362
testq %rax, %rax
je 0xba48
movq 0x8(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
testq %rcx, %rcx
movq -0x30(%rbp), %rbx
je 0xba5d
movq 0x8(%rcx), %rax
jmp 0xba5f
leaq -0xa0(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %eax, %eax
movq -0x30(%rbp), %rbx
jmp 0xba5f
xorl %eax, %eax
leaq -0x1d0(%rbp), %r14
testq %rax, %rax
je 0xba73
movq %r14, %rdi
callq *0x8(%rax)
jmp 0xba66
leaq -0x1d0(%rbp), %rdi
callq 0xb77f
testq %rbx, %rbx
je 0xbb64
leaq -0x1d0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3434
movq %rax, %rbx
movq 0x120(%r14), %rsi
movq %rax, %rdi
callq 0x2362
movq %rax, 0x120(%r14)
movq 0x451e(%rip), %rax      # 0xffd8
movq (%rax), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x28bc
leaq 0x9bf(%rip), %rsi       # 0xc48e
pushq $0x6
popq %rdx
movq %r14, %rdi
callq 0x32a0
movq 0x148(%r14), %rsi
movq %rax, %rdi
callq 0x27b2
testq %rax, %rax
je 0xbb64
movq 0x10(%rax), %rbx
movq 0x4ae7(%rip), %rdi      # 0x105e0
xorl %esi, %esi
callq 0x2362
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2362
testq %rax, %rax
je 0xbb31
movq 0x8(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
testq %rcx, %rcx
je 0xbb3b
movq 0x8(%rcx), %rbx
jmp 0xbb3d
xorps %xmm0, %xmm0
movups %xmm0, -0xa0(%rbp)
xorl %ebx, %ebx
movq 0x8(%r14), %rdi
movq 0x178(%r14), %rsi
callq 0x2362
movq %rax, 0x178(%r14)
testq %rbx, %rbx
je 0xbb64
movq %r14, %rdi
callq *0x8(%rbx)
movq %rax, %rbx
jmp 0xbb54
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)