LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: dati
int
dati(KA11 *cpu, int b)
{
trace("dati %06o: ", cpu->ba);
	if(!b && cpu->ba&1)
		goto be;

	/* internal registers */
	if((cpu->ba&0177400) == 0177400){
		switch(cpu->ba&0377){
		case 0170: case 0171:
			cpu->bus->data = cpu->sw;
			goto ok;
		case 0376: case 0377:
			cpu->bus->data = cpu->psw;
			goto ok;
		}
	}

	cpu->bus->addr = ubxt(cpu->ba)&~1;
	if(dati_bus(cpu->bus))
		goto be;
ok:
	trace("%06o\n", cpu->bus->data);
	cpu->be = 0;
	return 0;
be:
	trace("BE\n");
	cpu->be++;
	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x0, 0x111e6(%rip)     # 0x13cc8
je 0x2af6
movzwl 0x22(%rbx), %esi
leaq 0x46fe(%rip), %rdi      # 0x71ed
xorl %eax, %eax
callq 0x20a0
testl %ebp, %ebp
setne %al
movzwl 0x22(%rbx), %ecx
testb $0x1, %cl
sete %dl
orb %al, %dl
cmpb $0x1, %dl
jne 0x2b5a
movzwl %cx, %eax
cmpw $0xff00, %cx            # imm = 0xFF00
jb 0x2b35
movzbl %al, %ecx
leal -0xfe(%rcx), %edx
cmpl $0x2, %edx
jb 0x2b77
addl $-0x78, %ecx
cmpl $0x1, %ecx
ja 0x2b35
movzwl 0x88(%rbx), %eax
jmp 0x2b7b
movl %eax, %ecx
notl %ecx
leal 0x30000(%rax), %edx
testw $0xe000, %cx            # imm = 0xE000
cmovnel %eax, %edx
andl $-0x2, %edx
movq 0x28(%rbx), %rdi
movl %edx, 0x8(%rdi)
callq 0x235f
testl %eax, %eax
je 0x2b83
cmpl $0x0, 0x11167(%rip)     # 0x13cc8
je 0x2b6f
leaq 0x4906(%rip), %rdi      # 0x7470
callq 0x2040
incl 0x38(%rbx)
pushq $0x1
popq %rax
jmp 0x2ba8
movzbl 0x30(%rbx), %eax
movq 0x28(%rbx), %rcx
movw %ax, 0xc(%rcx)
cmpl $0x0, 0x1113e(%rip)     # 0x13cc8
je 0x2ba2
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %esi
leaq 0x4481(%rip), %rdi      # 0x701c
xorl %eax, %eax
callq 0x20a0
andl $0x0, 0x38(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: dato
int
dato(KA11 *cpu, int b)
{
trace("dato %06o %06o %d\n", cpu->ba, cpu->bus->data, b);
	if(!b && cpu->ba&1)
		goto be;

	/* internal registers */
	if((cpu->ba&0177400) == 0177400){
		switch(cpu->ba&0377){
		case 0170: case 0171:
			/* can't write switches */
			goto ok;
		case 0376: case 0377:
			/* writes 0 for the odd byte.
			   I think this is correct. */
			cpu->psw = cpu->bus->data;
			goto ok;
		}
	}

	if(b){
		cpu->bus->addr = ubxt(cpu->ba);
		if(datob_bus(cpu->bus))
			goto be;
	}else{
		cpu->bus->addr = ubxt(cpu->ba)&~1;
		if(dato_bus(cpu->bus))
			goto be;
	}
ok:
	cpu->be = 0;
	return 0;
be:
	cpu->be++;
	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x0, 0x1110a(%rip)     # 0x13cc8
je 0x2bdc
movzwl 0x22(%rbx), %esi
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %edx
leaq 0x4626(%rip), %rdi      # 0x71f9
movl %ebp, %ecx
xorl %eax, %eax
callq 0x20a0
testl %ebp, %ebp
setne %al
movzwl 0x22(%rbx), %ecx
testb $0x1, %cl
sete %dl
orb %al, %dl
cmpb $0x1, %dl
jne 0x2c55
movzwl %cx, %eax
cmpw $0xff00, %cx            # imm = 0xFF00
jb 0x2c1e
movzbl %al, %ecx
leal -0x78(%rcx), %edx
cmpl $0x2, %edx
jb 0x2c5d
addl $0xffffff02, %ecx       # imm = 0xFFFFFF02
cmpl $0x1, %ecx
ja 0x2c1e
movq 0x28(%rbx), %rax
movb 0xc(%rax), %al
movb %al, 0x30(%rbx)
jmp 0x2c5d
movl %eax, %edx
notl %edx
leal 0x30000(%rax), %ecx
testw $0xe000, %dx            # imm = 0xE000
cmovnel %eax, %ecx
testl %ebp, %ebp
je 0x2c42
movq 0x28(%rbx), %rdi
movl %ecx, 0x8(%rdi)
callq 0x23bd
jmp 0x2c51
andl $-0x2, %ecx
movq 0x28(%rbx), %rdi
movl %ecx, 0x8(%rdi)
callq 0x238e
testl %eax, %eax
je 0x2c5d
incl 0x38(%rbx)
pushq $0x1
popq %rax
jmp 0x2c63
andl $0x0, 0x38(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: fetchop
static int
fetchop(KA11 *cpu, int t, int m, int b)
{
	int r;
	r = m&7;
	if((m&070) == 0)
		cpu->r[t] = cpu->r[r];
	else{
		if(dati(cpu, b)) return 1;
		cpu->r[t] = cpu->bus->data;
		if(b && cpu->ba&1) cpu->r[t] = cpu->r[t]>>8;
	}
	if(b) cpu->r[t] = sxt(cpu->r[t]);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
testb $0x38, %dl
je 0x487a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2ad3
testl %eax, %eax
je 0x488f
pushq $0x1
popq %rax
jmp 0x48c3
andl $0x7, %edx
movzwl (%rbx,%rdx,2), %eax
movl %r14d, %r14d
movw %ax, (%rbx,%r14,2)
testl %ebp, %ebp
jne 0x48b4
jmp 0x48c1
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movl %r14d, %r14d
movw %ax, (%rbx,%r14,2)
testl %ebp, %ebp
je 0x48c1
testb $0x1, 0x22(%rbx)
je 0x48b4
movzwl %ax, %eax
shrl $0x8, %eax
movw %ax, (%rbx,%r14,2)
movzbl %al, %edi
callq 0x2402
movw %ax, (%rbx,%r14,2)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: writedest
static int
writedest(KA11 *cpu, word v, int b)
{
	int d;
	if((cpu->ir & 070) == 0){
		d = cpu->ir & 7;
		if(b) SETMASK(cpu->r[d], v, 0377);
		else cpu->r[d] = v;
	}else{
		if(cpu->ba&1) v <<= 8;
		cpu->bus->data = v;
		if(dato(cpu, b)) return 1;
	}
	return 0;
}

// Assembly:
movzwl 0x24(%rdi), %eax
testb $0x38, %al
je 0x491a
pushq %rax
movb 0x22(%rdi), %cl
shlb $0x3, %cl
andb $0x8, %cl
shll %cl, %esi
movq 0x28(%rdi), %rax
movw %si, 0xc(%rax)
movl %edx, %esi
callq 0x2baf
testl %eax, %eax
leaq 0x8(%rsp), %rsp
je 0x4933
pushq $0x1
popq %rax
retq
andl $0x7, %eax
testl %edx, %edx
je 0x492f
movzbl 0x1(%rdi,%rax,2), %ecx
shll $0x8, %ecx
movzbl %sil, %esi
orl %ecx, %esi
movw %si, (%rdi,%rax,2)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: addrop
static int
addrop(KA11 *cpu, int m, int b)
{
	int r;
	int ai;
	r = m&7;
	m >>= 3;
	ai = 1 + (!b || (r&6)==6 || m&1);
	if(m == 0){
//		assert(0);
		return 0;
	}
	switch(m&6){
	case 0:		// REG
		cpu->b = cpu->ba = cpu->r[r];
		return 0;	// this already is mode 1
	case 2:		// INC
		cpu->ba = cpu->r[r];
		cpu->b = cpu->r[r] = cpu->r[r] + ai;
		break;
	case 4:		// DEC
		cpu->b = cpu->ba = cpu->r[r]-ai;
		if(r == 6 && (cpu->ba&~0377) == 0) cpu->traps |= TRAP_STACK;
		cpu->r[r] = cpu->ba;
		break;
	case 6:		// INDEX
		cpu->ba = cpu->r[7];
		cpu->r[7] += 2;
		if(dati(cpu, 0)) return 1;
		cpu->b = cpu->ba = cpu->bus->data + cpu->r[r];
		break;
	}
	if(m&1){
		if(dati(cpu, 0)) return 1;
		cpu->b = cpu->ba = cpu->bus->data;
	}
	return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ecx
notl %ecx
xorl %eax, %eax
btl $0x3, %esi
adcw $0x1, %ax
testb $0x6, %cl
pushq $0x2
popq %rcx
cmovel %ecx, %eax
testl %edx, %edx
cmovel %ecx, %eax
cmpl $0x8, %esi
jb 0x4a34
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %r15d
andl $0x7, %r15d
movl %esi, %ecx
shrl $0x3, %ecx
andl $0x6, %ecx
leaq 0x27b7(%rip), %rdx      # 0x7134
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
pushq $0x1
popq %r14
jmpq *%rcx
movl %r15d, %eax
leaq (%rbx,%rax,2), %rax
jmp 0x4a29
movzwl 0xe(%rbx), %eax
movw %ax, 0x22(%rbx)
addl $0x2, %eax
movw %ax, 0xe(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2ad3
testl %eax, %eax
jne 0x4a37
movq 0x28(%rbx), %rax
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %ecx
addw 0xc(%rax), %cx
movw %cx, 0x22(%rbx)
movw %cx, 0x20(%rbx)
jmp 0x4a0d
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %edx
movw %dx, 0x22(%rbx)
addl %edx, %eax
movw %ax, (%rbx,%rcx,2)
movw %ax, 0x20(%rbx)
jmp 0x4a0d
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %edx
subl %eax, %edx
movw %dx, 0x22(%rbx)
movw %dx, 0x20(%rbx)
cmpl $0x6, %r15d
jne 0x4a09
cmpw $0xff, %dx
ja 0x4a09
orb $0x1, 0x34(%rbx)
movw %dx, (%rbx,%rcx,2)
testb $0x8, %bpl
je 0x4a34
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2ad3
testl %eax, %eax
jne 0x4a37
movq 0x28(%rbx), %rax
addq $0xc, %rax
movzwl (%rax), %eax
movw %ax, 0x22(%rbx)
movw %ax, 0x20(%rbx)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/ka11.c
// Function: run
void
run(KA11 *cpu)
{
	int count;

	count = 0;
	cpu->state = STATE_RUNNING;
	while(cpu->state != STATE_HALTED){
		svc(cpu, cpu->bus);

#ifdef AUTODIAG
	extern int diagpassed;
	if(diagpassed)
		return;
#endif

		if(cpu->state == STATE_RUNNING ||
		   cpu->state == STATE_WAITING && cpu->traps){
			cpu->state = STATE_RUNNING;
			step(cpu);
		}

		if (count++ == 1000) {
			sleep_ms(cpu->throttle);
			count = 0;
		}
	}

	printstate(cpu);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x1, 0x3c(%rdi)
leaq 0x48(%rdi), %r15
xorl %ebp, %ebp
pushq $0x1
popq %rax
pushq $0x48
popq %r12
xorps %xmm0, %xmm0
testl %eax, %eax
je 0x4b26
movq 0x28(%rbx), %r13
movq %r12, %rax
cmpq $0x88, %rax
je 0x4a8b
movups %xmm0, (%rbx,%rax)
addq $0x10, %rax
jmp 0x4a79
movl 0x34(%rbx), %ecx
andl $-0x6d, %ecx
movq %r13, %r14
movl %ecx, 0x34(%rbx)
movq (%r14), %r14
testq %r14, %r14
je 0x4ae6
movq 0x8(%r14), %rsi
movq %r13, %rdi
callq *0x28(%r14)
movl %eax, %ecx
andl $-0x4, %ecx
cmpl $0x4, %ecx
jne 0x4a97
addl $-0x4, %eax
movq %rax, %rcx
shlq $0x4, %rcx
cmpq $0x0, (%r15,%rcx)
jne 0x4a97
addq %r15, %rcx
movq 0x30(%r14), %rdx
movq %rdx, (%rcx)
movq 0x8(%r14), %rdx
movq %rdx, 0x8(%rcx)
movl 0x34(%rbx), %ecx
leaq 0x29af(%rip), %rdx      # 0x7490
orl (%rdx,%rax,4), %ecx
jmp 0x4a94
movl 0x3c(%rbx), %eax
cmpl $0x1, %eax
je 0x4af9
cmpl $0x2, %eax
jne 0x4b08
cmpl $0x0, 0x34(%rbx)
je 0x4b08
movl $0x1, 0x3c(%rbx)
movq %rbx, %rdi
callq 0x2c6a
cmpl $0x3e8, %ebp            # imm = 0x3E8
je 0x4b14
incl %ebp
jmp 0x4b1e
movl 0x40(%rbx), %edi
callq 0x6692
xorl %ebp, %ebp
movl 0x3c(%rbx), %eax
jmp 0x4a67
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29ec
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: dato_ke11
int
dato_ke11(Bus *bus, void *dev)
{
	KE11 *ke = dev;
	if(bus->addr >= 0777300 && bus->addr < 0777320){
//		printf("EAE DATO %o %o\n", bus->addr, bus->data);
		switch(bus->addr){
		case KE_DIV:
			ke->x = bus->data;
			divide(ke);
			break;
		case KE_AC:
			ke->ac = bus->data;
			break;
		case KE_MQ:
			ke->mq = bus->data;
			/* sign extend into AC */
			if(ke->mq&0100000)
				ke->ac = 0177777;
			else
				ke->ac = 0;
			break;
		case KE_MULT:
			ke->x = bus->data;
			mult(ke);
			break;
		case KE_SCSR:
			ke->sc = bus->data & 077;
			SETMASK(ke->sr, bus->data>>8, 0301);
			break;
		case KE_NORM:
			norm(ke);
			break;
		case KE_LSH:
			ke->sc = bus->data & 077;
			lsh(ke);
			break;
		case KE_ASH:
			ke->sc = bus->data & 077;
			ash(ke);
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rax
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3fec0, %ecx          # imm = 0x3FEC0
jne 0x4b80
addl $0xfffc0140, %eax       # imm = 0xFFFC0140
cmpl $0xe, %eax
ja 0x4c0a
leaq 0x293e(%rip), %rcx      # 0x74a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0xc(%rdi), %eax
movw %ax, 0x4(%rsi)
movq %rsi, %rdi
callq 0x4c29
jmp 0x4c06
pushq $0x1
popq %rax
jmp 0x4c08
movzwl 0xc(%rdi), %eax
movl %eax, %ecx
andb $0x3f, %cl
movb %cl, 0x6(%rsi)
movb 0x7(%rsi), %cl
andb $0x3e, %cl
shrl $0x8, %eax
andb $-0x3f, %al
orb %cl, %al
movb %al, 0x7(%rsi)
jmp 0x4c06
movq %rsi, %rdi
callq 0x4def
jmp 0x4c06
movzwl 0xc(%rdi), %eax
movw %ax, 0x2(%rsi)
testw %ax, %ax
js 0x4c02
andw $0x0, (%rsi)
jmp 0x4c06
movb 0xc(%rdi), %al
andb $0x3f, %al
movb %al, 0x6(%rsi)
movq %rsi, %rdi
callq 0x4efd
jmp 0x4c06
movzwl 0xc(%rdi), %eax
movw %ax, 0x4(%rsi)
movq %rsi, %rdi
callq 0x4d93
jmp 0x4c06
movzwl 0xc(%rdi), %eax
movw %ax, (%rsi)
jmp 0x4c06
movb 0xc(%rdi), %al
andb $0x3f, %al
movb %al, 0x6(%rsi)
movq %rsi, %rdi
callq 0x4e49
jmp 0x4c06
orw $-0x1, (%rsi)
xorl %eax, %eax
popq %rcx
retq
leaq 0x27ba(%rip), %rdi      # 0x73cb
leaq 0x2940(%rip), %rsi      # 0x7558
leaq 0x293f(%rip), %rcx      # 0x755e
movl $0x12a, %edx            # imm = 0x12A
callq 0x20d0
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: divide
static void
divide(KE11 *ke)
{
	uint32 dd, dr;
	uint16 q;
	int c;
	int s;
	int ov;

	dd = ke->ac<<16 | ke->mq;
	dr = ke->x<<16;
	q = 0;
	ov = 0;
	ke->sr &= ~SR_C;
	s = !!(dd&B31);
	ke->sc = 16;
	do{
		c = (dr&B31) == (dd&B31);
		dr >>= 1;
		if(dr&B30)
			dr |= B31;
		q <<= 1;
		q |= c;
		if(c)
			dd += ~dr + 1;
		else
			dd += dr;
		if(ke->sc == 16 && dd != 0 && !!(dd>>31 & 1) == s)
			goto ov;
		ke->sc--;
	}while(ke->sc);

	if(dd == 0 ||
/* is this correct? */
	   dd + abs32(dr) != 0 && !!(dd>>31 & 1) == s){
		c = 1;
		q <<= 1;
		q |= c;
	}else{
		c = (dd&B31) == (dr&B31);
		if(c)
			dd += ~dr + 1;
		else
			dd += dr;
		q += c;
		c = 0;
		q <<= 1;
	}

	/* DOCU manual says DD in one place and DR in another...
	 * which is correct? have to check */
	if((dr>>31 & 1) != (q>>15 & 1) != s)
ov:
		ov = 1;

	ke->ac = dd;
	ke->mq = q;
	setflag(ke, SR_OV, ov != (ke->sr>>6 & 1));
	setflags(ke);
	if(ov)
		setflag(ke, SR_NEG, s);
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl (%rdi), %ebp
movl %ebp, %eax
shll $0x10, %eax
movzwl 0x2(%rdi), %esi
orl %eax, %esi
movzwl 0x4(%rdi), %r9d
shll $0x10, %r9d
movzbl 0x7(%rdi), %ecx
movl %ecx, %eax
andb $0x7e, %al
movl %ebp, %edi
shrl $0xf, %edi
movb $0x10, 0x6(%rbx)
xorl %edx, %edx
movb $0xf, %r11b
movl %esi, %r14d
movl %r9d, %r8d
movl %r9d, %esi
shrl %esi
andl $0x80000000, %r9d       # imm = 0x80000000
orl %esi, %r9d
andl $0x7fff, %edx           # imm = 0x7FFF
movl %r9d, %r10d
negl %r10d
xorl %r15d, %r15d
movl %r14d, %esi
xorl %r8d, %esi
setns %r15b
movl %r9d, %esi
cmovnsl %r10d, %esi
leal (%r15,%rdx,2), %edx
addl %r14d, %esi
cmpb $0xf, %r11b
sete %r15b
testl %esi, %esi
setne %r12b
movl %esi, %r14d
shrl $0x1f, %r14d
cmpl %edi, %r14d
sete %r13b
andb %r15b, %r13b
testb %r12b, %r13b
jne 0x4cfc
movb %r11b, 0x6(%rbx)
addb $-0x1, %r11b
jb 0x4c64
testl %esi, %esi
je 0x4cf3
cmpl %edi, %r14d
sete %r11b
movl %r9d, %r14d
negl %r14d
cmovsl %r9d, %r14d
addl %esi, %r14d
setne %r14b
andb %r11b, %r14b
cmpb $0x1, %r14b
jne 0x4d05
leal 0x1(,%rdx,2), %edx
jmp 0x4d1e
pushq $0x1
popq %r8
xorl %r14d, %r14d
jmp 0x4d42
xorl %r11d, %r11d
movl %esi, %r14d
xorl %r8d, %r14d
cmovnsl %r10d, %r9d
setns %r11b
addl %r9d, %esi
addl %r11d, %edx
addl %edx, %edx
shrl $0x1f, %r8d
movzwl %dx, %r9d
shrl $0xf, %r9d
xorl %r10d, %r10d
cmpl %r9d, %r8d
setne %r10b
xorl %r8d, %r8d
cmpl %r10d, %edi
sete %r14b
setne %r8b
movw %si, (%rbx)
movw %dx, 0x2(%rbx)
movl %ecx, %edx
andb $0x7e, %dl
orb $-0x80, %al
btl $0x6, %ecx
sbbl $0x0, %r8d
movzbl %al, %eax
movzbl %dl, %ecx
cmovnel %eax, %ecx
movb %cl, 0x7(%rbx)
movq %rbx, %rdi
callq 0x5121
testb %r14b, %r14b
jne 0x4d84
movb 0x7(%rbx), %al
andb $-0x41, %al
shrl $0x9, %ebp
andb $0x40, %bpl
orb %al, %bpl
movb %bpl, 0x7(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: mult
static void
mult(KE11 *ke)
{
	uint32 sum, md;
	int c;

	sum = 0;
	md = ke->ac<<16 | ke->mq;
	c = 0;
	ke->sc = 16;
	do{
		if((ke->x & 1) != c){
			if(ke->x&1)
				sum += ~md + 1;
			else
				sum += md;
		}
		md <<= 1;
		c = ke->x&1;
		ke->x >>= 1;
		ke->sc--;
	}while(ke->sc);
	ke->ac = sum>>16;
	ke->mq = sum;
	ke->sr &= ~SR_C;
	setflags(ke);
}

// Assembly:
movzwl (%rdi), %eax
shll $0x10, %eax
movzwl 0x2(%rdi), %ecx
orl %eax, %ecx
movzwl 0x4(%rdi), %edx
xorl %eax, %eax
movb $-0x10, %sil
xorl %r8d, %r8d
movl %r8d, %r9d
movl %edx, %r8d
andl $0x1, %r8d
cmpl %r8d, %r9d
je 0x4dc6
testw %r8w, %r8w
jne 0x4dc4
addl %ecx, %eax
jmp 0x4dc6
subl %ecx, %eax
addl %ecx, %ecx
movzwl %dx, %edx
shrl %edx
incb %sil
jne 0x4dab
movw %dx, 0x4(%rdi)
movb $0x0, 0x6(%rdi)
movl %eax, %ecx
shrl $0x10, %ecx
movw %cx, (%rdi)
movw %ax, 0x2(%rdi)
andb $-0x2, 0x7(%rdi)
jmp 0x5121
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: norm
static void
norm(KE11 *ke)
{
	uint32 sh;

	sh = ke->ac<<16 | ke->mq;
	ke->sc = 0;
	ke->sr &= ~(SR_OV|SR_C);
	setflag(ke, SR_NEG, sh & B31);
	if(ke->sr & SR_NEG)
		ke->sr |= SR_OV;
loop:
	if((sh>>31 & 1) != (sh>>30 & 1))
		goto done;
	if(sh == (3U<<30))
		goto done;
	if(ke->sc == 31)
		goto done;
	sh <<= 1;
	ke->sc++;
	goto loop;
done:
	ke->ac = sh>>16;
	ke->mq = sh;
	setflags(ke);
}

// Assembly:
movzwl (%rdi), %ecx
shll $0x10, %ecx
movzwl 0x2(%rdi), %eax
orl %ecx, %eax
movb $0x0, 0x6(%rdi)
movb 0x7(%rdi), %dl
andb $0x3e, %dl
leal -0x40(%rdx), %esi
testl %ecx, %ecx
movzbl %dl, %ecx
movzbl %sil, %edx
cmovnsl %ecx, %edx
movb %dl, 0x7(%rdi)
movb $0x1, %cl
cmpl $0xc0000000, %eax       # imm = 0xC0000000
je 0x4e3f
movl %eax, %edx
shrl $0x1f, %edx
movl %eax, %esi
shrl $0x1e, %esi
andl $0x1, %esi
cmpl %esi, %edx
jne 0x4e3f
cmpb $0x20, %cl
je 0x4e3f
addl %eax, %eax
movb %cl, 0x6(%rdi)
incb %cl
jmp 0x4e19
rorl $0x10, %eax
movl %eax, (%rdi)
jmp 0x5121
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: lsh
static void
lsh(KE11 *ke)
{
	uint32 sh;
	int ov;

	sh = ke->ac<<16 | ke->mq;
	setflag(ke, SR_NEG, sh&B31);
	ov = 0;
loop:
	ke->sc &= 077;
	if(ke->sc == 0)
		goto done;
	if(ke->sc&040){
		/* negative, shift right */
		setflag(ke, SR_C, sh&1);
		sh >>= 1;
		ke->sr &= ~SR_NEG;
		ke->sc++;
	}else{
		/* positive, shift left */
		setflag(ke, SR_C, sh&B31);
		sh <<= 1;
		if((ke->sr>>6 & 1) != (sh>>31 & 1))
			ov = 1;	/* sign changed */
		setflag(ke, SR_NEG, sh&B31);
		ke->sc--;
	}
	goto loop;
done:
	setflag(ke, SR_OV, ov != (ke->sr>>6 & 1));
	ke->ac = sh>>16;
	ke->mq = sh;
	setflags(ke);
}

// Assembly:
pushq %rbx
movzwl (%rdi), %ecx
movl %ecx, %edx
shll $0x10, %edx
movzwl 0x2(%rdi), %eax
orl %edx, %eax
movb 0x6(%rdi), %r9b
movb 0x7(%rdi), %dl
andb $-0x41, %dl
shrl $0x9, %ecx
andb $0x40, %cl
orb %dl, %cl
xorl %edx, %edx
movl $0x1, %esi
movl %r9d, %r8d
movzbl %cl, %r10d
andb $0x3f, %r8b
je 0x4ed1
andb $-0x42, %cl
testb $0x20, %r9b
jne 0x4eb7
movl %eax, %r9d
shrl $0x1f, %r9d
leal (%rax,%rax), %r11d
movl %r11d, %ebx
shrl $0x1f, %ebx
btl $0x6, %r10d
sbbl $0x0, %ebx
cmovnel %esi, %edx
shrl $0x18, %eax
andb $0x40, %al
orb %r9b, %al
orb %cl, %al
movb $-0x1, %r9b
movl %eax, %ecx
movl %r11d, %eax
jmp 0x4ec6
movl %eax, %r9d
andb $0x1, %r9b
orb %r9b, %cl
shrl %eax
movb $0x1, %r9b
addb %r9b, %r8b
movb %cl, 0x7(%rdi)
movl %r8d, %r9d
jmp 0x4e74
movb $0x0, 0x6(%rdi)
btl $0x6, %r10d
sbbl $0x0, %edx
setne %dl
andb $0x7f, %cl
shlb $0x7, %dl
orb %cl, %dl
movb %dl, 0x7(%rdi)
movl %eax, %ecx
shrl $0x10, %ecx
movw %cx, (%rdi)
movw %ax, 0x2(%rdi)
popq %rbx
jmp 0x5121
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: ash
static void
ash(KE11 *ke)
{
	uint32 sh;
	int ov;

	sh = ke->ac<<16 | ke->mq;
	setflag(ke, SR_NEG, sh&B31);
	ov = 0;
loop:
	ke->sc &= 077;
	if(ke->sc == 0)
		goto done;
	if(ke->sc&040){
		/* negative, shift right */
		setflag(ke, SR_C, sh&1);
		sh >>= 1;
		if(ke->sr & SR_NEG)
			sh |= B31;
		ke->sc++;
	}else{
		/* positive, shift left */
		sh <<= 1;
		setflag(ke, SR_C, sh&B31);
		if(ke->sr & SR_NEG)
			sh |= B31;
		else
			sh &= ~B31;
		if((ke->sr & SR_C) != (ke->sr>>6 & 1))
			ov = 1;	/* sign changed */
		ke->sc--;
	}
	goto loop;
done:
	setflag(ke, SR_OV, ov != (ke->sr>>6 & 1));
	ke->ac = sh>>16;
	ke->mq = sh;
	setflags(ke);
}

// Assembly:
movzwl (%rdi), %ecx
movl %ecx, %edx
shll $0x10, %edx
movzwl 0x2(%rdi), %eax
orl %edx, %eax
movb 0x6(%rdi), %r9b
movb 0x7(%rdi), %dl
andb $-0x41, %dl
shrl $0x9, %ecx
andb $0x40, %cl
orb %dl, %cl
xorl %edx, %edx
pushq $0x1
popq %rsi
movl %r9d, %r8d
andb $0x3f, %r8b
je 0x4f9f
movl %ecx, %r10d
andb $0x40, %r10b
testb $0x20, %r9b
jne 0x4f77
addl %eax, %eax
andb $-0x2, %cl
movl %eax, %r11d
shrl $0x1f, %r11d
orb %cl, %r11b
movl %eax, %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
andl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
testb %r10b, %r10b
cmovnel %ecx, %eax
movzbl %r11b, %ecx
movl %ecx, %r9d
shrl $0x6, %r9d
xorl %ecx, %r9d
testb $0x1, %r9b
cmovnel %esi, %edx
movb $-0x1, %r9b
movl %r11d, %ecx
jmp 0x4f94
andb $-0x2, %cl
movl %eax, %r9d
andb $0x1, %r9b
orb %r9b, %cl
shrl %eax
movzbl %r10b, %r9d
shll $0x19, %r9d
orl %r9d, %eax
movb $0x1, %r9b
addb %r9b, %r8b
movb %cl, 0x7(%rdi)
movl %r8d, %r9d
jmp 0x4f25
movb $0x0, 0x6(%rdi)
movzbl %cl, %esi
btl $0x6, %esi
sbbl $0x0, %edx
setne %dl
andb $0x7f, %cl
shlb $0x7, %dl
orb %cl, %dl
movb %dl, 0x7(%rdi)
movl %eax, %ecx
shrl $0x10, %ecx
movw %cx, (%rdi)
movw %ax, 0x2(%rdi)
jmp 0x5121
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: datob_ke11
int
datob_ke11(Bus *bus, void *dev)
{
	KE11 *ke = dev;
	if(bus->addr >= 0777300 && bus->addr < 0777320){
//		printf("EAE DATOB %o %o\n", bus->addr, bus->data);
		switch(bus->addr){
		case KE_DIV:
			ke->x = sxt(bus->data);
			divide(ke);
			break;
		case KE_AC:
			ke->ac = sxt(bus->data);
			break;
		case KE_AC+1:
			SETMASK(ke->ac, bus->data, 0177400);
			break;
		case KE_MQ:
			ke->mq = sxt(bus->data);
			/* sign extend into AC */
			if(ke->mq&0100000)
				ke->ac = 0177777;
			else
				ke->ac = 0;
			break;
		case KE_MQ+1:
			SETMASK(ke->mq, bus->data, 0177400);
			/* sign extend into AC */
			if(ke->mq&0100000)
				ke->ac = 0177777;
			else
				ke->ac = 0;
			break;
		case KE_MULT:
			ke->x = sxt(bus->data);
			mult(ke);
			break;
		case KE_SCSR:
			break;
		case KE_NORM:
			norm(ke);
			break;
		case KE_LSH:
			ke->sc = bus->data & 077;
			lsh(ke);
			break;
		case KE_ASH:
			ke->sc = bus->data & 077;
			ash(ke);
			break;
		case KE_DIV+1:
		case KE_MULT+1:
		case KE_SCSR+1:
		case KE_NORM+1:
		case KE_LSH+1:
		case KE_ASH+1:
			break;

		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3fec0, %ecx          # imm = 0x3FEC0
jne 0x5010
movq %rsi, %rbp
xorl %ebx, %ebx
addl $0xfffc0140, %eax       # imm = 0xFFFC0140
leaq 0x24ec(%rip), %rcx      # 0x74dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0xc(%rdi), %edi
callq 0x2402
movw %ax, 0x4(%rbp)
movq %rbp, %rdi
callq 0x4c29
jmp 0x5013
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movb 0xc(%rdi), %al
andb $0x3f, %al
movb %al, 0x6(%rbp)
movq %rbp, %rdi
callq 0x4e49
jmp 0x5013
movzwl 0xc(%rdi), %eax
movb %ah, 0x3(%rbp)
testw %ax, %ax
js 0x508e
andw $0x0, (%rbp)
jmp 0x5013
movzbl 0xc(%rdi), %edi
callq 0x2402
movw %ax, 0x4(%rbp)
movq %rbp, %rdi
callq 0x4d93
jmp 0x5013
movb 0xd(%rdi), %al
movb %al, 0x1(%rbp)
jmp 0x5013
movb 0xc(%rdi), %al
andb $0x3f, %al
movb %al, 0x6(%rbp)
movq %rbp, %rdi
callq 0x4efd
jmp 0x5013
movq %rbp, %rdi
callq 0x4def
jmp 0x5013
movzbl 0xc(%rdi), %edi
callq 0x2402
movw %ax, 0x2(%rbp)
testw %ax, %ax
jns 0x503a
orw $-0x1, (%rbp)
jmp 0x5013
movzbl 0xc(%rdi), %edi
callq 0x2402
movw %ax, (%rbp)
jmp 0x5013
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: dati_ke11
int
dati_ke11(Bus *bus, void *dev)
{
	KE11 *ke = dev;
	if(bus->addr >= 0777300 && bus->addr < 0777320){
//		printf("EAE DATI %o\n", bus->addr);
		switch(bus->addr){
		case KE_DIV:
		case KE_MULT:
		case KE_LSH:
		case KE_ASH:
			bus->data = 0;
			break;
		case KE_AC:
			bus->data = ke->ac;
			break;
		case KE_MQ:
			bus->data = ke->mq;
			break;
		case KE_SCSR:
			bus->data = WD(ke->sr, ke->sc);
			break;
		case KE_NORM:
			bus->data = ke->sc & 077;
			break;

		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3fec0, %ecx          # imm = 0x3FEC0
jne 0x50dd
addl $0xfffc0140, %eax       # imm = 0xFFFC0140
cmpl $0xe, %eax
ja 0x50fb
leaq 0x2451(%rip), %rcx      # 0x751c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
movw %ax, 0xc(%rdi)
xorl %eax, %eax
retq
pushq $0x1
popq %rax
retq
movzwl (%rsi), %eax
jmp 0x50d6
movzwl 0x2(%rsi), %eax
jmp 0x50d6
movzbl 0x6(%rsi), %eax
andl $0x3f, %eax
jmp 0x50d6
movzwl 0x6(%rsi), %eax
jmp 0x50d6
pushq %rax
leaq 0x22c8(%rip), %rdi      # 0x73cb
leaq 0x244e(%rip), %rsi      # 0x7558
leaq 0x246a(%rip), %rcx      # 0x757b
movl $0x18c, %edx            # imm = 0x18C
callq 0x20d0
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/eae.c
// Function: setflags
static void
setflags(KE11 *ke)
{
	ke->sr &= ~(SR_AC_EQ_MQ15|SR_AC_MQ_0|SR_MQ_0|SR_AC_0|SR_AC_1);
	if(ke->ac == 0 && sgn(ke->mq)==0 ||
	   ke->ac == 0177777 && sgn(ke->mq))
		ke->sr |= SR_AC_EQ_MQ15;
	if(ke->mq == 0 && ke->ac == 0)
		ke->sr |= SR_AC_MQ_0;
	if(ke->mq == 0)
		ke->sr |= SR_MQ_0;
	if(ke->ac == 0)
		ke->sr |= SR_AC_0;
	if(ke->ac == 0177777)
		ke->sr |= SR_AC_1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
andb $-0x3f, 0x7(%rdi)
movzwl (%rdi), %eax
testw %ax, %ax
jne 0x5142
movzwl 0x2(%rbx), %edi
callq 0x23fc
testw %ax, %ax
je 0x5156
movzwl (%rbx), %eax
cmpw $-0x1, %ax
jne 0x515a
movzwl 0x2(%rbx), %edi
callq 0x23fc
testw %ax, %ax
je 0x515a
orb $0x2, 0x7(%rbx)
cmpw $0x0, 0x2(%rbx)
movzwl (%rbx), %eax
jne 0x517b
movzbl 0x7(%rbx), %ecx
movl %ecx, %edx
orb $0x4, %dl
testl %eax, %eax
movzbl %dl, %edx
cmovnel %ecx, %edx
orb $0x8, %dl
movb %dl, 0x7(%rbx)
testl %eax, %eax
je 0x518a
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x518f
movb $0x20, %al
jmp 0x518c
movb $0x10, %al
orb %al, 0x7(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/kw11.c
// Function: dati_kw11
int
dati_kw11(Bus *bus, void *dev)
{
	KW11 *kw = dev;
	if(bus->addr == 0777546){
		bus->data = kw->lc_int_enab<<6 |
			kw->lc_clock<<7;
		return 0;
	}
	return 1;
}

// Assembly:
cmpl $0x3ff66, 0x8(%rdi)     # imm = 0x3FF66
jne 0x51b1
movl (%rsi), %eax
movl 0x4(%rsi), %ecx
shll $0x6, %eax
shll $0x7, %ecx
orl %eax, %ecx
movw %cx, 0xc(%rdi)
xorl %eax, %eax
retq
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/kw11.c
// Function: dato_kw11
int
dato_kw11(Bus *bus, void *dev)
{
	KW11 *kw = dev;
	if(bus->addr == 0777546){
		kw->lc_int_enab = bus->data>>6 & 1;
		if((bus->data & 0200) == 0){
			kw->lc_clock = 0;
			kw->lc_int = 0;
		}
		return 0;
	}
	return 1;
}

// Assembly:
cmpl $0x3ff66, 0x8(%rdi)     # imm = 0x3FF66
jne 0x51d7
movl 0xc(%rdi), %ecx
movl %ecx, %eax
shrl $0x6, %eax
andl $0x1, %eax
movl %eax, (%rsi)
xorl %eax, %eax
testb %cl, %cl
js 0x51d6
andq $0x0, 0x4(%rsi)
retq
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/kl11.c
// Function: dati_kl11
int
dati_kl11(Bus *bus, void *dev)
{
	KL11 *kl = dev;
	if(bus->addr >= 0777560 && bus->addr < 0777570){
		switch(bus->addr&6){
		/* Receive */
		case 0:
			bus->data = kl->rdr_int_enab<<6 |
				kl->rdr_done<<7 |
				kl->rdr_busy<<11;
			break;
		case 2:
			bus->data = kl->rdr_buf;
			kl->rdr_buf = 0;
			kl->rdr_done = 0;
			break;
		/* Transmit */
		case 4:
			bus->data = kl->maint<<2 |
				kl->pun_int_enab<<6 |
				kl->pun_ready<<7;
			break;
		case 6:
			/* write only */
			bus->data = 0;
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x8, %ecx
cmpl $0x3ff70, %ecx          # imm = 0x3FF70
jne 0x5283
andl $0x6, %eax
leaq 0x233a(%rip), %rcx      # 0x7598
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4(%rsi), %eax
movl 0x8(%rsi), %ecx
shll $0x6, %eax
movl 0x10(%rsi), %edx
shll $0x7, %edx
orl %eax, %edx
shll $0xb, %ecx
orl %edx, %ecx
movw %cx, 0xc(%rdi)
jmp 0x52b9
pushq $0x1
popq %rax
retq
andw $0x0, 0xc(%rdi)
jmp 0x52b9
movzbl 0x14(%rsi), %eax
movw %ax, 0xc(%rdi)
movb $0x0, 0x14(%rsi)
andl $0x0, 0x10(%rsi)
jmp 0x52b9
movl (%rsi), %eax
movl 0x18(%rsi), %ecx
shll $0x2, %eax
shll $0x6, %ecx
orl %eax, %ecx
movl 0x1c(%rsi), %eax
shll $0x7, %eax
orl %ecx, %eax
movw %ax, 0xc(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/kl11.c
// Function: dato_kl11
int
dato_kl11(Bus *bus, void *dev)
{
	KL11 *kl = dev;
	if(bus->addr >= 0777560 && bus->addr < 0777570){
		switch(bus->addr&7){
		/* Receive */
		case 0:
			// TODO: RDR ENAB
			kl->rdr_enab = bus->data & 1;
			kl->rdr_int_enab = bus->data>>6 & 1;
			if(!kl->rdr_int_enab)
				kl->intr_flags &= ~2;
			else if(kl->rdr_done)
				kl->intr_flags |= 2;
			break;
		case 2:
			/* read only */
			break;
		/* Transmit */
		case 4:
			// TODO: MAINT
			kl->maint = bus->data>>2 & 1;
			kl->pun_int_enab = bus->data>>6 & 1;
			if(!kl->pun_int_enab)
				kl->intr_flags &= ~1;
			else if(kl->pun_ready)
				kl->intr_flags |= 1;
			break;
		case 6:
			kl->pun_buf = bus->data;
			kl->pun_halt = 0;
			kl->pun_ready = 0;
			break;

		/* respond but don't do anything */
		case 1:
		case 3:
		case 5:
		case 7:
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movl 0x8(%rdi), %ecx
movl %ecx, %eax
andl $-0x8, %eax
cmpl $0x3ff70, %eax          # imm = 0x3FF70
jne 0x52e1
andl $0x7, %ecx
xorl %eax, %eax
leaq 0x22dd(%rip), %rdx      # 0x75b4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
retq
pushq $0x1
popq %rax
retq
movb 0xc(%rdi), %cl
movb %cl, 0x24(%rsi)
andq $0x0, 0x1c(%rsi)
retq
movzwl 0xc(%rdi), %ecx
movl %ecx, %edx
andl $0x1, %edx
movl %edx, 0xc(%rsi)
shrl $0x6, %ecx
andl $0x1, %ecx
movl %ecx, 0x4(%rsi)
je 0x5337
cmpl $0x0, 0x10(%rsi)
je 0x52e0
orb $0x2, 0x28(%rsi)
retq
movzwl 0xc(%rdi), %ecx
movl %ecx, %edx
shrl $0x2, %edx
andl $0x1, %edx
movl %edx, (%rsi)
shrl $0x6, %ecx
andl $0x1, %ecx
movl %ecx, 0x18(%rsi)
je 0x533c
cmpl $0x0, 0x1c(%rsi)
je 0x52e0
orb $0x1, 0x28(%rsi)
retq
andb $-0x3, 0x28(%rsi)
retq
andb $-0x2, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/kl11.c
// Function: svc_kl11
int
svc_kl11(Bus *bus, void *dev)
{
	char c;
	KL11 *kl = dev;

	NNN++;
//	if(NNN == 20){
	if(NNN == 20000){
	/* transmit */
	if(!kl->pun_halt){
		uint8 c = kl->pun_buf & 0177;
		write(kl->tty.fd, &c, 1);
#ifdef AUTODIAG
	extern int diagpassed;
	if(c == '\a')
		diagpassed = 1;
#endif
		kl->pun_halt = 1;
		kl->pun_ready = 1;
		if(kl->pun_int_enab)
			kl->intr_flags |= 1;
	}

	/* receive */
	if(ttyinput(&kl->tty, &c)){
		kl->rdr_busy = 1;
		kl->rdr_enab = 0;
		kl->rdr_buf = c;
		kl->rdr_busy = 0;
		kl->rdr_done = 1;
		if(kl->rdr_int_enab)
			kl->intr_flags |= 2;
	}
	NNN = 0;
	}

	return kl->intr_flags ? 4 : 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movl 0xe978(%rip), %eax      # 0x13ccc
incl %eax
movl %eax, 0xe970(%rip)      # 0x13ccc
cmpl $0x4e20, %eax           # imm = 0x4E20
jne 0x53d1
cmpl $0x0, 0x20(%rbx)
jne 0x5398
movb 0x24(%rbx), %al
andb $0x7f, %al
leaq 0xf(%rsp), %rsi
movb %al, (%rsi)
movl 0x2c(%rbx), %edi
pushq $0x1
popq %rdx
callq 0x2080
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x1c(%rbx)
cmpl $0x0, 0x18(%rbx)
je 0x5398
orb $0x1, 0x28(%rbx)
leaq 0x2c(%rbx), %rdi
leaq 0xe(%rsp), %rsi
callq 0x6345
testl %eax, %eax
je 0x53ca
andl $0x0, 0xc(%rbx)
movb 0xe(%rsp), %al
movb %al, 0x14(%rbx)
andl $0x0, 0x8(%rbx)
movl $0x1, 0x10(%rbx)
cmpl $0x0, 0x4(%rbx)
je 0x53ca
orb $0x2, 0x28(%rbx)
andl $0x0, 0xe8fb(%rip)      # 0x13ccc
xorl %eax, %eax
cmpl $0x0, 0x28(%rbx)
setne %al
shll $0x2, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: dati_rf11
int
dati_rf11(Bus *bus, void *dev)
{
	RF11 *rf = dev;
	rf->bus = bus;
	if(bus->addr >= 0777460 && bus->addr < 0777500){
		switch(bus->addr&016){
		case 000: bus->data = rf->dcs; break;
		case 002: bus->data = rf->wc; break;
		case 004: bus->data = rf->cma; break;
		case 006: bus->data = rf->dar; break;
		case 010: bus->data = rf->dae; break;
		case 012: bus->data = rf->dbr; break;
		case 014: bus->data = rf->ma; break;
		case 016: bus->data = rf->drives[rf->d].ads; break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movq %rdi, (%rsi)
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3ff30, %ecx          # imm = 0x3FF30
jne 0x5478
andl $0xe, %eax
leaq 0x2187(%rip), %rcx      # 0x75f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x8, %rsi
jmp 0x54af
pushq $0x1
popq %rax
retq
addq $0xe, %rsi
jmp 0x54af
movslq 0x1c(%rsi), %rax
shlq $0x4, %rax
addq %rax, %rsi
addq $0x28, %rsi
jmp 0x54af
addq $0xc, %rsi
jmp 0x54af
addq $0xa, %rsi
jmp 0x54af
addq $0x12, %rsi
jmp 0x54af
addq $0x14, %rsi
jmp 0x54af
addq $0x10, %rsi
movzwl (%rsi), %eax
movw %ax, 0xc(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: datox_rf11
static int
datox_rf11(Bus *bus, RF11 *rf, word mask)
{
	rf->bus = bus;
	RS11 *drive = &rf->drives[rf->d];
	if(bus->addr >= 0777460 && bus->addr < 0777500){
		switch(bus->addr&017){
		case 000:	// DCS
		case 001:
			SETMASK(rf->dcs, bus->data, mask&0176);
			if(bus->data & GO){
				// start function
				rf->done = 0;
				switch((rf->dcs>>1)&3){
				case FR_NOP:
					rf->dcs |= RDY;
					// ??? interrupt?
					break;
				case FR_READ:
				case FR_WRITE:
				case FR_WRITE_CHECK:
					rf->dcs &= ~RDY;
					if(drive->fp == nil)
						rferr(rf, NED);
					break;
				}
			}
			if(bus->data & DCLR)
				reset_rf11(rf);
			break;
		case 002:	// WC
		case 003:
			SETMASK(rf->wc, bus->data, mask);
			break;
		case 004:	// CMA
		case 005:
			SETMASK(rf->cma, bus->data, mask);
			break;
		case 006:	// DAR
		case 007:
			SETMASK(rf->dar, bus->data, mask);
			break;
		case 010:	// DAE
		case 011:
			SETMASK(rf->dae, bus->data, mask&0637);
			rf->dae &= ~DA14;
			seldisk(rf, (rf->dae>>2)&7);
			break;
		case 012:	// DBR
		case 013:
			SETMASK(rf->dbr, bus->data, mask);
			break;
		case 014:	// MA
		case 015:
			// not implemented
			break;
		case 016:	// ADS
		case 017:
			// read only
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbx
movq %rdi, (%rsi)
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3ff30, %ecx          # imm = 0x3FF30
jne 0x5558
andl $0xf, %eax
xorl %ebx, %ebx
leaq 0x2148(%rip), %rcx      # 0x762c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x1c(%rsi), %r8
movzwl 0x8(%rsi), %r9d
movzwl 0xc(%rdi), %eax
movl %eax, %ecx
xorl %r9d, %ecx
andl %edx, %ecx
andl $0x7e, %ecx
xorl %r9d, %ecx
movw %cx, 0x8(%rsi)
testb $0x1, %al
je 0x55ef
andl $0x0, 0x18(%rsi)
testb $0x6, %cl
je 0x55e5
shlq $0x4, %r8
leaq (%rsi,%r8), %rdx
addq $0x20, %rdx
movl %ecx, %edi
andl $0xff7f, %edi           # imm = 0xFF7F
movw %di, 0x8(%rsi)
cmpq $0x0, (%rdx)
jne 0x55ef
orl $0x880, %ecx            # imm = 0x880
movw %cx, 0x8(%rsi)
movl $0x1, 0x18(%rsi)
jmp 0x55ef
pushq $0x1
popq %rbx
movl %ebx, %eax
popq %rbx
retq
movzwl 0xc(%rsi), %eax
movzwl 0xc(%rdi), %ecx
xorw %ax, %cx
andl %edx, %ecx
xorl %ecx, %eax
movw %ax, 0xc(%rsi)
jmp 0x555b
movzwl 0xa(%rsi), %eax
movzwl 0xc(%rdi), %ecx
xorw %ax, %cx
andl %edx, %ecx
xorl %ecx, %eax
movw %ax, 0xa(%rsi)
jmp 0x555b
movzwl 0x12(%rsi), %eax
movzwl 0xc(%rdi), %ecx
xorw %ax, %cx
andl %edx, %ecx
xorl %ecx, %eax
movw %ax, 0x12(%rsi)
jmp 0x555b
movzwl 0xe(%rsi), %eax
movzwl 0xc(%rdi), %ecx
xorw %ax, %cx
andl %edx, %ecx
xorl %ecx, %eax
movw %ax, 0xe(%rsi)
jmp 0x555b
andl $0x19f, %edx            # imm = 0x19F
movzwl 0xc(%rdi), %eax
andw %dx, %ax
xorl $0xffdf, %edx           # imm = 0xFFDF
andw 0x10(%rsi), %dx
orl %eax, %edx
movw %dx, 0x10(%rsi)
shrl $0x2, %edx
andl $0x7, %edx
movq %rsi, %rdi
movl %edx, %esi
callq 0x580d
jmp 0x555b
orl $0x80, %ecx
movw %cx, 0x8(%rsi)
btl $0x8, %eax
jae 0x555b
movq %rsi, %rdi
callq 0x57ed
jmp 0x555b
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: svc_rf11
int
svc_rf11(Bus *bus, void *dev)
{
	int i;
	RF11 *rf = dev;

	for(i = 0; i < 8; i++)
		svc_rs11(&rf->drives[i], rf, rf->d == i);

	if(rf->dcs&(FRZ|WCE|DPE|NED|WLO|MXF))
		rf->dcs |= ERR;
	else
		rf->dcs &= ~ERR;

	return (rf->dcs&IE) &&
// TODO: probably just have one interrupt bit?
	       (rf->done || (rf->dcs&ERR)) ?
		5 : 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
leaq 0x20(%rsi), %r14
xorl %r15d, %r15d
cmpq $0x8, %r15
je 0x5650
movl 0x1c(%rbx), %eax
xorl %edx, %edx
cmpq %rax, %r15
sete %dl
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5693
incq %r15
addq $0x10, %r14
jmp 0x562b
movzwl 0x8(%rbx), %ecx
movl %ecx, %eax
andl $0x1ff, %eax            # imm = 0x1FF
movl %ecx, %edx
orl $0xffff8000, %edx       # imm = 0xFFFF8000
testw $0x7e00, %cx            # imm = 0x7E00
cmovel %eax, %edx
movw %dx, 0x8(%rbx)
xorl %eax, %eax
testb $0x40, %dl
je 0x568d
xorl %eax, %eax
testw $0x7e00, %cx            # imm = 0x7E00
setne %al
cmpl $0x0, 0x18(%rbx)
leal (%rax,%rax,4), %ecx
pushq $0x5
popq %rax
cmovel %ecx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: svc_rs11
void
svc_rs11(RS11 *drive, RF11 *rf, int selected)
{
	if(drive->fp == nil){
		drive->ads = 0;
		return;
	}

	// read/write data
	if(selected && (rf->dcs&RDY)==0){
		// track address we want
		seltrack(rf, (rf->dar>>11) | (rf->dae&3)<<5);

		// word we're interested in
		if(rf->wc && drive->ads == (rf->dar&03777)){
			// read/write word here
			switch((rf->dcs>>1)&3){
			case FR_READ:
				rf->dbr = WD(rf->buf[drive->ads*2+1], rf->buf[drive->ads*2]);

				// write to bus
				rf->bus->data = rf->dbr;
				rf->bus->addr = busaddr(rf);
				if(dato_bus(rf->bus))
					rferr(rf, NEM);
				break;
			case FR_WRITE:
			case FR_WRITE_CHECK:
				// read from bus
				rf->bus->addr = busaddr(rf);
				if(dati_bus(rf->bus))
					rferr(rf, NEM);
				rf->dbr = rf->bus->data;

				rf->buf[drive->ads*2] = rf->dbr;
				rf->buf[drive->ads*2+1] = rf->dbr>>8;
				rf->dirty = 1;
				break;
			}

			rf->wc++;
			if(rf->wc == 0){
				rf->dcs |= RDY;
				rf->done = 1;
			}else{
				// count
				rf->dar++;
				if(rf->dar == 0){
					// carry into dae
					rf->dae++;
					// this can carry into disk address
					seldisk(rf, (rf->dae>>2)&017);
				}
			}
		}
	}

	// rotate - one word every 16us
	// address of next word on track
	drive->ads = (drive->ads+1)&03777;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, (%rdi)
je 0x575a
testl %edx, %edx
je 0x57ce
movq %rsi, %rbp
testb $-0x80, 0x8(%rsi)
jne 0x57ce
movzwl 0xe(%rbp), %eax
shrl $0xb, %eax
movl 0x10(%rbp), %esi
shll $0x5, %esi
andl $0x60, %esi
orl %eax, %esi
movq %rbp, %rdi
callq 0x58ec
cmpw $0x0, 0xa(%rbp)
je 0x57ce
movzwl 0x8(%rbx), %eax
movzwl 0xe(%rbp), %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
cmpw %cx, %ax
jne 0x57ce
movl 0x8(%rbp), %ecx
shrl %ecx
andl $0x3, %ecx
leaq 0x1f69(%rip), %rdx      # 0x766c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %rbp, %rdi
callq 0x59a1
movq (%rbp), %rdi
movl %eax, 0x8(%rdi)
callq 0x235f
testl %eax, %eax
je 0x5731
orw $0x480, 0x8(%rbp)       # imm = 0x480
movl $0x1, 0x18(%rbp)
movq (%rbp), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x12(%rbp)
movzwl 0x8(%rbx), %ecx
movb %al, 0xa8(%rbp,%rcx,2)
movzwl 0x8(%rbx), %ecx
movb %ah, 0xa9(%rbp,%rcx,2)
movl $0xa0, %eax
jmp 0x5796
andw $0x0, 0x8(%rbx)
jmp 0x57dc
movzwl 0xa8(%rbp,%rax,2), %eax
movw %ax, 0x12(%rbp)
movq (%rbp), %rcx
movw %ax, 0xc(%rcx)
movq %rbp, %rdi
callq 0x59a1
movq (%rbp), %rdi
movl %eax, 0x8(%rdi)
callq 0x238e
testl %eax, %eax
je 0x579e
orw $0x480, 0x8(%rbp)       # imm = 0x480
pushq $0x18
popq %rax
movl $0x1, (%rbp,%rax)
incw 0xa(%rbp)
jne 0x57b1
orb $-0x80, 0x8(%rbp)
movl $0x1, 0x18(%rbp)
jmp 0x57ce
incw 0xe(%rbp)
jne 0x57ce
movl 0x10(%rbp), %esi
incl %esi
movw %si, 0x10(%rbp)
shrl $0x2, %esi
andl $0xf, %esi
movq %rbp, %rdi
callq 0x580d
movl 0x8(%rbx), %eax
incl %eax
andl $0x7ff, %eax            # imm = 0x7FF
movw %ax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: seldisk
static void
seldisk(RF11 *rf, int disk)
{
	if(rf->d == disk)
		return;
	seltrack(rf, -1);
	rf->d = disk&7;
	if(disk&010)
		rferr(rf, NED);
}

// Assembly:
cmpl %esi, 0x1c(%rdi)
je 0x5843
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
pushq $-0x1
popq %rsi
callq 0x58ec
movl %ebp, %eax
andl $0x7, %eax
movl %eax, 0x1c(%rbx)
testb $0x8, %bpl
je 0x583d
orw $0x880, 0x8(%rbx)       # imm = 0x880
movl $0x1, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: attach_rs11
void
attach_rs11(RF11 *rf, int n, char *path)
{
	if(rf->drives[n].fp)
		detach_rs11(rf, n);
	rf->drives[n].fp = fopen(path, "r+");
	if(rf->drives[n].fp == nil)
		rf->drives[n].fp = fopen(path, "w+");
	if(rf->drives[n].fp == nil)
		fprintf(stderr, "couldn't open '%s'\n", path);
	reset_rs11(&rf->drives[n]);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movslq %esi, %rax
shlq $0x4, %rax
leaq (%rdi,%rax), %r14
addq $0x20, %r14
cmpq $0x0, (%r14)
je 0x5865
callq 0x58be
leaq 0x1e17(%rip), %rsi      # 0x7683
movq %rbx, %rdi
callq 0x21b0
movq %rax, (%r14)
testq %rax, %rax
jne 0x5893
leaq 0x1e03(%rip), %rsi      # 0x7686
movq %rbx, %rdi
callq 0x21b0
movq %rax, (%r14)
testq %rax, %rax
je 0x58a1
andw $0x0, 0x8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x4750(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x1dd7(%rip), %rsi      # 0x7689
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2120
jmp 0x5893
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: detach_rs11
void
detach_rs11(RF11 *rf, int n)
{
	if(rf->drives[n].fp){
		fclose(rf->drives[n].fp);
		rf->drives[n].fp = nil;
	}
	reset_rs11(&rf->drives[n]);
}

// Assembly:
pushq %rbx
movslq %esi, %rax
shlq $0x4, %rax
leaq (%rdi,%rax), %rbx
addq $0x20, %rbx
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x58df
callq 0x2090
andq $0x0, (%rbx)
andw $0x0, 0x8(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: seltrack
static void
seltrack(RF11 *rf, int track)
{
	if(rf->track == track)
		return;

	RS11 *drive = &rf->drives[rf->d];
	if(rf->dirty){
		assert(drive->fp);
		fwrite(rf->buf, 1, 2048*2, drive->fp);
	}
	rf->track = track;

	if(rf->track >= 0){
		int pos = rf->track<<12;
		fseek(drive->fp, pos, 0);
		fread(rf->buf, 1, 2048*2, drive->fp);
		// rewind so we can write back easily
		fseek(drive->fp, pos, 0);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl %esi, 0xa4(%rdi)
je 0x597e
movl %esi, %ebx
movq %rdi, %r14
movslq 0x1c(%rdi), %rax
shlq $0x4, %rax
leaq (%rdi,%rax), %r15
addq $0x20, %r15
cmpl $0x0, 0xa0(%rdi)
je 0x5937
movq (%r15), %rcx
testq %rcx, %rcx
je 0x5984
leaq 0xa8(%r14), %rdi
pushq $0x1
popq %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2200
movl %ebx, 0xa4(%r14)
testl %ebx, %ebx
js 0x597e
shll $0xc, %ebx
movq (%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2170
addq $0xa8, %r14
movq (%r15), %rcx
pushq $0x1
popq %rsi
movl $0x1000, %edx           # imm = 0x1000
movq %r14, %rdi
callq 0x2050
movq (%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
popq %rbx
popq %r14
popq %r15
jmp 0x2170
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1d12(%rip), %rdi      # 0x769d
leaq 0x1cea(%rip), %rsi      # 0x767c
leaq 0x1d0e(%rip), %rcx      # 0x76a7
pushq $0x40
popq %rdx
callq 0x20d0
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rf11.c
// Function: busaddr
static int
busaddr(RF11 *rf)
{
	int addr = rf->cma | (rf->dcs&060)<<12;
	if((rf->dae & CMA_INH)==0){
		rf->cma += 2;
		if(rf->cma == 0)
			SETMASK(rf->dcs, rf->dcs+020, 060);
	}
	return addr;
}

// Assembly:
movzwl 0xc(%rdi), %ecx
movzwl 0x8(%rdi), %eax
testb $0x1, 0x11(%rdi)
jne 0x59cc
movl %ecx, %edx
addw $0x2, %dx
movw %dx, 0xc(%rdi)
jne 0x59cc
movl %eax, %edx
andl $-0x31, %edx
leal 0x10(%rax), %esi
andl $0x30, %esi
orl %edx, %esi
movw %si, 0x8(%rdi)
andl $0x30, %eax
shll $0xc, %eax
orl %ecx, %eax
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rk11.c
// Function: dati_rk11
int
dati_rk11(Bus *bus, void *dev)
{
	RK11 *rk = dev;
	rk->bus = bus;
	if(bus->addr >= 0777400 && bus->addr < 0777420){
		switch(bus->addr&016){
		case 000: bus->data = rk->rkds | rk->drives[rk->d].rkds; break;
		case 002: bus->data = rk->rker; break;
		case 004: bus->data = rk->rkcs; break;
		case 006: bus->data = rk->rkwc; break;
		case 010: bus->data = rk->rkba; break;
		case 012: bus->data = rk->rkda; break;
		case 014: bus->data = rk->rkmr; break;
		case 016: bus->data = rk->rkdb; break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movq %rdi, (%rsi)
movl 0x8(%rdi), %eax
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0x3ff00, %ecx          # imm = 0x3FF00
jne 0x5a11
andl $0xe, %eax
leaq 0x1ccf(%rip), %rcx      # 0x76c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x20(%rsi), %rax
imulq $0x30, %rax, %rax
movzwl 0x34(%rsi,%rax), %eax
orw 0x8(%rsi), %ax
jmp 0x5a3d
pushq $0x1
popq %rax
retq
movzwl 0xe(%rsi), %eax
jmp 0x5a3d
movzwl 0x16(%rsi), %eax
jmp 0x5a3d
movzwl 0xc(%rsi), %eax
jmp 0x5a3d
movzwl 0xa(%rsi), %eax
jmp 0x5a3d
movzwl 0x12(%rsi), %eax
jmp 0x5a3d
movzwl 0x14(%rsi), %eax
jmp 0x5a3d
movzwl 0x10(%rsi), %eax
movw %ax, 0xc(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rk11.c
// Function: datox_rk11
static int
datox_rk11(Bus *bus, RK11 *rk, word mask)
{
	rk->bus = bus;
	if(bus->addr >= 0777400 && bus->addr < 0777420){
		switch(bus->addr&017){
		case 000:	// RKDS
		case 001:
		case 002:	// RKER
		case 003:
			break;	// read only

		case 004:	// RKCS
		case 005:
			SETMASK(rk->rkcs, bus->data, mask&0017577);
			break;
		case 006:	// RKWC
		case 007:
			SETMASK(rk->rkwc, bus->data, mask);
			break;
		case 010:	// RKBA
		case 011:
			SETMASK(rk->rkba, bus->data, mask);
			break;
		case 012:	// RKDA
		case 013:
			if(rk->rkcs & RDY){
				SETMASK(rk->rkda, bus->data, mask);
				rk->d = (rk->rkda>>13) & 7;
			}else if((rk->rkcs & GO)==0)
				rk->done = 1;
			break;
		case 014:	// RKMR
		case 015:
			// not implemented
			break;
		case 016:	// RKDB
		case 017:
			// read only
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
movq %rdi, (%rsi)
movl 0x8(%rdi), %ecx
movl %ecx, %eax
andl $-0x10, %eax
cmpl $0x3ff00, %eax          # imm = 0x3FF00
jne 0x5a73
andl $0xf, %ecx
xorl %eax, %eax
leaq 0x1c97(%rip), %r8       # 0x7700
movslq (%r8,%rcx,4), %rcx
addq %r8, %rcx
jmpq *%rcx
retq
pushq $0x1
popq %rax
retq
movzwl 0xc(%rsi), %ecx
movzwl 0xc(%rdi), %edi
xorw %cx, %di
andl %edx, %edi
andl $0x1f7f, %edi           # imm = 0x1F7F
xorl %edi, %ecx
movw %cx, 0xc(%rsi)
retq
movzwl 0xc(%rsi), %ecx
testb %cl, %cl
js 0x5ace
testb $0x1, %cl
jne 0x5a72
movl $0x1, 0x1c(%rsi)
retq
movzwl 0xe(%rsi), %ecx
movzwl 0xc(%rdi), %edi
xorw %cx, %di
andl %edx, %edi
xorl %edi, %ecx
movw %cx, 0xe(%rsi)
retq
movzwl 0x10(%rsi), %ecx
movzwl 0xc(%rdi), %edi
xorw %cx, %di
andl %edx, %edi
xorl %edi, %ecx
movw %cx, 0x10(%rsi)
retq
movzwl 0x12(%rsi), %ecx
movzwl 0xc(%rdi), %edi
xorw %cx, %di
andl %edx, %edi
xorl %edi, %ecx
movzwl %cx, %ecx
movw %cx, 0x12(%rsi)
shrl $0xd, %ecx
movl %ecx, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/rk11.c
// Function: start_rk11
void
start_rk11(RK05 *drive, RK11 *rk)
{
	drive->func = (rk->rkcs>>1) & 7;
	rk->rkcs &= ~SCP;
	rk->done = 0;


	switch(drive->func){
	case FR_CTL_RESET:
		reset_rk11(rk);
		break;
	case FR_WRITE:
	case FR_READ:
	case FR_WRITE_CHECK:
	case FR_READ_CHECK:
		rk->rkcs &= ~RDY;
		if(drive->fp == nil)
			rkerr(drive, rk, NXD);
		if((rk->rkda&017) >= 12)
			rkerr(drive, rk, NXS);
		if(((rk->rkda>>5)&0377) >= 0312)
			rkerr(drive, rk, NXC);
		if(drive->rkds & WPS &&
		   (drive->func == FR_WRITE || drive->func == FR_WRITE_CHECK))
			rkerr(drive, rk, WLO);
		else
			drive->newcyl = (rk->rkda>>5)&0377;
		break;
	case FR_SEEK:
		drive->newcyl = (rk->rkda>>5)&0377;
		break;
	case FR_DRIVE_RESET:
		reset_rk05(&rk->drives[rk->d]);
		break;
	case FR_WRITE_LOCK:
		drive->rkds |= WPS;
		drive->func = 0;
		break;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movzwl 0xc(%rsi), %eax
movl %eax, %ecx
shrl %ecx
andl $0x7, %ecx
movl %ecx, 0x10(%rdi)
movl %eax, %edx
andl $0xdfff, %edx           # imm = 0xDFFF
movw %dx, 0xc(%rsi)
andl $0x0, 0x1c(%rsi)
leaq 0x1c10(%rip), %rdx      # 0x7740
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
andl $0xdf7f, %eax           # imm = 0xDF7F
movw %ax, 0xc(%r14)
cmpq $0x0, (%rbx)
jne 0x5b59
movq %rbx, %rdi
movq %r14, %rsi
movl $0x80, %edx
callq 0x5c4e
movzwl 0x12(%r14), %eax
movl %eax, %ecx
notl %ecx
testb $0xc, %cl
jne 0x5b7a
pushq $0x20
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5c4e
movzwl 0x12(%r14), %eax
andl $0x1fc0, %eax           # imm = 0x1FC0
cmpw $0x1921, %ax            # imm = 0x1921
jb 0x5b93
pushq $0x40
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5c4e
testb $0x20, 0xc(%rbx)
je 0x5bbb
movl 0x10(%rbx), %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0x5bbb
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2000, %edx           # imm = 0x2000
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5c4e
movzwl 0x12(%r14), %eax
shrl $0x5, %eax
movzbl %al, %eax
movl %eax, 0x20(%rbx)
jmp 0x5c07
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5c0f
orb $0x20, 0xc(%rbx)
andl $0x0, 0x10(%rbx)
jmp 0x5c07
movslq 0x20(%r14), %rax
imulq $0x30, %rax, %rax
movw $0x800, 0x34(%r14,%rax) # imm = 0x800
andq $0x0, 0x38(%r14,%rax)
andl $0x0, 0x48(%r14,%rax)
andw $0x0, 0x54(%r14,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq