// File: /workspace/github_c_makefile_star2_O3/aap[P]rx-0/pdp1/mach.c
// Function: disasm
char*
disasm(Word w)
{
	static char s[100];
	char *p;
	int op, y;
	char *opstr, *sym;;

	op = w>>12 & 076;
	y = w & ADDRMASK;
	p = s;
	memset(s, 0, 100);
	switch(op){
	case 000:
	case 012: // jfd
	case 014:
	case 036:
	case 074:
		// no instruction
		sym = findsym(w);
		if(sym)
			p += sprintf(p, "%s", sym);
		else
			p += sprintf(p, "%o", w);
		break;
	case 002: opstr = "and"; goto memop;
	case 004: opstr = "ior"; goto memop;
	case 006: opstr = "xor"; goto memop;
	case 010: opstr = "xct"; goto memop;
	case 016: opstr = w & 010000 ? "jda" : "cal"; w &= ~010000; goto memop;
	case 020: opstr = "lac"; goto memop;
	case 022: opstr = "lio"; goto memop;
	case 024: opstr = "dac"; goto memop;
	case 026: opstr = "dap"; goto memop;
	case 030: opstr = "dip"; goto memop;
	case 032: opstr = "dio"; goto memop;
	case 034: opstr = "dzm"; goto memop;
	case 040: opstr = "add"; goto memop;
	case 042: opstr = "sub"; goto memop;
	case 044: opstr = "idx"; goto memop;
	case 046: opstr = "isp"; goto memop;
	case 050: opstr = "sad"; goto memop;
	case 052: opstr = "sas"; goto memop;
	case 054: opstr = "mus"; goto memop;
	case 056: opstr = "dis"; goto memop;
	case 060: opstr = "jmp"; goto memop;
	case 062: opstr = "jsp"; goto memop;
	case 064:	// skip
		if(y == 02000)
			p += sprintf(p, "spi ");
		else if(y == 01000)
			p += sprintf(p, "szo ");
		else if(y == 0400)
			p += sprintf(p, "sma ");
		else if(y == 0200)
			p += sprintf(p, "spa ");
		else if(y == 0100)
			p += sprintf(p, "sza ");
		else if((y&07770) == 0 && (y&7))
			p += sprintf(p, "szf %o ", y&7);
		else if((y&07707) == 0 && (y&070))
			p += sprintf(p, "szs %o ", y&070);
		else
			p += sprintf(p, "skp %o ", y);
		if(w & 010000)
			p += sprintf(p, "i ");
		break;
	case 066:	// shift
		p += sprintf(p, "%c", w&04000 ? 's' : 'r');
		p += sprintf(p, "%c", "xaic"[y>>9 & 3]);
		p += sprintf(p, "%c ", w&010000 ? 'r' : 'l');
		p += sprintf(p, "%o", y & 0777);
		break;
	case 070: opstr = "law";
	memop:
		p += sprintf(p, "%s ", opstr);
		if(w & 010000)
			p += sprintf(p, "i ");
		sym = findsym(y);
		if(sym)
			p += sprintf(p, "%s", sym);
		else
			p += sprintf(p, "%o", y);
		break;
	case 072:	// iot
		p += sprintf(p, "iot %o", w &017777);
		break;
	case 076:	// opr
		if(y == 04000)
			p += sprintf(p, "cli ");
		else if(y == 02200)
			p += sprintf(p, "lat ");
		else if(y == 01000)
			p += sprintf(p, "cma ");
		else if(y == 0400)
			p += sprintf(p, "hlt ");
		else if(y == 00200)
			p += sprintf(p, "cla ");
		else if(y == 00300)
			p += sprintf(p, "lap ");
		else if((y&07770) == 0 && (y&7))
			p += sprintf(p, "clf %o ", y&7);
		else if((y&07770) == 00010 && (y&7))
			p += sprintf(p, "stf %o ", y&7);
		else if(y == 0)
			p += sprintf(p, "nop ");
		else
			p += sprintf(p, "opr %o ", y);
		if(w & 010000)
			p += sprintf(p, "i ");
		break;
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebx
movl %edi, %eax
shrl $0xc, %eax
andl $0x3e, %eax
movl %edi, %r14d
andl $0xfff, %r14d           # imm = 0xFFF
xorps %xmm0, %xmm0
movaps %xmm0, 0xe45a(%rip)     # 0x12660
movaps %xmm0, 0xe443(%rip)     # 0x12650
movaps %xmm0, 0xe42c(%rip)     # 0x12640
movaps %xmm0, 0xe415(%rip)     # 0x12630
movaps %xmm0, 0xe3fe(%rip)     # 0x12620
movaps %xmm0, 0xe3e7(%rip)     # 0x12610
movl $0x0, 0xe43d(%rip)      # 0x12670
leaq 0x2046(%rip), %rcx      # 0x6280
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %ebx, %edi
callq 0x292d
leaq 0xe3bf(%rip), %rdi      # 0x12610
testq %rax, %rax
je 0x448f
movq %rax, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2090
cmpl $0xff, %r14d
jle 0x4558
cmpl $0x100, %r14d           # imm = 0x100
je 0x457d
cmpl $0x200, %r14d           # imm = 0x200
je 0x4593
cmpl $0x400, %r14d           # imm = 0x400
jne 0x45bf
movb $0x0, 0xe36f(%rip)      # 0x12614
movl $0x20697073, 0xe361(%rip) # imm = 0x20697073
jmp 0x466a
leaq 0x21f5(%rip), %rdx      # 0x64b0
jmp 0x44aa
leaq 0x21d1(%rip), %rdx      # 0x6498
jmp 0x44aa
leaq 0x21c1(%rip), %rdx      # 0x6494
jmp 0x44aa
leaq 0x21bd(%rip), %rdx      # 0x649c
jmp 0x44aa
leaq 0x21f9(%rip), %rdx      # 0x64e4
jmp 0x44aa
leaq 0x21c5(%rip), %rdx      # 0x64bc
jmp 0x44aa
leaq 0x21dd(%rip), %rdx      # 0x64e0
jmp 0x44aa
leaq 0x2199(%rip), %rdx      # 0x64a8
jmp 0x44aa
leaq 0x2199(%rip), %rdx      # 0x64b4
jmp 0x44aa
cmpl $0x1ff, %r14d           # imm = 0x1FF
jg 0x451b
cmpl $0x80, %r14d
je 0x45ea
cmpl $0xc0, %r14d
je 0x4646
cmpl $0x100, %r14d           # imm = 0x100
jne 0x4610
movb $0x0, 0xe2b9(%rip)      # 0x12614
movl $0x20746c68, 0xe2ab(%rip) # imm = 0x20746C68
jmp 0x466a
leaq 0x2153(%rip), %rdx      # 0x64c4
jmp 0x44aa
leaq 0x2153(%rip), %rdx      # 0x64d0
jmp 0x44aa
leaq 0x214b(%rip), %rdx      # 0x64d4
jmp 0x44aa
leaq 0x2133(%rip), %rdx      # 0x64c8
jmp 0x44aa
andl $0x1fff, %ebx           # imm = 0x1FFF
leaq 0xe269(%rip), %rdi      # 0x12610
leaq 0x2180(%rip), %rsi      # 0x652e
jmp 0x4496
leaq 0x20d6(%rip), %rdx      # 0x6490
jmp 0x44aa
btl $0xc, %ebx
leaq 0x20da(%rip), %rax      # 0x64a4
leaq 0x20cf(%rip), %rdx      # 0x64a0
cmovaeq %rax, %rdx
xorl %ebx, %ebx
jmp 0x44aa
leaq 0x20c9(%rip), %rdx      # 0x64ac
jmp 0x44aa
leaq 0x20e9(%rip), %rdx      # 0x64d8
jmp 0x44aa
leaq 0x20bd(%rip), %rdx      # 0x64b8
jmp 0x44aa
leaq 0x20c5(%rip), %rdx      # 0x64cc
jmp 0x44aa
leaq 0x20ad(%rip), %rdx      # 0x64c0
jmp 0x44aa
leaq 0x20bd(%rip), %rdx      # 0x64dc
jmp 0x44aa
btl $0xb, %ebx
setae %al
xorb $0x73, %al
movb %al, 0xe1dd(%rip)       # 0x12610
leaq 0xe1d6(%rip), %r14      # 0x12610
movl %ebx, %eax
shrl $0x9, %eax
andl $0x3, %eax
leaq 0x20d4(%rip), %rcx      # 0x651d
movb (%rax,%rcx), %al
movb %al, 0xe1bf(%rip)       # 0x12611
movb $0x0, 0xe1b9(%rip)      # 0x12612
leaq 0xe1b2(%rip), %rdi      # 0x12612
btl $0xc, %ebx
movl $0x6c, %eax
movl $0x72, %edx
cmovael %eax, %edx
leaq 0x20aa(%rip), %rsi      # 0x6522
xorl %eax, %eax
callq 0x22d0
cltq
leaq (%rax,%r14), %rdi
addq $0x2, %rdi
andl $0x1ff, %ebx            # imm = 0x1FF
leaq 0x209c(%rip), %rsi      # 0x6532
movl %ebx, %edx
jmp 0x4504
leaq 0x2085(%rip), %rdx      # 0x6526
jmp 0x44aa
leaq 0x203e(%rip), %rdx      # 0x64e8
leaq 0xe15f(%rip), %r12      # 0x12610
leaq 0x2072(%rip), %rsi      # 0x652a
movq %r12, %rdi
xorl %eax, %eax
callq 0x22d0
movslq %eax, %r15
addq %r12, %r15
btl $0xc, %ebx
jae 0x44dd
movb $0x0, 0x2(%r15)
movw $0x2069, (%r15)         # imm = 0x2069
addq $0x2, %r15
movl %r14d, %edi
callq 0x292d
testq %rax, %rax
je 0x44f7
movq %r15, %rdi
movq %rax, %rsi
callq 0x2090
jmp 0x450b
leaq 0x2034(%rip), %rsi      # 0x6532
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22d0
leaq 0xe0fe(%rip), %rax      # 0x12610
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x200, %r14d           # imm = 0x200
je 0x45fd
cmpl $0x480, %r14d           # imm = 0x480
je 0x4659
cmpl $0x800, %r14d           # imm = 0x800
jne 0x4610
movb $0x0, 0xe0cb(%rip)      # 0x12614
movl $0x20696c63, 0xe0bd(%rip) # imm = 0x20696C63
jmp 0x466a
cmpl $0x40, %r14d
je 0x45a9
cmpl $0x80, %r14d
jne 0x45bf
movb $0x0, 0xe0a6(%rip)      # 0x12614
movl $0x20617073, 0xe098(%rip) # imm = 0x20617073
jmp 0x466a
movb $0x0, 0xe090(%rip)      # 0x12614
movl $0x20616d73, 0xe082(%rip) # imm = 0x20616D73
jmp 0x466a
movb $0x0, 0xe07a(%rip)      # 0x12614
movl $0x206f7a73, 0xe06c(%rip) # imm = 0x206F7A73
jmp 0x466a
movb $0x0, 0xe064(%rip)      # 0x12614
movl $0x20617a73, 0xe056(%rip) # imm = 0x20617A73
jmp 0x466a
testl $0xff8, %ebx            # imm = 0xFF8
je 0x4689
testl $0xfc7, %ebx            # imm = 0xFC7
je 0x46a4
leaq 0xe032(%rip), %r15      # 0x12610
leaq 0x1f30(%rip), %rsi      # 0x6515
jmp 0x46f8
movb $0x0, 0xe023(%rip)      # 0x12614
movl $0x20616c63, 0xe015(%rip) # imm = 0x20616C63
jmp 0x466a
movb $0x0, 0xe010(%rip)      # 0x12614
movl $0x20616d63, 0xe002(%rip) # imm = 0x20616D63
jmp 0x466a
movl %ebx, %eax
andl $0xff8, %eax            # imm = 0xFF8
cmpl $0x8, %eax
je 0x46bf
testl %eax, %eax
jne 0x46e5
movl %ebx, %edx
andl $0x7, %edx
je 0x46e5
leaq 0xdfd6(%rip), %r14      # 0x12610
leaq 0x1f12(%rip), %rsi      # 0x6553
jmp 0x46d4
movb $0x0, 0xdfc7(%rip)      # 0x12614
movl $0x2070616c, 0xdfb9(%rip) # imm = 0x2070616C
jmp 0x466a
movb $0x0, 0xdfb4(%rip)      # 0x12614
movl $0x2074616c, 0xdfa6(%rip) # imm = 0x2074616C
leaq 0xdfa3(%rip), %rax      # 0x12614
btl $0xc, %ebx
jae 0x450b
movb $0x0, 0x2(%rax)
movw $0x2069, (%rax)         # imm = 0x2069
jmp 0x450b
movl %ebx, %edx
andl $0x7, %edx
je 0x45cb
leaq 0xdf75(%rip), %r14      # 0x12610
leaq 0x1e63(%rip), %rsi      # 0x6505
jmp 0x46d4
movl %ebx, %edx
andl $0x38, %edx
je 0x45d7
leaq 0xdf5a(%rip), %r14      # 0x12610
leaq 0x1e50(%rip), %rsi      # 0x650d
jmp 0x46d4
movl %ebx, %edx
andl $0x7, %edx
je 0x46e5
leaq 0xdf43(%rip), %r14      # 0x12610
leaq 0x1e87(%rip), %rsi      # 0x655b
movq %r14, %rdi
xorl %eax, %eax
callq 0x22d0
cltq
addq %r14, %rax
jmp 0x4671
testl %r14d, %r14d
je 0x470f
leaq 0xdf1f(%rip), %r15      # 0x12610
leaq 0x1e70(%rip), %rsi      # 0x6568
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x22d0
cltq
addq %r15, %rax
jmp 0x4671
movb $0x0, 0xdefe(%rip)      # 0x12614
movl $0x20706f6e, 0xdef0(%rip) # imm = 0x20706F6E
jmp 0x466a