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

    for (addr = 0; addr < CORE_SIZE; addr++) {
        // skip unused, data, or non-indirect opcodes
        if (core [addr] == -1 || (tags [addr] & TAG_DATA) || core [addr] >= 06000 || !(core [addr] & 00400)) {
            if (optv > 2 && core [addr] != -1) {
                printf ("+FLOW3 %04o %04o tags 0x%04x skipped\n", addr, core [addr], tags [addr]);
            }
            continue;
        }

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

        switch (core [addr] & 07000) {      // check opcode (indirectness assured above)
        case    00000:                      // AND I
        case    01000:                      // TAD I
        case    02000:                      // ISZ I
        case    03000:                      // DCA I
            if (core [eff] != -1 && !(tags [eff] & TAG_WRITABLE)) { // if it's valid and constant
                tags [core [eff]] |= TAG_DATA;  // then the target is data
                if (optv > 1) {
                    printf ("+FLOW3 %04o %04o is AND/TAD/ISZ/DCA I through constant EA %04o so target %04o is DATA\n", addr, core [addr], eff, core [eff]);
                }

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

        case    04000:                      // JMS I
            if (core [eff] != -1 && !(tags [eff] & TAG_WRITABLE)) { // if it's valid and constant
                if (core [core [eff]] == 0 || core [core [eff]] == core [eff]) {    // valid first word of JMS I target
                    tags [core [eff]] |= TAG_SUB;   // ultimate target is a valid subroutine target
                    tags [eff] |= TAG_DATA;         // and the pointer is a valid data type
                    tags [eff] |= TAG_INDIRECTFC;   // and the pointer is used in an indirect flow control target
                    if (optv > 1) {
                        printf ("+FLOW3 %04o %04o is JMS I through constant EA %04o so target %04o (content %04o) is ok, so tagged as SUB\n", addr, core [addr], eff, core [eff], core [core [eff]]);
                    }
                } else {
                    tags [addr] |= TAG_DATA;    // then this isn't a valid instruction
                    if (optv > 1) {
                        printf ("+FLOW3 %04o %04o is JMS I through constant EA %04o with target %04o (invalid content %04o), so tagged as DATA\n", addr, core [addr], eff, core [eff], core [core [eff]]);
                    }
                }
            }
            break;

        case    05000:                      // JMP I
            if (core [eff] != -1) {             // if it's valid
                if (!(tags [eff] & TAG_WRITABLE)) { // and constant
                    tags [eff] |= TAG_DATA;         // pointer is a valid data type
                    tags [eff] |= TAG_INDIRECTFC;   // and the pointer is used in an indirect flow control target
                    tags [core [eff]] |= TAG_LABEL; // ultimate target is a valid JMP target
                    if (optv > 1) {
                        printf ("+FLOW3 %04o %04o is JMP I through constant EA %04o with valid target %04o, so EA tagged as DATA | INDIRECTFC and target data %04o tagged as LABEL\n", addr, core [addr], eff, core [eff], core [core [eff]]);
                    }
                }
            } else {
                tags [addr] |= TAG_DATA;    // else, it's not really a valid constant expression
                if (optv > 1) {
                    printf ("+FLOW3 %04o %04o is JMP I through constant EA %04o with invalid target %04o, so tagged as DATA\n", addr, core [addr], eff, core [eff]);
                }
            }
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x1000, -0x4(%rbp)     # imm = 0x1000
jge 0x6ff6
movslq -0x4(%rbp), %rcx
leaq 0x8529(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6a86
movslq -0x4(%rbp), %rcx
leaq 0xa515(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x6a86
movslq -0x4(%rbp), %rcx
leaq 0x84fe(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $0xc00, %eax            # imm = 0xC00
jge 0x6a86
movslq -0x4(%rbp), %rcx
leaq 0x84e8(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x6ada
leaq 0x84c3(%rip), %rax      # 0xef50
cmpl $0x2, (%rax)
jle 0x6ad5
movslq -0x4(%rbp), %rcx
leaq 0x84c3(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6ad5
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x84ac(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movslq -0x4(%rbp), %rcx
leaq 0xa49d(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %ecx
leaq 0x5440(%rip), %rdi      # 0xbf0e
movb $0x0, %al
callq 0x30a0
jmp 0x6fe8
movslq -0x4(%rbp), %rcx
movl %ecx, %edi
leaq 0x8479(%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 $0xe00, %eax            # imm = 0xE00
movl %eax, -0xc(%rbp)
je 0x6b5f
jmp 0x6b18
movl -0xc(%rbp), %eax
subl $0x200, %eax            # imm = 0x200
je 0x6b5f
jmp 0x6b24
movl -0xc(%rbp), %eax
subl $0x400, %eax            # imm = 0x400
je 0x6b5f
jmp 0x6b30
movl -0xc(%rbp), %eax
subl $0x600, %eax            # imm = 0x600
je 0x6b5f
jmp 0x6b3c
movl -0xc(%rbp), %eax
subl $0x800, %eax            # imm = 0x800
je 0x6cab
jmp 0x6b4c
movl -0xc(%rbp), %eax
subl $0xa00, %eax            # imm = 0xA00
je 0x6e81
jmp 0x6fe6
movslq -0x8(%rbp), %rcx
leaq 0x83f6(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6ca6
movslq -0x8(%rbp), %rcx
leaq 0xa3de(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x6ca6
movslq -0x8(%rbp), %rcx
leaq 0x83c1(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0xa3b5(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa3a4(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x8389(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6bff
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x8386(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x8374(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
leaq 0x533c(%rip), %rdi      # 0xbf34
movb $0x0, %al
callq 0x30a0
movslq -0x4(%rbp), %rcx
leaq 0x8356(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
andl $0xe00, %eax            # imm = 0xE00
cmpl $0x400, %eax            # imm = 0x400
je 0x6c35
movslq -0x4(%rbp), %rcx
leaq 0x833b(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
andl $0xe00, %eax            # imm = 0xE00
cmpl $0x600, %eax            # imm = 0x600
jne 0x6ca4
movslq -0x8(%rbp), %rcx
leaq 0x8320(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0xa314(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x100, %eax            # imm = 0x100
movw %ax, %dx
leaq 0xa301(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x82e6(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6ca2
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x82e3(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x82d1(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
leaq 0x52f0(%rip), %rdi      # 0xbf8b
movb $0x0, %al
callq 0x30a0
jmp 0x6ca4
jmp 0x6ca6
jmp 0x6fe6
movslq -0x8(%rbp), %rcx
leaq 0x82aa(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6e7c
movslq -0x8(%rbp), %rcx
leaq 0xa292(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x6e7c
movslq -0x8(%rbp), %rcx
leaq 0x8275(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0x8269(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
je 0x6d32
movslq -0x8(%rbp), %rcx
leaq 0x8255(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0x8249(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
movslq -0x8(%rbp), %rdx
leaq 0x823a(%rip), %rcx      # 0xef60
movswl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jne 0x6dfd
movslq -0x8(%rbp), %rcx
leaq 0x8223(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0xa217(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x2, %eax
movw %ax, %dx
leaq 0xa206(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
movslq -0x8(%rbp), %rcx
leaq 0xa1f7(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa1e6(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
movslq -0x8(%rbp), %rcx
leaq 0xa1d7(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x400, %eax            # imm = 0x400
movw %ax, %dx
leaq 0xa1c4(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x81a9(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6dfb
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x81a6(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x8194(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
movslq -0x8(%rbp), %rdi
leaq 0x8184(%rip), %rax      # 0xef60
movswq (%rax,%rdi,2), %rdi
leaq 0x8178(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r9d
leaq 0x51ea(%rip), %rdi      # 0xbfde
movb $0x0, %al
callq 0x30a0
jmp 0x6e7a
movslq -0x4(%rbp), %rcx
leaq 0xa158(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa147(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x812c(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6e78
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x8129(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x8117(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
movslq -0x8(%rbp), %rdi
leaq 0x8107(%rip), %rax      # 0xef60
movswq (%rax,%rdi,2), %rdi
leaq 0x80fb(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r9d
leaq 0x51d7(%rip), %rdi      # 0xc048
movb $0x0, %al
callq 0x30a0
jmp 0x6e7a
jmp 0x6e7c
jmp 0x6fe6
movslq -0x8(%rbp), %rcx
leaq 0x80d4(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %eax
cmpl $-0x1, %eax
je 0x6f83
movslq -0x8(%rbp), %rcx
leaq 0xa0bc(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x6f81
movslq -0x8(%rbp), %rcx
leaq 0xa09f(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0xa08e(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
movslq -0x8(%rbp), %rcx
leaq 0xa07f(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x400, %eax            # imm = 0x400
movw %ax, %dx
leaq 0xa06c(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
movslq -0x8(%rbp), %rcx
leaq 0x805d(%rip), %rax      # 0xef60
movswq (%rax,%rcx,2), %rcx
leaq 0xa051(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x4, %eax
movw %ax, %dx
leaq 0xa040(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x8025(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6f7f
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x8022(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x8010(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
movslq -0x8(%rbp), %rdi
leaq 0x8000(%rip), %rax      # 0xef60
movswq (%rax,%rdi,2), %rdi
leaq 0x7ff4(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r9d
leaq 0x513f(%rip), %rdi      # 0xc0b7
movb $0x0, %al
callq 0x30a0
jmp 0x6f81
jmp 0x6fe4
movslq -0x4(%rbp), %rcx
leaq 0x9fd2(%rip), %rax      # 0x10f60
movzwl (%rax,%rcx,2), %eax
orl $0x1, %eax
movw %ax, %dx
leaq 0x9fc1(%rip), %rax      # 0x10f60
movw %dx, (%rax,%rcx,2)
leaq 0x7fa6(%rip), %rax      # 0xef50
cmpl $0x1, (%rax)
jle 0x6fe2
movl -0x4(%rbp), %esi
movslq -0x4(%rbp), %rcx
leaq 0x7fa3(%rip), %rax      # 0xef60
movswl (%rax,%rcx,2), %edx
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdi
leaq 0x7f91(%rip), %rax      # 0xef60
movswl (%rax,%rdi,2), %r8d
leaq 0x516f(%rip), %rdi      # 0xc14a
movb $0x0, %al
callq 0x30a0
jmp 0x6fe4
jmp 0x6fe6
jmp 0x6fe8
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x6a1f
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)