// File: /workspace/github_c_makefile_star2_O0/pahihu[P]mixal/run.c
// Function: run
void run(void)
{
    install_error_handler(stop);
    if (setjmp(escape_k) != 0) {
        if (mix_config & MIXCONFIG_CORE) {
            if (mix_config & MIXCONFIG_INTERRUPT)
                save_memory("mixcore.ctl", control_memory, memory_size);
            save_memory("mixcore.dat", memory, memory_size);
        }
        return;
    }

    /* --- Go device support --- */
    if (MIXCONFIG_PUSHGO & mix_config) {
        M = 0; F = io_go_device(); C = 36;
        op_table[C].action();
        io_complete();
        pc = 0;
    }

    if (trace_count)
        print_CPU_trace(true);
    for (;;) {
        if (memory_size <= abs(pc)) {
            error("Program counter out of range: %s", address_to_string(pc));
        }
        {
            unsigned long start_time, delta_time;

            /* --- Instruction trace --- */
            if (trace_count && (frequency[pc] <= trace_count))
                print_CPU_trace(false);

            /* MOV adds 2 clocks per word */
            start_time = elapsed_time;
            xecute(pc, false);
            elapsed_time += op_table[C].clocks;

            /* --- I/O subsystem --- */
            delta_time = elapsed_time - start_time;
            if ((false == wait_state) && io_scheduled())
                do_scheduled_io(delta_time);

            /* --- Real-time clock --- */
            if (rtc_busy) {
                if (rtc_busy <= delta_time) {
                    Cell cell = sub(control_memory[10], ulong_to_cell(1));
                    control_memory[10] = cell;
                    if (magnitude(cell))
                        rtc_busy = 1000 + rtc_busy - delta_time;
                    else
                        rtc_busy = 0;
                    rtc_int_pending = true;
                }
            } else
                rtc_busy -= delta_time;

            /* --- Interrupt facility --- */
            if (!rti_done && 
                normal_state == internal_state)
            {
                Address int_pc = 0;
                Byte device;

                if (true == rtc_int_pending) {
                    rtc_int_pending = false;
                    int_pc = -11;
                }
                else if (true == io_pending_interrupt(&device))
                    int_pc = -(20 + device);
                if (int_pc) {
                    save_state();
                    internal_state = control_state;
                    pc = int_pc;
                }
            }
        } /* for (;;) body */
    } /* for (;;) */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x2d1(%rip), %rdi       # 0x9810
callq 0x7490
leaq 0xa8d5(%rip), %rdi      # 0x13e20
callq 0x3150
cmpl $0x0, %eax
je 0x95a9
movl 0xa801(%rip), %eax      # 0x13d5c
andl $0x8, %eax
cmpl $0x0, %eax
je 0x95a3
movl 0xa7f3(%rip), %eax      # 0x13d5c
andl $0x2, %eax
cmpl $0x0, %eax
je 0x958a
movq 0xa868(%rip), %rsi      # 0x13de0
movl 0xa856(%rip), %edx      # 0x13dd4
leaq 0x3ad1(%rip), %rdi      # 0xd056
callq 0x9880
movq 0xa857(%rip), %rsi      # 0x13de8
movl 0xa83d(%rip), %edx      # 0x13dd4
leaq 0x3ac4(%rip), %rdi      # 0xd062
callq 0x9880
addq $0x30, %rsp
popq %rbp
retq
movl 0xa7ad(%rip), %eax      # 0x13d5c
andl $0x10, %eax
cmpl $0x0, %eax
je 0x95fe
movq $0x0, 0xa84e(%rip) # 0x13e10
callq 0x5560
movl %eax, 0xa83f(%rip)      # 0x13e0c
movl $0x24, 0xa831(%rip)     # 0x13e08
movl 0xa82b(%rip), %eax      # 0x13e08
movl %eax, %ecx
leaq 0x81fa(%rip), %rax      # 0x117e0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
callq *(%rax)
callq 0x5ae0
movl $0x0, 0xa7d2(%rip)      # 0x13dd0
cmpl $0x0, 0xa753(%rip)      # 0x13d58
je 0x9611
movl $0x1, %edi
callq 0x9270
jmp 0x9613
movl 0xa7bb(%rip), %eax      # 0x13dd4
movl 0xa7b1(%rip), %ecx      # 0x13dd0
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
cmpl %ecx, %eax
jg 0x9646
movl 0xa7a0(%rip), %edi      # 0x13dd0
callq 0x4670
movq %rax, %rsi
leaq 0x3a2f(%rip), %rdi      # 0xd06e
movb $0x0, %al
callq 0x74b0
cmpl $0x0, 0xa70b(%rip)      # 0x13d58
je 0x966f
movq 0xa7a2(%rip), %rax      # 0x13df8
movslq 0xa773(%rip), %rcx      # 0x13dd0
movl (%rax,%rcx,4), %eax
cmpl 0xa6f2(%rip), %eax      # 0x13d58
ja 0x966f
xorl %edi, %edi
callq 0x9270
movq 0xa6da(%rip), %rax      # 0x13d50
movq %rax, -0x8(%rbp)
movl 0xa750(%rip), %edi      # 0x13dd0
xorl %esi, %esi
callq 0x9910
movl 0xa77b(%rip), %eax      # 0x13e08
movl %eax, %ecx
leaq 0x814a(%rip), %rax      # 0x117e0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addq 0xa6a9(%rip), %rax      # 0x13d50
movq %rax, 0xa6a2(%rip)      # 0x13d50
movq 0xa69b(%rip), %rax      # 0x13d50
subq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
xorl %eax, %eax
cmpl 0xa72b(%rip), %eax      # 0x13df0
jne 0x96dc
callq 0x5960
cmpl $0x0, %eax
je 0x96dc
movq -0x10(%rbp), %rax
movl %eax, %edi
callq 0x5570
cmpl $0x0, 0xa689(%rip)      # 0x13d6c
je 0x976d
movslq 0xa67c(%rip), %rax      # 0x13d6c
cmpq -0x10(%rbp), %rax
ja 0x976b
movq 0xa6e3(%rip), %rax      # 0x13de0
movq 0x50(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x1, %edi
callq 0x3570
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x3c30
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq 0xa6b6(%rip), %rax      # 0x13de0
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
andq $0x3fffffff, %rax       # imm = 0x3FFFFFFF
cmpq $0x0, %rax
je 0x9757
movl 0xa628(%rip), %eax      # 0x13d6c
addl $0x3e8, %eax            # imm = 0x3E8
cltq
subq -0x10(%rbp), %rax
movl %eax, 0xa617(%rip)      # 0x13d6c
jmp 0x9761
movl $0x0, 0xa60b(%rip)      # 0x13d6c
movl $0x1, 0xa605(%rip)      # 0x13d70
jmp 0x9781
movq -0x10(%rbp), %rcx
movslq 0xa5f4(%rip), %rax      # 0x13d6c
subq %rcx, %rax
movl %eax, 0xa5eb(%rip)      # 0x13d6c
cmpl $0x0, 0xa760(%rip)      # 0x13ee8
jne 0x97fe
xorl %eax, %eax
cmpl 0xa5d6(%rip), %eax      # 0x13d68
jne 0x97fe
movl $0x0, -0x1c(%rbp)
movl $0x1, %eax
cmpl 0xa5ca(%rip), %eax      # 0x13d70
jne 0x97bb
movl $0x0, 0xa5be(%rip)      # 0x13d70
movl $0xfffffff5, -0x1c(%rbp) # imm = 0xFFFFFFF5
jmp 0x97de
leaq -0x20(%rbp), %rdi
callq 0x5c80
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x97dc
movl -0x20(%rbp), %ecx
addl $0x14, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x97de
cmpl $0x0, -0x1c(%rbp)
je 0x97fc
callq 0x9b10
movl $0x1, 0xa575(%rip)      # 0x13d68
movl -0x1c(%rbp), %eax
movl %eax, 0xa5d4(%rip)      # 0x13dd0
jmp 0x97fe
jmp 0x9613
nopw %cs:(%rax,%rax)