// File: /workspace/github_c_makefile_star2_O0/pahihu[P]mixal/main.c
// Function: main
int main(int argc, char **argv)
{
    char title[8];
    Flag dump = false, punch = false, asm_only = false;
    
    precompute_field_data();

    /* Assemble the input: */
    strcpy(title, "OBJS");
    install_error_handler(assembler_error);
    if (argc == 1) {
        set_configuration(0);                           /* default config */
        assemble_file("-");
    } else {
        int i, j;
        unsigned flags;

    /* --- Process flags --- */
        flags = 0;
        for (i = 1; i < argc; ++i) {
            if (*argv[i] == '-')
                switch (argv[i][1]) {
		        case 'a': asm_only = true; break;
                case 'b': flags += MIXCONFIG_BINARY; break;
                case 'c': flags += MIXCONFIG_CORE; break;
                case 'd': dump = true; break;
                case 'e':
                    if (++i == argc) usage();
                    entry_point = atol(argv[i]);
                    break;
                case 'f': flags += MIXCONFIG_FLOAT; break;
                case 'g':
                    flags += MIXCONFIG_PUSHGO;
                    if (i+1 != argc) {
                        if (isdigit(*argv[i+1]))
                            io_set_go_device(atol(argv[++i]));
                    }
                    break;
                case 'h': usage(); break;
                case 'i': flags += MIXCONFIG_INTERRUPT; break;
                case 'm': flags += MIXCONFIG_MASTER; break;
                case 'o': punch = true; break;
                case 'r': io_redirect(); break;
                case 't':
                    if (++i == argc) usage();
                    set_trace_count(atol(argv[i]));
                    break;
                case 'x': flags += MIXCONFIG_INDEX; break;
                case 'v': VERBOSE = true; break;
                default: usage();
                }
        }
        set_configuration(flags);

        /* --- Assemble MIXAL source files --- */
        for (i = 1; i < argc; i++) {
            if (*argv[i] == '-') {
                char flag = argv[i][1];
                if (flag == 'e' || flag == 't')
                    i++;
                else if (flag == 'g') {
                    if ((i+1 != argc) && isdigit(*argv[i+1]))
                        i++;
                }
            } else {
                for (j = 0; j < 5; j++) {
                    int ch = argv[i][j];
                    if (ch == 0 || ch == '.')
                        break;
                    title[j] = toupper(ch);
                }
                title[j] = '\0';
                assemble_file(argv[i]);
            }
        }
    }
    resolve_generated_futures();
    if (num_errors != 0) {
        fprintf(stderr, "%u errors found\n", num_errors);
        exit(1);
    }

    /* --- Punch object deck --- */
    if (punch)
        punch_object_deck(title, entry_point);

    /* --- Check assemble only --- */
    if (asm_only)
        return 0;

    /* Now run it: */
    set_initial_state();
    {
        clock_t finish, start = clock();
        run();
        finish = clock();
        fprintf(stderr, "%g seconds elapsed\n", 
                (float)(finish - start) / CLOCKS_PER_SEC);
    }
    print_CPU_state();
    if (dump) print_DUMP();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
callq 0x3870
leaq -0x18(%rbp), %rdi
leaq 0x5254(%rip), %rsi      # 0xc92f
callq 0x3070
leaq 0x3e9(%rip), %rdi       # 0x7ad0
callq 0x7490
cmpl $0x1, -0x8(%rbp)
jne 0x770a
xorl %edi, %edi
callq 0x8b60
leaq 0x4c51(%rip), %rdi      # 0xc351
callq 0x7b60
jmp 0x7a00
movl $0x0, -0x30(%rbp)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x78d7
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x78c7
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
addl $-0x61, %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x17, %eax
ja 0x78c0
movq -0x50(%rbp), %rax
leaq 0x50ff(%rip), %rcx      # 0xc868
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x24(%rbp)
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl $0x1, -0x1c(%rbp)
jmp 0x78c5
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x77b9
callq 0x7db0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3200
movl %eax, %ecx
leaq 0xaf75(%rip), %rax      # 0x12748
movl %ecx, (%rax)
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
je 0x784b
callq 0x3280
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl -0x28(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7849
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x28(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3200
movl %eax, %edi
callq 0x5520
jmp 0x784b
jmp 0x78c5
callq 0x7db0
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x80, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl $0x1, -0x20(%rbp)
jmp 0x78c5
callq 0x5510
jmp 0x78c5
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl -0x8(%rbp), %eax
jne 0x788f
callq 0x7db0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3200
movl %eax, %edi
callq 0x8a90
jmp 0x78c5
movl -0x30(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x30(%rbp)
jmp 0x78c5
movl $0x1, 0xc442(%rip)      # 0x13d00
jmp 0x78c5
callq 0x7db0
jmp 0x78c7
jmp 0x78c9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x7718
movl -0x30(%rbp), %edi
callq 0x8b60
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x79fe
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x7985
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movb 0x1(%rax), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x65, %eax
je 0x792a
movsbl -0x31(%rbp), %eax
cmpl $0x74, %eax
jne 0x7935
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x7983
movsbl -0x31(%rbp), %eax
cmpl $0x67, %eax
jne 0x7981
movl -0x28(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
je 0x797f
callq 0x3280
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl -0x28(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x797f
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x7981
jmp 0x7983
jmp 0x79ee
movl $0x0, -0x2c(%rbp)
cmpl $0x5, -0x2c(%rbp)
jge 0x79d4
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x79b5
cmpl $0x2e, -0x38(%rbp)
jne 0x79b7
jmp 0x79d4
movl -0x38(%rbp), %edi
callq 0x3080
movb %al, %cl
movslq -0x2c(%rbp), %rax
movb %cl, -0x18(%rbp,%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x798c
movslq -0x2c(%rbp), %rax
movb $0x0, -0x18(%rbp,%rax)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b60
jmp 0x79f0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x78e6
jmp 0x7a00
callq 0xb840
cmpl $0x0, 0xc314(%rip)      # 0x13d20
je 0x7a36
movq 0xa5e3(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl 0xc302(%rip), %edx      # 0x13d20
leaq 0x4f0f(%rip), %rsi      # 0xc934
movb $0x0, %al
callq 0x3170
movl $0x1, %edi
callq 0x3250
cmpl $0x0, -0x20(%rbp)
je 0x7a4e
leaq -0x18(%rbp), %rdi
leaq 0xad01(%rip), %rax      # 0x12748
movl (%rax), %esi
callq 0x5d80
cmpl $0x0, -0x24(%rbp)
je 0x7a5d
movl $0x0, -0x4(%rbp)
jmp 0x7ac5
callq 0x8ab0
callq 0x30b0
movq %rax, -0x48(%rbp)
callq 0x9530
callq 0x30b0
movq %rax, -0x40(%rbp)
movq 0xa578(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
cvtsi2ss %rax, %xmm0
movss 0x4dcc(%rip), %xmm1     # 0xc864
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x4e9e(%rip), %rsi      # 0xc945
movb $0x1, %al
callq 0x3170
callq 0x8ce0
cmpl $0x0, -0x1c(%rbp)
je 0x7abe
callq 0x8ff0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop