// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movl %edx, %r12d
movq %rdi, (%rsp)
movl %edx, %r13d
shrl $0x14, %r13d
movl %edx, %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %edx, %r15d
shll $0xd, %r15d
sarl $0x1f, %r15d
andl $0x7000, %r15d          # imm = 0x7000
orl %eax, %r15d
movl %edx, %ebp
andl $0x7fff, %ebp           # imm = 0x7FFF
leaq 0x443f(%rip), %rcx      # 0x8190
movq %rcx, %r14
movl -0x4(%rcx), %eax
testl %eax, %eax
je 0x3d68
andl %r12d, %eax
leaq 0x18(%r14), %rcx
cmpl -0x8(%r14), %eax
jne 0x3d51
movl (%r14), %ebx
movq -0x10(%r14), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x3360
testl %ebx, %ebx
jne 0x3de4
movl %r13d, 0xc(%rsp)
xorl %eax, %eax
btl $0x13, %r12d
pushq $0x7f
popq %rcx
pushq $0x1f
popq %rdi
cmovael %ecx, %edi
leaq 0x190a(%rip), %rcx      # 0x56a8
leaq 0x18ff(%rip), %rsi      # 0x56a4
cmovaeq %rcx, %rsi
setb %al
leal (%rax,%rax,2), %ecx
orl $0xc, %ecx
movl %r12d, %edx
shrl %cl, %edx
andl %edi, %edx
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x23cc
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20b0
movl 0xc(%rsp), %r13d
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
btl $0x13, %r12d
setae %al
cmpl $0x7800, %ebp           # imm = 0x7800
setb %cl
orb %al, %cl
jne 0x3e5a
andl $0x7ff, %r12d           # imm = 0x7FF
movq (%rsp), %rax
movq 0x40048(%rax), %rax
shll $0x5, %r12d
movq (%rax,%r12), %rdx
leaq 0x1882(%rip), %rsi      # 0x56ad
leaq 0x30(%rsp), %rdi
xorl %eax, %eax
callq 0x23cc
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %r12
movq %r12, %rsi
callq 0x21a0
movq %r12, %rdi
callq 0x20b0
movq (%rsp), %r12
jmp 0x3fd8
movl %r13d, 0xc(%rsp)
btl $0x13, %r12d
setae %al
cmpl $0x4000, %ebp           # imm = 0x4000
setb %cl
orb %al, %cl
jne 0x3f2b
movl %r12d, %r13d
andl $0x3fff, %r13d          # imm = 0x3FFF
movq (%rsp), %rcx
movq 0x40060(%rcx), %rax
movq 0x40068(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r13, %rcx
jbe 0x3f2b
movl %r13d, %ecx
shll $0x5, %ecx
cmpq $0x0, 0x8(%rax,%rcx)
movq (%rsp), %r12
jne 0x3f0d
cmpl $0x1000, %r13d          # imm = 0x1000
leaq 0x160e(%rip), %rax      # 0x54d2
leaq 0x160e(%rip), %rsi      # 0x54d9
cmovbq %rax, %rsi
leaq 0x30(%rsp), %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x23cc
movl %r13d, %edi
shll $0x5, %edi
addq 0x40060(%r12), %rdi
leaq 0x30(%rsp), %r12
movq %r12, %rsi
callq 0x21a0
movq %r12, %rdi
movq (%rsp), %r12
callq 0x20b0
movq 0x40060(%r12), %rax
shll $0x5, %r13d
addq %rax, %r13
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x20d0
movl 0xc(%rsp), %r13d
jmp 0x3fd8
cmpl $0x800, %r15d           # imm = 0x800
setae %cl
movl %r12d, %eax
andl $0xc0000, %eax          # imm = 0xC0000
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3f74
andl $0x7ff, %r12d           # imm = 0x7FF
shll $0x5, %r12d
movq (%rsp), %rax
addq 0x40048(%rax), %r12
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rax, %r12
callq 0x20d0
movl 0xc(%rsp), %r13d
jmp 0x3fd8
cmpl $0x40000, %eax          # imm = 0x40000
movl 0xc(%rsp), %r13d
jne 0x3f97
leaq 0x1729(%rip), %rsi      # 0x56b0
leaq 0x10(%rsp), %rdi
callq 0x22a0
movq (%rsp), %r12
jmp 0x3fd8
testl $0x80000, %r12d         # imm = 0x80000
cmovel %r15d, %ebp
testl %ebp, %ebp
movq (%rsp), %r12
je 0x3fd8
cmpl $0x4, %ebx
setne %al
cmpl $0x8, %ebp
setae %cl
testb %al, %cl
jne 0x4115
leaq 0x16fe(%rip), %rsi      # 0x56c3
leaq 0x30(%rsp), %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x23cc
jmp 0x3e37
movl 0x34(%r12), %eax
testl %eax, %eax
sete %cl
cmpl %eax, %r13d
setne %al
orb %cl, %al
jne 0x402a
cmpl $0xa0000, -0x8(%r14)    # imm = 0xA0000
jne 0x4009
leaq 0x16bf(%rip), %rsi      # 0x56bc
leaq 0x50(%rsp), %rdi
callq 0x22a0
jmp 0x402a
addl 0x38(%r12), %r15d
shlq $0x5, %r15
addq 0x40060(%r12), %r15
xorl %r13d, %r13d
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x20d0
cmpb $0x1, 0x40(%r12)
jne 0x40b8
movq 0x10(%rsp), %r15
cmpb $0x2a, (%r15)
jne 0x40b8
pushq $0x2b
popq %rsi
movq %r15, %rdi
callq 0x2080
testq %rax, %rax
jne 0x40b8
incq %r15
leaq 0x70(%rsp), %r12
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x21f0
movq (%r12), %rcx
subq 0x10(%rsp), %rcx
cmpq $0x5, %rcx
jl 0x40b8
leaq 0x1644(%rip), %rcx      # 0x56c1
leaq 0x1642(%rip), %rsi      # 0x56c6
movq (%rsp), %rdx
cmpb $0x0, 0x42(%rdx)
cmovneq %rcx, %rsi
leaq 0x30(%rsp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x23cc
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x20b0
testl %r13d, %r13d
je 0x40d0
leaq 0x1608(%rip), %rdi      # 0x56cc
movl %r13d, %esi
xorl %eax, %eax
callq 0x2030
jmp 0x40d8
pushq $0x2c
popq %rdi
callq 0x21e0
leaq 0x50(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x10(%rsp), %r14
movq (%r14), %rdx
leaq 0x15e1(%rip), %rdi      # 0x56d0
xorl %eax, %eax
callq 0x2030
movq %r14, %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x20b0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x8, %ebx
jne 0x4137
addl $-0x40, %ebp
leaq 0x1592(%rip), %rsi      # 0x56b6
leaq 0x30(%rsp), %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x23cc
jmp 0x3e37
leaq 0x1585(%rip), %rax      # 0x56c3
leaq 0x1583(%rip), %rsi      # 0x56c8
cmpb $0x0, 0x42(%r12)
cmovneq %rax, %rsi
leaq 0x30(%rsp), %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x23cc
jmp 0x3e37
jmp 0x4175
jmp 0x4175
jmp 0x4175
jmp 0x4175
jmp 0x4175
jmp 0x4175
movq %rax, %rbx
jmp 0x4182
jmp 0x4175
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20b0
leaq 0x50(%rsp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2280