// File: /workspace/github_c_makefile_star2_O0/AK6DN[P]dec-utilities-for-pdp/d8tape/flow.c
// Function: pass2
static void
pass2 (void)
{
    int     addr;
    int     eff;

    for (addr = 0; addr < CORE_SIZE; addr++) {
        // skip unused or data locations
        if (core [addr] == -1 || (tags [addr] & TAG_DATA)) {
            continue;
        }

        eff = ea (addr, core [addr], NULL, NULL);

        switch (core [addr] & 07400) {      // check opcode
        case    00000:                      // AND
        case    00400:                      // AND I
        case    01000:                      // TAD
        case    01400:                      // TAD I
        case    02000:                      // ISZ
        case    02400:                      // ISZ I
        case    03000:                      // DCA
        case    03400:                      // DCA I
            tags [eff] |= TAG_DATA;         // the referenced EA is data
            if (optv > 1) {
                printf ("+FLOW2 %04o %04o is AND/TAD/ISZ/DCA's EA %04o tagged as DATA\n", addr, core [addr], eff);
            }

            // mark as writable if someone writes to it directly (ISZ and DCA only)
            if ((core [addr] & 07400) == 02000 || (core [addr] & 07400) == 03000) {
                tags [eff] |= TAG_WRITABLE;
                if (optv > 1) {
                    printf ("+FLOW2 %04o %04o is ISZ/DCA so EA %04o is WRITABLE\n", addr, core [addr], eff);
                }
            }
            break;

        case    04000:                      // JMS
            if (core [eff] == 0 || core [eff] == eff) { // first word of JMS target must be zero or the address itself
                tags [eff] |= TAG_SUB;      // otherwise, it's a valid subroutine target
                if (optv > 1) {
                    printf ("+FLOW2 %04o %04o is JMS with good target %04o content (%04o) so tagged as SUB\n", addr, core [addr], eff, core [eff]);
                }
            } else {
                tags [addr] |= TAG_DATA;    // then invalidate this "instruction", it's bogus
                if (optv > 1) {
                    printf ("+FLOW2 %04o %04o is JMS with bad target %04o content (%04o) so tagged as DATA\n", addr, core [addr], eff, core [eff]);
                }
            }
            break;

        case    05000:                      // JMP
            tags [eff] |= TAG_LABEL;
            if (optv > 1) {
                printf ("+FLOW2 %04o %04o is JMP so EA %04o is LABEL\n", addr, core [addr], eff);
            }
            break;

            break;

        // JMS I, JMP I, IOTs, and OPRs are not handled in this pass
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x1000, -0x4(%rbp)     # imm = 0x1000
jge 0x69fb
movslq -0x4(%rbp), %rcx
leaq 0x8869(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6717
movslq -0x4(%rbp), %rcx
leaq 0xa855(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x671c
jmp 0x69ed
movslq -0x4(%rbp), %rcx
movl %ecx, %edi
leaq 0x8837(%rip), %rax      # 0xef60
movq %rax, -0x18(%rbp)
movswl (%rax,%rcx,2), %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x5c40
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, -0x8(%rbp)
movslq -0x4(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0xf00, %eax            # imm = 0xF00
movl %eax, -0xc(%rbp)
je 0x67d1
jmp 0x675a
movl -0xc(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x67d1
jmp 0x6766
movl -0xc(%rbp), %eax
subl $0x200, %eax            # imm = 0x200
je 0x67d1
jmp 0x6772
movl -0xc(%rbp), %eax
subl $0x300, %eax            # imm = 0x300
je 0x67d1
jmp 0x677e
movl -0xc(%rbp), %eax
subl $0x400, %eax            # imm = 0x400
je 0x67d1
jmp 0x678a
movl -0xc(%rbp), %eax
subl $0x500, %eax            # imm = 0x500
je 0x67d1
jmp 0x6796
movl -0xc(%rbp), %eax
subl $0x600, %eax            # imm = 0x600
je 0x67d1
jmp 0x67a2
movl -0xc(%rbp), %eax
subl $0x700, %eax            # imm = 0x700
je 0x67d1
jmp 0x67ae
movl -0xc(%rbp), %eax
subl $0x800, %eax            # imm = 0x800
je 0x68ae
jmp 0x67be
movl -0xc(%rbp), %eax
subl $0xa00, %eax            # imm = 0xA00
je 0x699a
jmp 0x69eb
movslq -0x8(%rbp), %rcx
leaq 0xa784(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa773(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x8758(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6820
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x8755(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
leaq 0x55b8(%rip), %rdi      # 0xbdd1
movb $0x0, %al
callq 0x30a0
movslq -0x4(%rbp), %rcx
leaq 0x8735(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
andl $0xf00, %eax            # imm = 0xF00
cmpl $0x400, %eax            # imm = 0x400
je 0x6856
movslq -0x4(%rbp), %rcx
leaq 0x871a(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
andl $0xf00, %eax            # imm = 0xF00
cmpl $0x600, %eax            # imm = 0x600
jne 0x68a9
movslq -0x8(%rbp), %rcx
leaq 0xa6ff(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x100, %eax            # imm = 0x100
movw %ax, %dx
leaq 0xa6ec(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x86d1(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x68a7
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x86ce(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
leaq 0x556f(%rip), %rdi      # 0xbe0f
movb $0x0, %al
callq 0x30a0
jmp 0x68a9
jmp 0x69eb
movslq -0x8(%rbp), %rcx
leaq 0x86a7(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
je 0x68d6
movslq -0x8(%rbp), %rcx
leaq 0x8693(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl -0x8(%rbp), %eax
jne 0x6937
movslq -0x8(%rbp), %rcx
leaq 0xa67f(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x2, %eax
movw %ax, %dx
leaq 0xa66e(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x8653(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6935
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x8650(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x863e(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
leaq 0x5515(%rip), %rdi      # 0xbe43
movb $0x0, %al
callq 0x30a0
jmp 0x6998
movslq -0x4(%rbp), %rcx
leaq 0xa61e(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa60d(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x85f2(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6996
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x85ef(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x85dd(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
leaq 0x5503(%rip), %rdi      # 0xbe92
movb $0x0, %al
callq 0x30a0
jmp 0x6998
jmp 0x69eb
movslq -0x8(%rbp), %rcx
leaq 0xa5bb(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x4, %eax
movw %ax, %dx
leaq 0xa5aa(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x858f(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x69e9
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x858c(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
leaq 0x54ff(%rip), %rdi      # 0xbee1
movb $0x0, %al
callq 0x30a0
jmp 0x69eb
jmp 0x69ed
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x66df
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)