// File: /workspace/github_cpp_makefile_star2_O1/besm6[P]pascal-re/dtran.cc
// Function: Dtran::prinsn(unsigned int, unsigned int)
void
prinsn (uint32 memaddr, uint32 opcode)
{
    int i;

    uint reg = opcode >> 20;
    int arg1 = (opcode & 07777) + (opcode & 0x040000 ? 070000 : 0);
    int arg2 = opcode & 077777;
    int struc = opcode & 02000000;

    for (i=0; op[i].mask; i++)
        if ((opcode & op[i].mask) == op[i].opcode)
            break;
    opcode_e type = op[i].type;
    std::string opname = op[i].name;
    if (type == OPCODE_ILLEGAL) {
        opname = struc ? strprintf("%2o", (opcode >> 15) & 037)
            : strprintf("%03o", (opcode >> 12) & 0177);
    }
    std::string operand;
    if (struc && arg2 >= 074000) {
        operand = strprintf("%s", symtab[arg2 & 03777].c_str());
    } else if (struc && arg2 >= 040000 && (arg2 & 037777) < labels.size()) {
        uint off = arg2 & 037777;
        if (labels[off].empty())
            labels[off] = off < 010000 ?
                                strprintf("*%04oB", off) :
                                strprintf("*%05o", off);
        operand = labels[off];
    } else if (!struc && arg1 >= 04000 && arg1 < 010000) {
        operand = symtab[arg2 & 03777];
    } else if (!struc && arg1 >= 070000) {
        operand = "dunno";
    } else {
        if (uint val = struc ? arg2 : arg1) {
            if (type == OPCODE_REG1 || val < 8)
                operand = strprintf("%d", val);
            else if (type == OPCODE_IMM64) {
                operand = strprintf("64%+d", val-64);
            } else
                operand = strprintf(nooctal ? "%d" : "%oB", val);
        }
    }

    if (basereg && reg == basereg) {
        if (op[i].opcode == 02400000) {
            opname = "BASE";
        } else {
            reg = 0;
            operand = labels[baseaddr + arg1];
        }
    }
    if (nolabels && operand[0] == '*' && !strchr(operand.c_str(), '+')) {
        char * end;
        int off = strtol(operand.c_str()+1, &end, 8);
        if (end - operand.c_str() > 4)
            operand = strprintf(nooctal ? "/+%d" : "/+%oB", off);
    }
    if (reg) printf("%d,", reg); else printf(",");
    printf("%s,%s\n", opname.c_str(), operand.c_str());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebx
movq %rdi, %r14
movl 0x4097(%rip), %eax      # 0x814c
leaq 0x4084(%rip), %r13      # 0x8140
testl %eax, %eax
je 0x40d2
andl %ebx, %eax
cmpl 0x8(%r13), %eax
je 0x40d2
movl 0x24(%r13), %eax
addq $0x18, %r13
jmp 0x40bc
movl 0x10(%r13), %ebp
movq (%r13), %rsi
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x373e
testl %ebp, %ebp
jne 0x4153
xorl %eax, %eax
btl $0x13, %ebx
movl $0x7f, %ecx
movl $0x1f, %edi
cmovael %ecx, %edi
leaq 0x15a3(%rip), %rcx      # 0x56a8
leaq 0x1598(%rip), %rsi      # 0x56a4
cmovaeq %rcx, %rsi
setb %al
leal (%rax,%rax,2), %ecx
addl $0xc, %ecx
movl %ebx, %edx
shrl %cl, %edx
andl %edi, %edx
movq %rsp, %rdi
xorl %eax, %eax
callq 0x254c
leaq 0x40(%rsp), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0x2190
movq (%r15), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4153
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
movl %ebx, %r15d
shll $0xd, %r15d
sarl $0x1f, %r15d
movl %ebx, %eax
andl $0xfff, %eax            # imm = 0xFFF
andl $0x7000, %r15d          # imm = 0x7000
orl %eax, %r15d
movl %ebx, %edx
andl $0x7fff, %edx           # imm = 0x7FFF
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
btl $0x13, %ebx
setae %al
cmpl $0x7800, %edx           # imm = 0x7800
setb %cl
orb %al, %cl
jne 0x41fb
movl %ebx, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movq 0x40048(%r14), %rcx
shll $0x5, %eax
movq (%rcx,%rax), %rdx
leaq 0x14f2(%rip), %rsi      # 0x56ad
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
movq %rsp, %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
callq 0x2190
movq (%r12), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4361
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x4361
btl $0x13, %ebx
setae %al
cmpl $0x4000, %edx           # imm = 0x4000
setb %cl
orb %al, %cl
jne 0x42c1
movl %ebx, %r12d
andl $0x3fff, %r12d          # imm = 0x3FFF
movq 0x40060(%r14), %rax
movq 0x40068(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r12, %rcx
jbe 0x42c1
movl %r12d, %ecx
shll $0x5, %ecx
cmpq $0x0, 0x8(%rax,%rcx)
jne 0x42a6
cmpl $0x1000, %r12d          # imm = 0x1000
leaq 0x127b(%rip), %rax      # 0x54d2
leaq 0x127b(%rip), %rsi      # 0x54d9
cmovbq %rax, %rsi
leaq 0x20(%rsp), %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x254c
movl %r12d, %edi
shll $0x5, %edi
addq 0x40060(%r14), %rdi
leaq 0x20(%rsp), %rbp
movq %rbp, %rsi
callq 0x2190
movq (%rbp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x42a6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
shll $0x5, %r12d
addq 0x40060(%r14), %r12
movq %rsp, %rdi
movq %r12, %rsi
callq 0x20b0
jmp 0x4361
cmpl $0x800, %r15d           # imm = 0x800
setae %cl
movl %ebx, %eax
andl $0xc0000, %eax          # imm = 0xC0000
sete %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0x42fb
movl %ebx, %esi
andl $0x7ff, %esi            # imm = 0x7FF
shll $0x5, %esi
addq 0x40048(%r14), %rsi
movq %rsp, %rdi
callq 0x20b0
jmp 0x4361
cmpl $0x40000, %eax          # imm = 0x40000
jne 0x431d
leaq 0x13a7(%rip), %rcx      # 0x56b0
movq %rsp, %rdi
movl $0x5, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
jmp 0x4361
testl $0x80000, %ebx          # imm = 0x80000
cmovel %r15d, %edx
testl %edx, %edx
je 0x4361
cmpl $0x8, %edx
jb 0x44d7
cmpl $0x4, %ebp
je 0x44d7
cmpl $0x8, %ebp
jne 0x44ef
addl $-0x40, %edx
leaq 0x1366(%rip), %rsi      # 0x56b6
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41c7
shrl $0x14, %ebx
movl 0x34(%r14), %eax
testl %eax, %eax
sete %cl
cmpl %eax, %ebx
setne %al
orb %cl, %al
jne 0x43bb
cmpl $0xa0000, 0x8(%r13)     # imm = 0xA0000
jne 0x439f
leaq 0x40(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x132c(%rip), %rcx      # 0x56bc
movl $0x4, %r8d
xorl %esi, %esi
callq 0x21f0
jmp 0x43bb
addl 0x38(%r14), %r15d
shlq $0x5, %r15
addq 0x40060(%r14), %r15
xorl %ebx, %ebx
movq %rsp, %rdi
movq %r15, %rsi
callq 0x20b0
cmpb $0x1, 0x40(%r14)
jne 0x445b
movq (%rsp), %r15
cmpb $0x2a, (%r15)
jne 0x445b
movq %r15, %rdi
movl $0x2b, %esi
callq 0x2080
testq %rax, %rax
jne 0x445b
incq %r15
leaq 0x60(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x21c0
movq (%r12), %rcx
subq (%rsp), %rcx
cmpq $0x5, %rcx
jl 0x445b
leaq 0x12ae(%rip), %rcx      # 0x56c1
leaq 0x12ac(%rip), %rsi      # 0x56c6
cmpb $0x0, 0x42(%r14)
cmovneq %rcx, %rsi
leaq 0x20(%rsp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x254c
movq %rsp, %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x2190
movq (%r14), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x445b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
testl %ebx, %ebx
je 0x4471
leaq 0x1266(%rip), %rdi      # 0x56cc
movl %ebx, %esi
xorl %eax, %eax
callq 0x2030
jmp 0x447b
movl $0x2c, %edi
callq 0x21b0
leaq 0x10(%rsp), %rbx
movq 0x40(%rsp), %rsi
movq (%rsp), %rdx
leaq 0x1240(%rip), %rdi      # 0x56d0
xorl %eax, %eax
callq 0x2030
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x44ad
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44c8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2140
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11e5(%rip), %rsi      # 0x56c3
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41c7
leaq 0x11cd(%rip), %rax      # 0x56c3
leaq 0x11cb(%rip), %rsi      # 0x56c8
cmpb $0x0, 0x42(%r14)
cmovneq %rax, %rsi
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41c7
jmp 0x452a
jmp 0x452a
jmp 0x452a
jmp 0x452a
jmp 0x452a
jmp 0x452a
movq %rax, %rbx
jmp 0x4548
jmp 0x452a
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4548
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4563
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x2220
nop