// File: /workspace/github_c_makefile_star2_O2/afi-lambda[P]a_little_smalltalk/src/st.c
// Function: main
int main(int argc, char **argv)
{
    FILE *fp;
    object firstProcess;
    char *p, buffer[120];

    initMemoryManager();

    strcpy(buffer, "systemImage");
    p = buffer;

    if (argc <= 2)
    {
        if (argc != 1) p = argv[1];

        fp = fopen(p, "rb");

        if (fp == NULL)
        {
            sysError("cannot open image", p);
            exit(1);
        }
        imageRead(fp);
        initCommonSymbols();

        firstProcess = globalSymbol("systemProcess");
        if (firstProcess == nilobj)
        {
            sysError("no initial process", "in image");
            exit(1);
            return 1;
        }

        /* execute the main system process loop repeatedly */
        /*debugging = true;*/

        /* not using windowing interface, safe to print out message */
        printf("Little Smalltalk Improved, Version 0.01\n");

        while (execute(firstProcess, 15000))
            ;
    }
    else     // We have been called for image creation
    {
        char methbuf[100];
        int i;

        initMemoryManager();

        makeInitialImage();

        initCommonSymbols();

        for (i = 1; i < argc; i++)
        {
            fprintf(stderr, "%s:\n", argv[i]);
            sprintf(methbuf, "x <120 1 '%s' 'r'>. <123 1>. <121 1>", argv[i]);
            goDoIt(methbuf);
        }

        /* when we are all done looking at the arguments, do initialization */
        fprintf(stderr, "initialization\n");
        /*debugging = true;*/
        goDoIt("x nil initialize\n");
        fprintf(stderr, "finished\n");

        /* exit and return - belt and suspenders, but it keeps lint happy */
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %rbx
movl %edi, %ebp
callq 0x2838
movabsq $0x6d496d6574737973, %rax # imm = 0x6D496D6574737973
movq %rax, (%rsp)
movl $0x656761, 0x8(%rsp)    # imm = 0x656761
cmpl $0x2, %ebp
jg 0x23ef
cmpl $0x1, %ebp
jne 0x2370
movq %rsp, %rbx
jmp 0x2374
movq 0x8(%rbx), %rbx
leaq 0x6c95(%rip), %rsi      # 0x9010
movq %rbx, %rdi
callq 0x21b0
testq %rax, %rax
je 0x2694
movq %rax, %rdi
callq 0x7bdc
xorl %eax, %eax
callq 0x3092
leaq 0x254e2(%rip), %rax     # 0x27884
movswl (%rax), %edi
leaq 0x6c79(%rip), %rsi      # 0x9025
callq 0x306f
testw %ax, %ax
je 0x26a0
movl %eax, %ebx
leaq 0x6d2f(%rip), %rdi      # 0x90f2
callq 0x2060
movswl %bx, %ebx
movl %ebx, %edi
movl $0x3a98, %esi           # imm = 0x3A98
callq 0x37be
testl %eax, %eax
jne 0x23cb
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2838
pushq $0x1
popq %rdi
callq 0x2964
leaq 0x25481(%rip), %rcx     # 0x27884
movw %ax, (%rcx)
movq %rcx, %r14
movswl %ax, %edi
callq 0x2b30
movl $0x9f, %edi
callq 0x2964
movswl (%r14), %ecx
shrl %ecx
movswq %cx, %rcx
shlq $0x4, %rcx
leaq 0xbe00(%rip), %r12      # 0xe230
movq 0x8(%r12,%rcx), %rcx
movw %ax, (%rcx)
movswl %ax, %r14d
movl %r14d, %edi
callq 0x2b30
leaq 0x6c5d(%rip), %r15      # 0x90a8
movq %r15, %rdi
callq 0x3368
movswl %ax, %r13d
movq %r15, %rdi
callq 0x32d7
shrl %r13d
movswq %r13w, %rcx
shlq $0x4, %rcx
movw %ax, (%r12,%rcx)
movswl %ax, %r15d
movl %r15d, %edi
callq 0x2b30
leaq 0x6c2d(%rip), %rdi      # 0x90af
callq 0x32d7
shrl %r15d
movswq %r15w, %rcx
shlq $0x4, %rcx
movw %ax, (%r12,%rcx)
movswl %ax, %r15d
movl %r15d, %edi
callq 0x2b30
movl %r15d, %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
movw %r15w, (%r12,%rax)
movl %r15d, %edi
callq 0x2b30
leaq 0x6bf1(%rip), %rdi      # 0x90b5
callq 0x32d7
leaq 0x6bea(%rip), %rdi      # 0x90ba
callq 0x32d7
leaq 0x6be2(%rip), %rdi      # 0x90be
callq 0x32d7
shrl %r14d
movswq %r14w, %rcx
shlq $0x4, %rcx
movw %ax, (%r12,%rcx)
movswl %ax, %edi
callq 0x2b30
leaq 0x6bc4(%rip), %rdi      # 0x90c4
callq 0x32d7
leaq 0x25378(%rip), %r13     # 0x27884
movswl (%r13), %ecx
shrl %ecx
movswq %cx, %rcx
shlq $0x4, %rcx
movw %ax, (%r12,%rcx)
movswl %ax, %edi
callq 0x2b30
leaq 0x6ba0(%rip), %rdi      # 0x90cf
callq 0x32d7
movw %ax, (%r12)
movswl %ax, %edi
callq 0x2b30
leaq 0x6d06(%rip), %rdi      # 0x924e
callq 0x32d7
movswl (%r13), %r14d
leaq 0x6b86(%rip), %r15      # 0x90df
movq %r15, %rdi
callq 0x2f93
movl %eax, %r12d
movq %r15, %rdi
callq 0x3368
movswl (%r13), %ecx
movswl %ax, %edx
movl %r14d, %edi
movl %r12d, %esi
callq 0x2da8
leaq 0x6b61(%rip), %r14      # 0x90e7
movq %r14, %rdi
callq 0x3368
leaq 0x25a2d(%rip), %r12     # 0x27fc2
movw %ax, (%r12)
movswl (%r13), %r15d
movq %r14, %rdi
callq 0x2f93
movswl (%r12), %ecx
movl %r15d, %edi
movl %eax, %esi
movl %ecx, %edx
callq 0x2da8
leaq 0x6b2d(%rip), %r14      # 0x90ec
movq %r14, %rdi
callq 0x3368
leaq 0x259f6(%rip), %r12     # 0x27fc4
movw %ax, (%r12)
movswl (%r13), %r15d
movq %r14, %rdi
callq 0x2f93
movswl (%r12), %ecx
movl %r15d, %edi
movl %eax, %esi
movl %ecx, %edx
callq 0x2da8
xorl %eax, %eax
callq 0x3092
movl %ebp, %ebp
pushq $0x1
popq %r13
leaq 0x6a4a(%rip), %r14      # 0x904f
leaq 0x6a48(%rip), %r15      # 0x9054
leaq 0x80(%rsp), %r12
movq 0xa9d5(%rip), %rax      # 0xcff0
movq (%rax), %rcx
cmpq %r13, %rbp
je 0x2652
movq (%rbx,%r13,8), %rdx
movq %rcx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2170
movq (%rbx,%r13,8), %rdx
movq %r12, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21d0
movq %r12, %rdi
callq 0x26bb
incq %r13
jmp 0x2614
leaq 0x6a20(%rip), %rdi      # 0x9079
pushq $0xf
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x21f0
leaq 0x6a1b(%rip), %rdi      # 0x9089
callq 0x26bb
movq 0xa976(%rip), %rax      # 0xcff0
movq (%rax), %rcx
leaq 0x6a17(%rip), %rdi      # 0x909b
pushq $0x9
popq %rsi
movq %rbx, %rdx
callq 0x21f0
jmp 0x23db
leaq 0x6978(%rip), %rdi      # 0x9013
movq %rbx, %rsi
jmp 0x26ae
leaq 0x698c(%rip), %rdi      # 0x9033
leaq 0x6998(%rip), %rsi      # 0x9046
callq 0x4938
pushq $0x1
popq %rdi
callq 0x21e0