// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x29f0
leaq -0xa0(%rbp), %rdi
leaq 0x9ca8(%rip), %rsi      # 0xc004
callq 0x2050
leaq -0xa0(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpl $0x2, -0x8(%rbp)
jg 0x2435
cmpl $0x1, -0x8(%rbp)
je 0x2388
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x9c7d(%rip), %rsi      # 0xc010
callq 0x21b0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x23bd
movq -0x28(%rbp), %rsi
leaq 0x9c65(%rip), %rdi      # 0xc013
callq 0x63f0
movl $0x1, %edi
callq 0x21e0
movq -0x18(%rbp), %rdi
callq 0xb420
movb $0x0, %al
callq 0x3ba0
leaq 0x9c51(%rip), %rsi      # 0xc025
leaq 0x274d9(%rip), %rax     # 0x298b4
movswl (%rax), %edi
callq 0x3b50
movw %ax, -0x1a(%rbp)
movswl -0x1a(%rbp), %eax
cmpl $0x0, %eax
jne 0x240d
leaq 0x9c3c(%rip), %rdi      # 0xc033
leaq 0x9c48(%rip), %rsi      # 0xc046
callq 0x63f0
movl $0x1, %edi
callq 0x21e0
leaq 0x9c3b(%rip), %rdi      # 0xc04f
movb $0x0, %al
callq 0x20b0
movl $0x3a98, %esi           # imm = 0x3A98
movswl -0x1a(%rbp), %edi
callq 0x4690
cmpl $0x0, %eax
je 0x2430
jmp 0x241b
jmp 0x24ff
callq 0x29f0
callq 0x2740
movb $0x0, %al
callq 0x3ba0
movl $0x1, -0x114(%rbp)
movl -0x114(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x24c3
movq 0xcb96(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x114(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x9bfd(%rip), %rsi      # 0xc078
movb $0x0, %al
callq 0x2170
leaq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x114(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x9bde(%rip), %rsi      # 0xc07d
movb $0x0, %al
callq 0x21d0
leaq -0x110(%rbp), %rdi
callq 0x2510
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x2450
movq 0xcb2e(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x9bce(%rip), %rsi      # 0xc0a2
movb $0x0, %al
callq 0x2170
leaq 0x9bd0(%rip), %rdi      # 0xc0b2
callq 0x2510
movq 0xcb0a(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x9bcc(%rip), %rsi      # 0xc0c4
movb $0x0, %al
callq 0x2170
xorl %eax, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)