// File: /workspace/github_cpp_makefile_star2_O3/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 0x40bb(%rip), %eax      # 0x814c
leaq 0x40a8(%rip), %r13      # 0x8140
testl %eax, %eax
je 0x40ae
andl %ebx, %eax
cmpl 0x8(%r13), %eax
je 0x40ae
movl 0x24(%r13), %eax
addq $0x18, %r13
jmp 0x4098
movl 0x10(%r13), %ebp
movq (%r13), %rsi
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x3714
testl %ebp, %ebp
jne 0x412f
xorl %eax, %eax
btl $0x13, %ebx
movl $0x7f, %ecx
movl $0x1f, %edi
cmovael %ecx, %edi
leaq 0x15c7(%rip), %rcx      # 0x56a8
leaq 0x15bc(%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 0x412f
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 0x41d7
movl %ebx, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movq 0x40048(%r14), %rcx
shll $0x5, %eax
movq (%rcx,%rax), %rdx
leaq 0x1516(%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 0x4340
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x4340
btl $0x13, %ebx
setae %al
cmpl $0x4000, %edx           # imm = 0x4000
setb %cl
orb %al, %cl
jne 0x42a0
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 0x42a0
movl %r12d, %ecx
shll $0x5, %ecx
cmpq $0x0, 0x8(%rax,%rcx)
jne 0x4289
cmpl $0x1000, %r12d          # imm = 0x1000
leaq 0x129f(%rip), %rax      # 0x54d2
leaq 0x129f(%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 0x4282
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
movq 0x40060(%r14), %rax
shll $0x5, %r12d
addq %rax, %r12
movq %rsp, %rdi
movq %r12, %rsi
callq 0x20b0
jmp 0x4340
cmpl $0x800, %r15d           # imm = 0x800
setae %cl
movl %ebx, %eax
andl $0xc0000, %eax          # imm = 0xC0000
sete %sil
andb %cl, %sil
cmpb $0x1, %sil
jne 0x42da
movl %ebx, %esi
andl $0x7ff, %esi            # imm = 0x7FF
shll $0x5, %esi
addq 0x40048(%r14), %rsi
movq %rsp, %rdi
callq 0x20b0
jmp 0x4340
cmpl $0x40000, %eax          # imm = 0x40000
jne 0x42fc
leaq 0x13c8(%rip), %rcx      # 0x56b0
movq %rsp, %rdi
movl $0x5, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
jmp 0x4340
testl $0x80000, %ebx          # imm = 0x80000
cmovel %r15d, %edx
testl %edx, %edx
je 0x4340
cmpl $0x8, %edx
jb 0x44b6
cmpl $0x4, %ebp
je 0x44b6
cmpl $0x8, %ebp
jne 0x44ce
addl $-0x40, %edx
leaq 0x1387(%rip), %rsi      # 0x56b6
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41a3
shrl $0x14, %ebx
movl 0x34(%r14), %eax
testl %eax, %eax
sete %cl
cmpl %eax, %ebx
setne %al
orb %cl, %al
jne 0x439a
cmpl $0xa0000, 0x8(%r13)     # imm = 0xA0000
jne 0x437e
leaq 0x40(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x134d(%rip), %rcx      # 0x56bc
movl $0x4, %r8d
xorl %esi, %esi
callq 0x21f0
jmp 0x439a
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 0x443a
movq (%rsp), %r15
cmpb $0x2a, (%r15)
jne 0x443a
movq %r15, %rdi
movl $0x2b, %esi
callq 0x2080
testq %rax, %rax
jne 0x443a
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 0x443a
leaq 0x12cf(%rip), %rcx      # 0x56c1
leaq 0x12cd(%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 0x443a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2140
testl %ebx, %ebx
je 0x4450
leaq 0x1287(%rip), %rdi      # 0x56cc
movl %ebx, %esi
xorl %eax, %eax
callq 0x2030
jmp 0x445a
movl $0x2c, %edi
callq 0x21b0
leaq 0x10(%rsp), %rbx
movq 0x40(%rsp), %rsi
movq (%rsp), %rdx
leaq 0x1261(%rip), %rdi      # 0x56d0
xorl %eax, %eax
callq 0x2030
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x448c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44a7
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 0x1206(%rip), %rsi      # 0x56c3
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41a3
leaq 0x11ee(%rip), %rax      # 0x56c3
leaq 0x11ec(%rip), %rsi      # 0x56c8
cmpb $0x0, 0x42(%r14)
cmovneq %rax, %rsi
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x254c
jmp 0x41a3
jmp 0x4509
jmp 0x4509
jmp 0x4509
jmp 0x4509
jmp 0x4509
jmp 0x4509
movq %rax, %rbx
jmp 0x4527
jmp 0x4509
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4527
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4542
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x2220