// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/u_kb11a.c
// Function: ir_decodeXXXX
void
ir_decodeXXXX(KB11A *kb)
{
	printf("IR/%06o\n", kb->c.ir);

	// IRCH
	int irch_bin = (kb->c.ir&0070000) != 0070000 &&
		(kb->c.ir&0070000) != 0000000;
	int irch_sub = (kb->c.ir&0170000) == 0160000;
	int irch_subroma;
	switch(kb->c.ir & 0070000){
	case 0000000: irch_subroma = kb->c.ir>>6 & 017; break;
	case 0010000: irch_subroma = 021; break;
	case 0020000: irch_subroma = 022; break;
	case 0030000: irch_subroma = 023; break;
	case 0040000: irch_subroma = 024; break;
	case 0050000: irch_subroma = 025; break;
	case 0060000: irch_subroma = irch_sub ? 020 : 026; break;
	case 0070000: irch_subroma = 030 | kb->c.ir>>9 & 7; break;
	}
	word irch_subword = subrom[irch_subroma];
	kb->alucntl = alucntl[irch_subroma];
	int ircc_rom_dec_ena = (kb->c.ir&0170000) == 0070000 ||
		(kb->c.ir&0077000) == 0005000 ||
		(kb->c.ir&0077000) == 0006000 ||
		irch_bin;

	// IRCB
	int ircb_swab = (kb->c.ir&0177700) == 0000300;
	int ircb_movb = (kb->c.ir&0170000) == 0110000;
	int ircb_fclass = (kb->c.ir&0170000) == 0170000;
	int ircb_jmp_jsr = (kb->c.ir&0177700) == 0000100 ||
		(kb->c.ir&0177000) == 0004000;
	int ircb_fjclass = ircb_fclass || ircb_jmp_jsr;
	int ircb_neg_b = (kb->c.ir&0077700) == 0005400;
	int ircb_obd_asrb_rorb = kb->grab_obd &&
		((kb->c.ir&0177700) == 0106000 ||
		 (kb->c.ir&0177700) == 0106200);
	int ircb_mul_ashc_mfp = ircc_rom_dec_ena &&
		irch_subword&SUBROM_R_MUL_ASHC_MFP;
	int ircb_part_pclass = ircc_rom_dec_ena &&
		irch_subword&SUBROM_R_PART_PCLASS;
	int ircb_pclass = ircb_part_pclass || ircb_swab || ircb_movb;
	int ircb_iclass = ircc_rom_dec_ena &&
		irch_subword&SUBROM_R_ICLASS;
	int ircb_kclass = ircc_rom_dec_ena &&
		irch_subword&SUBROM_R_KCLASS;

	// IRCC
	int ircc_mfp_mtp = ircc_rom_dec_ena && irch_subword&SUBROM_R_MFP_MTP;
	int ircc_dm0_mfp_mtp = ircc_mfp_mtp && (kb->c.ir&0000077) == 0000000;
	int ircc_oclass = (kb->c.ir&0170000) == 0010000 ||
		(kb->c.ir&0077700) == 0006600;

	// IRCD
	int nobyte = (kb->c.ir&0070000) == 0060000 ||
		(kb->c.ir&0177400) == 0106400;
	int ircd_wdin = (kb->c.ir&0100000) == 0 || nobyte;
	int ircd_byin = (kb->c.ir&0100000) != 0 && !nobyte && !ircb_fclass;
	int ircd_sbyn = ircd_byin &&
		(kb->c.ir&0077000) != 0005000 &&
		(kb->c.ir&0077000) != 0006000;
	int ircd_rtt = kb->c.ir == 0000006;
	// TODO: these are inhibited by TMCB TRAP INH
	int ircd_iot = kb->c.ir == 0000004;
	int ircd_opcode3 = kb->c.ir == 0000003;
	int ircd_trap = (kb->c.ir&01777400) == 0104400;
	int ircd_emt = (kb->c.ir&01777400) == 0104000;

	printf("%o %o\n", irch_subroma, irch_subword);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %esi
leaq 0x34ac(%rip), %rdi      # 0x58ba
movb $0x0, %al
callq 0x2030
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x7000, %ecx           # imm = 0x7000
xorl %eax, %eax
cmpl $0x7000, %ecx           # imm = 0x7000
movb %al, -0x7d(%rbp)
je 0x2446
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7000, %eax           # imm = 0x7000
cmpl $0x0, %eax
setne %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
subl $0xe000, %eax           # imm = 0xE000
sete %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7000, %eax           # imm = 0x7000
movl %eax, -0x84(%rbp)
je 0x24ed
jmp 0x2484
movl -0x84(%rbp), %eax
subl $0x1000, %eax           # imm = 0x1000
je 0x2500
jmp 0x2493
movl -0x84(%rbp), %eax
subl $0x2000, %eax           # imm = 0x2000
je 0x2509
jmp 0x24a2
movl -0x84(%rbp), %eax
subl $0x3000, %eax           # imm = 0x3000
je 0x2512
jmp 0x24b1
movl -0x84(%rbp), %eax
subl $0x4000, %eax           # imm = 0x4000
je 0x251b
jmp 0x24c0
movl -0x84(%rbp), %eax
subl $0x5000, %eax           # imm = 0x5000
je 0x2524
jmp 0x24cf
movl -0x84(%rbp), %eax
subl $0x6000, %eax           # imm = 0x6000
je 0x252d
jmp 0x24de
movl -0x84(%rbp), %eax
subl $0x7000, %eax           # imm = 0x7000
je 0x2545
jmp 0x2559
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
sarl $0x6, %eax
andl $0xf, %eax
movl %eax, -0x14(%rbp)
jmp 0x2559
movl $0x11, -0x14(%rbp)
jmp 0x2559
movl $0x12, -0x14(%rbp)
jmp 0x2559
movl $0x13, -0x14(%rbp)
jmp 0x2559
movl $0x14, -0x14(%rbp)
jmp 0x2559
movl $0x15, -0x14(%rbp)
jmp 0x2559
movl -0x10(%rbp), %edx
movl $0x16, %eax
movl $0x10, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0x2559
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
sarl $0x9, %eax
andl $0x7, %eax
orl $0x18, %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x5aec(%rip), %rax      # 0x8050
movw (%rax,%rcx,2), %ax
movw %ax, -0x16(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x5b19(%rip), %rax      # 0x8090
movb (%rax,%rcx), %cl
movq -0x8(%rbp), %rax
movb %cl, 0x208(%rax)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xf000, %ecx           # imm = 0xF000
movb $0x1, %al
cmpl $0x7000, %ecx           # imm = 0x7000
movb %al, -0x85(%rbp)
je 0x25eb
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x7e00, %ecx           # imm = 0x7E00
movb $0x1, %al
cmpl $0xa00, %ecx            # imm = 0xA00
movb %al, -0x85(%rbp)
je 0x25eb
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x7e00, %ecx           # imm = 0x7E00
movb $0x1, %al
cmpl $0xc00, %ecx            # imm = 0xC00
movb %al, -0x85(%rbp)
je 0x25eb
cmpl $0x0, -0xc(%rbp)
setne %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xffc0, %eax           # imm = 0xFFC0
cmpl $0xc0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x9000, %eax           # imm = 0x9000
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xf000, %eax           # imm = 0xF000
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xffc0, %ecx           # imm = 0xFFC0
movb $0x1, %al
cmpl $0x40, %ecx
movb %al, -0x86(%rbp)
je 0x2686
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xfe00, %eax           # imm = 0xFE00
cmpl $0x800, %eax            # imm = 0x800
sete %al
movb %al, -0x86(%rbp)
movb -0x86(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movb $0x1, %al
cmpl $0x0, -0x28(%rbp)
movb %al, -0x87(%rbp)
jne 0x26af
cmpl $0x0, -0x2c(%rbp)
setne %al
movb %al, -0x87(%rbp)
movb -0x87(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7fc0, %eax           # imm = 0x7FC0
cmpl $0xb00, %eax            # imm = 0xB00
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x230(%rcx)
movb %al, -0x88(%rbp)
je 0x2734
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xffc0, %ecx           # imm = 0xFFC0
movb $0x1, %al
cmpl $0x8c00, %ecx           # imm = 0x8C00
movb %al, -0x89(%rbp)
je 0x2728
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xffc0, %eax           # imm = 0xFFC0
cmpl $0x8c80, %eax           # imm = 0x8C80
sete %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
movb %al, -0x88(%rbp)
movb -0x88(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x8a(%rbp)
je 0x2765
movzwl -0x16(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x8b(%rbp)
je 0x2796
movzwl -0x16(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
setne %al
movb %al, -0x8b(%rbp)
movb -0x8b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x40(%rbp)
movb $0x1, %al
cmpl $0x0, -0x40(%rbp)
movb %al, -0x8c(%rbp)
jne 0x27cd
movb $0x1, %al
cmpl $0x0, -0x20(%rbp)
movb %al, -0x8c(%rbp)
jne 0x27cd
cmpl $0x0, -0x24(%rbp)
setne %al
movb %al, -0x8c(%rbp)
movb -0x8c(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x44(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x8d(%rbp)
je 0x27fe
movzwl -0x16(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
setne %al
movb %al, -0x8d(%rbp)
movb -0x8d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x48(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x8e(%rbp)
je 0x282f
movzwl -0x16(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x8e(%rbp)
movb -0x8e(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x8f(%rbp)
je 0x2860
movzwl -0x16(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
setne %al
movb %al, -0x8f(%rbp)
movb -0x8f(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x50(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x50(%rbp)
movb %al, -0x90(%rbp)
je 0x2893
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x3f, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x90(%rbp)
movb -0x90(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xf000, %ecx           # imm = 0xF000
movb $0x1, %al
cmpl $0x1000, %ecx           # imm = 0x1000
movb %al, -0x91(%rbp)
je 0x28da
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7fc0, %eax           # imm = 0x7FC0
cmpl $0xd80, %eax            # imm = 0xD80
sete %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x7000, %ecx           # imm = 0x7000
movb $0x1, %al
cmpl $0x6000, %ecx           # imm = 0x6000
movb %al, -0x92(%rbp)
je 0x2921
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0xff00, %eax           # imm = 0xFF00
cmpl $0x8d00, %eax           # imm = 0x8D00
sete %al
movb %al, -0x92(%rbp)
movb -0x92(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x8000, %ecx           # imm = 0x8000
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x93(%rbp)
je 0x2957
cmpl $0x0, -0x5c(%rbp)
setne %al
movb %al, -0x93(%rbp)
movb -0x93(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x8000, %ecx           # imm = 0x8000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x94(%rbp)
je 0x299d
xorl %eax, %eax
cmpl $0x0, -0x5c(%rbp)
movb %al, -0x94(%rbp)
jne 0x299d
cmpl $0x0, -0x28(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x94(%rbp)
movb -0x94(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x64(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x64(%rbp)
movb %al, -0x95(%rbp)
je 0x29f2
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x7e00, %ecx           # imm = 0x7E00
xorl %eax, %eax
cmpl $0xa00, %ecx            # imm = 0xA00
movb %al, -0x95(%rbp)
je 0x29f2
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7e00, %eax           # imm = 0x7E00
cmpl $0xc00, %eax            # imm = 0xC00
setne %al
movb %al, -0x95(%rbp)
movb -0x95(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
cmpl $0x6, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
cmpl $0x4, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
cmpl $0x3, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7ff00, %eax          # imm = 0x7FF00
cmpl $0x8900, %eax           # imm = 0x8900
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x7ff00, %eax          # imm = 0x7FF00
cmpl $0x8800, %eax           # imm = 0x8800
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x7c(%rbp)
movl -0x14(%rbp), %esi
movzwl -0x16(%rbp), %edx
leaq 0x2ebc(%rip), %rdi      # 0x5946
movb $0x0, %al
callq 0x2030
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)