LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
andl $-0x3f, %ecx
movb %cl, 0x7(%rax)
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0x6f7b
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2570
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x6f9e
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x6fac
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x2570
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x6fac
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x7(%rax)
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x6fd3
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0x6fd3
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x7(%rax)
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x6fee
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
orl $0x8, %ecx
movb %cl, 0x7(%rax)
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0x7008
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
orl $0x10, %ecx
movb %cl, 0x7(%rax)
movq -0x8(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x7024
movq -0x8(%rbp), %rax
movzbl 0x7(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x7(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3ff66, 0x8(%rax)     # imm = 0x3FF66
jne 0x70fa
movq -0x20(%rbp), %rax
movl (%rax), %eax
shll $0x6, %eax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x7101
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3ff66, 0x8(%rax)     # imm = 0x3FF66
jne 0x7176
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
sarl $0x6, %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x716d
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x717d
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kw11.c
// Function: datob_kw11
int
datob_kw11(Bus *bus, void *dev)
{
	if(bus->addr == 0777546){
		/* ignore odd bytes */
		if(bus->addr & 1)
			return 0;
		return dato_kw11(bus, dev);
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3ff66, 0x8(%rax)     # imm = 0x3FF66
jne 0x71d7
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x71c5
movl $0x0, -0x4(%rbp)
jmp 0x71de
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7110
movl %eax, -0x4(%rbp)
jmp 0x71de
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kw11.c
// Function: svc_kw11
int
svc_kw11(Bus *bus, void *dev)
{
	KW11 *kw = dev;
	if(handleclock(&kw->clock)){
		kw->lc_clock = 1;
		kw->lc_int = 1;
	}
	return kw->lc_int && kw->lc_int_enab ? 6 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x98b0
cmpl $0x0, %eax
je 0x7230
movq -0x18(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0x8(%rax)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
movb %al, -0x19(%rbp)
je 0x724c
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
setne %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %dl
xorl %eax, %eax
movl $0x6, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kw11.c
// Function: reset_kw11
void
reset_kw11(void *dev)
{
	KW11 *kw = dev;
	kw->lc_int_enab = 0;
	// TODO: 1?
	kw->lc_clock = 0;
	kw->lc_int = 0;

	initclock(&kw->clock, CLOCKFREQ);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
movl $0xfe502a, %esi         # imm = 0xFE502A
callq 0x9860
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3ff70, 0x8(%rax)     # imm = 0x3FF70
jb 0x7413
movq -0x10(%rbp), %rax
cmpl $0x3ff78, 0x8(%rax)     # imm = 0x3FF78
jae 0x7413
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x6, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x6, %eax
ja 0x73eb
movq -0x28(%rbp), %rax
leaq 0x4292(%rip), %rcx      # 0xb5e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
shll $0x6, %eax
movq -0x20(%rbp), %rcx
movl 0x10(%rcx), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll $0xb, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x740a
movq -0x20(%rbp), %rax
movzbl 0x14(%rax), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x14(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x740a
movq -0x20(%rbp), %rax
movl (%rax), %eax
shll $0x2, %eax
movq -0x20(%rbp), %rcx
movl 0x18(%rcx), %ecx
shll $0x6, %ecx
orl %ecx, %eax
movq -0x20(%rbp), %rcx
movl 0x1c(%rcx), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x740a
movq -0x10(%rbp), %rax
movw $0x0, 0xc(%rax)
jmp 0x740a
leaq 0x4019(%rip), %rdi      # 0xb40b
leaq 0x4223(%rip), %rsi      # 0xb61c
movl $0x22, %edx
leaq 0x421e(%rip), %rcx      # 0xb623
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x741a
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3ff70, 0x8(%rax)     # imm = 0x3FF70
jb 0x75aa
movq -0x10(%rbp), %rax
cmpl $0x3ff78, 0x8(%rax)     # imm = 0x3FF78
jae 0x75aa
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x7, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x7, %eax
ja 0x7582
movq -0x28(%rbp), %rax
leaq 0x416e(%rip), %rcx      # 0xb5fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
sarl $0x6, %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x74d7
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x28(%rax)
jmp 0x74f0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x74ee
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x28(%rax)
jmp 0x74f0
jmp 0x75a1
jmp 0x75a1
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
sarl $0x2, %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
sarl $0x6, %ecx
andl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x753c
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x28(%rax)
jmp 0x7555
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x7553
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x7555
jmp 0x75a1
movq -0x10(%rbp), %rax
movw 0xc(%rax), %ax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x24(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x1c(%rax)
jmp 0x75a1
jmp 0x75a1
leaq 0x3e82(%rip), %rdi      # 0xb40b
leaq 0x408c(%rip), %rsi      # 0xb61c
movl $0x52, %edx
leaq 0x40a4(%rip), %rcx      # 0xb640
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x75b1
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl 0x106ce(%rip), %eax     # 0x17cdc
addl $0x1, %eax
movl %eax, 0x106c5(%rip)     # 0x17cdc
cmpl $0x4e20, 0x106bb(%rip)  # imm = 0x4E20
jne 0x76f2
movq -0x20(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x7683
movq -0x20(%rbp), %rax
movzbl 0x24(%rax), %eax
andl $0x7f, %eax
movb %al, -0x21(%rbp)
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %edi
leaq -0x21(%rbp), %rsi
movl $0x1, %edx
callq 0x2070
movq -0x20(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x7681
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x7683
movq -0x20(%rbp), %rdi
addq $0x2c, %rdi
leaq -0x11(%rbp), %rsi
callq 0x99d0
cmpl $0x0, %eax
je 0x76e8
movq -0x20(%rbp), %rax
movl $0x1, 0x8(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0xc(%rax)
movb -0x11(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x14(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x76e6
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x28(%rax)
jmp 0x76e8
movl $0x0, 0x105ea(%rip)     # 0x17cdc
movq -0x20(%rbp), %rax
movl 0x28(%rax), %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kl11.c
// Function: bg_kl11
int
bg_kl11(void *dev)
{
	KL11 *kl = dev;

	// reader interrupt
	if(kl->intr_flags & 2){
		kl->intr_flags &= ~2;
		return 060;
	}

	// punch interrupt
	if(kl->intr_flags & 1){
		kl->intr_flags &= ~1;
		return 064;
	}
	assert(0);	// can't happen
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7749
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x28(%rax)
movl $0x30, -0x4(%rbp)
jmp 0x778d
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x776e
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x28(%rax)
movl $0x34, -0x4(%rbp)
jmp 0x778d
leaq 0x3c96(%rip), %rdi      # 0xb40b
leaq 0x3ea0(%rip), %rsi      # 0xb61c
movl $0x9b, %edx
leaq 0x3ed5(%rip), %rcx      # 0xb65d
callq 0x20d0
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kl11.c
// Function: reset_kl11
void
reset_kl11(void *dev)
{
	KL11 *kl = dev;
	kl->rdr_busy = 0;
	kl->rdr_enab = 0;
	kl->rdr_int_enab = 0;
	kl->rdr_done = 0;
	kl->rdr_buf = 0;

	kl->pun_int_enab = 0;
	kl->maint = 0;
	kl->pun_ready = 1;
	kl->pun_halt = 1;
	kl->pun_buf = 0;

	kl->intr_flags = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x20(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x24(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x3ff30, 0x8(%rax)     # imm = 0x3FF30
jb 0x7976
movq -0x10(%rbp), %rax
cmpl $0x3ff40, 0x8(%rax)     # imm = 0x3FF40
jae 0x7976
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0xe, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xe, %eax
ja 0x794e
movq -0x28(%rbp), %rax
leaq 0x3ddb(%rip), %rcx      # 0xb674
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movw 0x8(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0xa(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0xe(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0x10(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0x12(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
movw 0x14(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
movq -0x20(%rbp), %rax
addq $0x20, %rax
movq -0x20(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0x8(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x796d
leaq 0x3ab6(%rip), %rdi      # 0xb40b
leaq 0x3d94(%rip), %rsi      # 0xb6f0
movl $0x68, %edx
leaq 0x3d8f(%rip), %rcx      # 0xb6f7
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x797d
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jge 0x7d1e
movq -0x20(%rbp), %rdi
addq $0x20, %rdi
movslq -0x14(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x14(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %edx
callq 0x7db0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7cdf
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0x7e00, %eax           # imm = 0x7E00
cmpl $0x0, %eax
je 0x7d44
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
movw %cx, 0x8(%rax)
jmp 0x7d56
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %ecx
andl $0xffff7fff, %ecx       # imm = 0xFFFF7FFF
movw %cx, 0x8(%rax)
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %ecx
andl $0x40, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x21(%rbp)
je 0x7d96
movq -0x20(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x18(%rcx)
movb %al, -0x22(%rbp)
jne 0x7d90
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
setne %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %dl
xorl %eax, %eax
movl $0x5, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rf11.c
// Function: reset_rf11
void
reset_rf11(void *dev)
{
	RF11 *rf = dev;
	rf->dcs = RDY;
	rf->wc = 0;
	rf->cma = 0;
	rf->dar = 0;
	rf->dae = 0;
	seldisk(rf, 0);
	rf->dbr = 0;
	rf->ma = 0;

	rf->done = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movw $0x80, 0x8(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0xa(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0xe(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x10(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x8110
movq -0x10(%rbp), %rax
movw $0x0, 0x12(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x812d
jmp 0x8161
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8310
movl -0xc(%rbp), %ecx
andl $0x7, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0xc(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x8161
movq -0x8(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
callq 0x84a0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x81a8
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x8270
movq -0x18(%rbp), %rdi
leaq 0x3561(%rip), %rsi      # 0xb714
callq 0x21b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x8213
movq -0x18(%rbp), %rdi
leaq 0x3522(%rip), %rsi      # 0xb717
callq 0x21b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x8248
movq 0x5dc5(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x34d9(%rip), %rsi      # 0xb71a
movb $0x0, %al
callq 0x2120
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xc(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x82f0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x82cd
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2080
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xc(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x82f0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0xa4(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x8333
jmp 0x8416
movq -0x8(%rbp), %rax
addq $0x20, %rax
movq -0x8(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0xa0(%rax)
je 0x83a7
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x8367
jmp 0x8386
leaq 0x33e4(%rip), %rdi      # 0xb752
leaq 0x337b(%rip), %rsi      # 0xb6f0
movl $0x40, %edx
leaq 0x33db(%rip), %rcx      # 0xb75c
callq 0x20d0
movq -0x8(%rbp), %rdi
addq $0xa8, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2200
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0xa4(%rax)
jl 0x8416
movq -0x8(%rbp), %rax
movl 0xa4(%rax), %eax
shll $0xc, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movslq -0x1c(%rbp), %rsi
xorl %edx, %edx
callq 0x2170
movq -0x8(%rbp), %rdi
addq $0xa8, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2040
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movslq -0x1c(%rbp), %rsi
xorl %edx, %edx
callq 0x2170
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0x8(%rcx), %ecx
andl $0x30, %ecx
shll $0xc, %ecx
orl %ecx, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x10(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x8499
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
addl $0x2, %ecx
movw %cx, 0xc(%rax)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
cmpl $0x0, %eax
jne 0x8497
movq -0x8(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $-0x31, %eax
movq -0x8(%rbp), %rcx
movzwl 0x8(%rcx), %ecx
addl $0x10, %ecx
andl $0x30, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
jmp 0x8499
movl -0xc(%rbp), %eax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x3ff00, 0x8(%rax)     # imm = 0x3FF00
jb 0x8620
movq -0x10(%rbp), %rax
cmpl $0x3ff10, 0x8(%rax)     # imm = 0x3FF10
jae 0x8620
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0xe, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xe, %eax
ja 0x85f8
movq -0x28(%rbp), %rax
leaq 0x323f(%rip), %rcx      # 0xb778
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movzwl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
addq $0x28, %rcx
movq -0x20(%rbp), %rdx
movslq 0x20(%rdx), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movzwl 0xc(%rcx), %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0xa(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0xe(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0x10(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0x12(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0x14(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
movq -0x20(%rbp), %rax
movw 0x16(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x8617
leaq 0x2e0c(%rip), %rdi      # 0xb40b
leaq 0x320e(%rip), %rsi      # 0xb814
movl $0x54, %edx
leaq 0x3209(%rip), %rcx      # 0xb81b
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x8627
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
shrl %ecx
andl $0x7, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movw 0xc(%rax), %cx
andw $0xdfff, %cx            # imm = 0xDFFF
movw %cx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x18(%rbp)
subq $0x7, %rax
ja 0x8a03
movq -0x18(%rbp), %rax
leaq 0x2f25(%rip), %rcx      # 0xb7f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
callq 0x8a10
jmp 0x8a03
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movw %cx, 0xc(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x8914
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x80, %edx
callq 0x8ad0
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0xf, %eax
cmpl $0xc, %eax
jl 0x8936
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x20, %edx
callq 0x8ad0
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
sarl $0x5, %eax
andl $0xff, %eax
cmpl $0xca, %eax
jl 0x895f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x40, %edx
callq 0x8ad0
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x8997
movq -0x8(%rbp), %rax
cmpl $0x1, 0x10(%rax)
je 0x8983
movq -0x8(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0x8997
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x8ad0
jmp 0x89af
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %ecx
sarl $0x5, %ecx
andl $0xff, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x8a03
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %ecx
sarl $0x5, %ecx
andl $0xff, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x8a03
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movslq 0x20(%rax), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x8b30
jmp 0x8a03
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %ecx
orl $0x20, %ecx
movw %cx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: reset_rk11
void
reset_rk11(void *dev)
{
	int i;
	RK11 *rk = dev;
	rk->rkds = 0;
	rk->rker = 0;
	rk->rkcs = RDY;
	rk->rkwc = 0;
	rk->rkba = 0;
	rk->rkda = 0;
	rk->rkmr = 0;
	rk->rkdb = 0;

	rk->state = 0;
	rk->done = 0;

	rk->d = 0;
	for(i = 0; i < 8; i++)
		reset_rk05(&rk->drives[i]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movw $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0xa(%rax)
movq -0x18(%rbp), %rax
movw $0x80, 0xc(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0xe(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x12(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x14(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x16(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x20(%rax)
movl $0x0, -0xc(%rbp)
cmpl $0x8, -0xc(%rbp)
jge 0x8ac5
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movslq -0xc(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x8b30
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8a9c
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: rkerr
static void
rkerr(RK05 *drive, RK11 *rk, int err)
{
	rk->rker |= err;
	if(rk->rker & 177740){
		rk->rkcs |= RDY;
		drive->func = 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movzwl 0xa(%rax), %ecx
orl %edx, %ecx
movw %cx, 0xa(%rax)
movq -0x10(%rbp), %rax
movzwl 0xa(%rax), %eax
andl $0x2b64c, %eax          # imm = 0x2B64C
cmpl $0x0, %eax
je 0x8b1f
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %ecx
orl $0x80, %ecx
movw %cx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: reset_rk05
void
reset_rk05(RK05 *drive)
{
	// TODO: figure out what to actually do here
	drive->rkds = HDEN;

	drive->func = 0;
	drive->cyl_timer = 0;

	drive->newcyl = 0;

	drive->dsb = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw $0x800, 0xc(%rax)       # imm = 0x800
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x8(%rbp), %rax
movw $0x0, 0x2c(%rax)
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: svc_rk11
int
svc_rk11(Bus *bus, void *dev)
{
	int i;
	RK11 *rk = dev;

	if((rk->rkcs & RDY) && (rk->rkcs & GO)){
		rk->rkcs &= ~GO;
		start_rk11(&rk->drives[rk->d], rk);
	}
	for(i = 0; i < 8; i++)
		svc_rk05(&rk->drives[i], rk, rk->d == i);

	if(rk->rker & 177740)
		rk->rkcs |= HE;
	else
		rk->rkcs &= ~HE;
	if(rk->rker)
		rk->rkcs |= ERR;
	else
		rk->rkcs &= ~ERR;

	return (rk->rkcs&IDE) &&
// TODO: probably just have one interrupt bit?
	       (rk->done || (rk->rkcs&HE) || (rk->rkcs&ERR) && (rk->rkcs&SSE)) ?
		5 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8bd9
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8bd9
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $-0x2, %ecx
movw %cx, 0xc(%rax)
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
movq -0x20(%rbp), %rax
movslq 0x20(%rax), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x8870
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jge 0x8c1f
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
movslq -0x14(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
cmpl -0x14(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %edx
callq 0x8d20
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8be0
movq -0x20(%rbp), %rax
movzwl 0xa(%rax), %eax
andl $0x2b64c, %eax          # imm = 0x2B64C
cmpl $0x0, %eax
je 0x8c45
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
orl $0x4000, %ecx           # imm = 0x4000
movw %cx, 0xc(%rax)
jmp 0x8c57
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xffffbfff, %ecx       # imm = 0xFFFFBFFF
movw %cx, 0xc(%rax)
movq -0x20(%rbp), %rax
cmpw $0x0, 0xa(%rax)
je 0x8c76
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
orl $0x8000, %ecx           # imm = 0x8000
movw %cx, 0xc(%rax)
jmp 0x8c88
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0xffff7fff, %ecx       # imm = 0xFFFF7FFF
movw %cx, 0xc(%rax)
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x40, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x21(%rbp)
je 0x8cfe
movq -0x20(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x1c(%rcx)
movb %al, -0x22(%rbp)
jne 0x8cf8
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x4000, %ecx           # imm = 0x4000
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x22(%rbp)
jne 0x8cf8
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %ecx
andl $0x8000, %ecx           # imm = 0x8000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x23(%rbp)
je 0x8cf2
movq -0x20(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
setne %al
movb %al, -0x23(%rbp)
movb -0x23(%rbp), %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %dl
xorl %eax, %eax
movl $0x5, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: attach_rk05
void
attach_rk05(RK11 *rk, int n, char *path)
{
	if(rk->drives[n].fp)
		detach_rk05(rk, n);
	rk->drives[n].fp = fopen(path, "r+");
	if(rk->drives[n].fp == nil)
		rk->drives[n].fp = fopen(path, "w+");
	if(rk->drives[n].fp == nil)
		fprintf(stderr, "couldn't open '%s'\n", path);
	reset_rk05(&rk->drives[n]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x92f8
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x93c0
movq -0x18(%rbp), %rdi
leaq 0x2411(%rip), %rsi      # 0xb714
callq 0x21b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x9363
movq -0x18(%rbp), %rdi
leaq 0x23d2(%rip), %rsi      # 0xb717
callq 0x21b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x9398
movq 0x4c75(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2389(%rip), %rsi      # 0xb71a
movb $0x0, %al
callq 0x2120
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movslq -0xc(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x8b30
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: detach_rk05
void
detach_rk05(RK11 *rk, int n)
{
	if(rk->drives[n].fp){
		fclose(rk->drives[n].fp);
		rk->drives[n].fp = nil;
	}
	reset_rk05(&rk->drives[n]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x941d
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2080
movq -0x8(%rbp), %rax
addq $0x28, %rax
movslq -0xc(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movslq -0xc(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x8b30
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: busaddr
static int
busaddr(RK11 *rk)
{
	int addr = rk->rkba | (rk->rkcs&060)<<12;
	if((rk->rkcs & IBA)==0){
		rk->rkba += 2;
		if(rk->rkba == 0)
			SETMASK(rk->rkcs, rk->rkcs+020, 060);
	}
	return addr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
andl $0x30, %ecx
shll $0xc, %ecx
orl %ecx, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x94d9
movq -0x8(%rbp), %rax
movzwl 0x10(%rax), %ecx
addl $0x2, %ecx
movw %cx, 0x10(%rax)
movq -0x8(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x94d7
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $-0x31, %eax
movq -0x8(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
addl $0x10, %ecx
andl $0x30, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x94d9
movl -0xc(%rbp), %eax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: count
static void
count(RK05 *drive, RK11 *rk)
{
	word rkda;

	if(rk->rkwc == 0)
		return;

	rkda = rk->rkda+1;
	if((rkda & 017) == 12)
		rkda = (rkda&~017)+020;
	if((rkda&0160000) != (rk->rkda&0160000))
		rkerr(drive, rk, OVR);
	SETMASK(rk->rkda, rkda, 017777);

	// seek
	drive->newcyl = (rkda>>5) & 0377;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzwl 0xe(%rax), %eax
cmpl $0x0, %eax
jne 0x9502
jmp 0x9590
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
addl $0x1, %eax
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
andl $0xf, %eax
cmpl $0xc, %eax
jne 0x952b
movzwl -0x12(%rbp), %eax
andl $-0x10, %eax
addl $0x10, %eax
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
andl $0xe000, %eax           # imm = 0xE000
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
andl $0xe000, %ecx           # imm = 0xE000
cmpl %ecx, %eax
je 0x9558
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x4000, %edx           # imm = 0x4000
callq 0x8ad0
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0xffffe000, %eax       # imm = 0xFFFFE000
movzwl -0x12(%rbp), %ecx
andl $0x1fff, %ecx           # imm = 0x1FFF
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%rax)
movzwl -0x12(%rbp), %ecx
sarl $0x5, %ecx
andl $0xff, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/mem.c
// Function: dati_mem
int
dati_mem(Bus *bus, void *dev)
{
	Memory *mem = dev;
	uint32 waddr = bus->addr>>1;
	if(waddr >= mem->start && waddr < mem->end){
		bus->data = mem->mem[waddr-mem->start];
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jb 0x9600
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x9600
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rdx
subl 0x8(%rdx), %ecx
movl %ecx, %ecx
movw (%rax,%rcx,2), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xc(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x9607
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/mem.c
// Function: dato_mem
int
dato_mem(Bus *bus, void *dev)
{
	Memory *mem = dev;
	uint32 waddr = bus->addr>>1;
	if(waddr >= mem->start && waddr < mem->end){
		mem->mem[waddr-mem->start] = bus->data;
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jb 0x9670
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x9670
movq -0x10(%rbp), %rax
movw 0xc(%rax), %dx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rsi
subl 0x8(%rsi), %ecx
movl %ecx, %ecx
movw %dx, (%rax,%rcx,2)
movl $0x0, -0x4(%rbp)
jmp 0x9677
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/mem.c
// Function: datob_mem
int
datob_mem(Bus *bus, void *dev)
{
	Memory *mem = dev;
	uint32 waddr = bus->addr>>1;
	if(waddr >= mem->start && waddr < mem->end){
		mem->mem[waddr-mem->start] &= (bus->addr&1) ? 0377 : ~0377;
		mem->mem[waddr-mem->start] |= bus->data & ((bus->addr&1) ? ~0377 : 0377);
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jb 0x9741
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x9741
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0x1, %ecx
movl $0xffffff00, %esi       # imm = 0xFFFFFF00
movl $0xff, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rdx
subl 0x8(%rdx), %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %edx
andl %esi, %edx
movw %dx, (%rax,%rcx,2)
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
andl $0x1, %edx
movl $0xff, %eax
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
cmpl $0x0, %edx
cmovnel %ecx, %eax
andl %eax, %esi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rdx
subl 0x8(%rdx), %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %edx
orl %esi, %edx
movw %dx, (%rax,%rcx,2)
movl $0x0, -0x4(%rbp)
jmp 0x9748
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/mem.c
// Function: dato_rom
int
dato_rom(Bus *bus, void *dev)
{
	Memory *mem = dev;
	uint32 waddr = bus->addr>>1;
	if(waddr >= mem->start && waddr < mem->end)
		return 0;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jb 0x9801
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x9801
movl $0x0, -0x4(%rbp)
jmp 0x9808
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/unix.c
// Function: handleclock
int
handleclock(Clock *clk)
{
	struct timespec diff;
	clock_gettime(CLOCK_REALTIME, &clk->newtime);
	diff.tv_sec = clk->newtime.tv_sec - clk->oldtime.tv_sec;
	diff.tv_nsec = clk->newtime.tv_nsec - clk->oldtime.tv_nsec;
	if(diff.tv_nsec < 0){
		diff.tv_nsec += 1000000000;
		diff.tv_sec -= 1;
	}
	if(diff.tv_nsec >= clk->period){
		clk->oldtime.tv_nsec += clk->period;
		if(clk->oldtime.tv_nsec >= 1000000000){
			clk->oldtime.tv_nsec -= 1000000000;
			clk->oldtime.tv_sec += 1;
		}
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
xorl %edi, %edi
callq 0x2060
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
subq (%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x8(%rcx), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jge 0x9913
movq -0x18(%rbp), %rax
addq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jl 0x996d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x3b9aca00, 0x8(%rax)  # imm = 0x3B9ACA00
jl 0x9964
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
subq $0x3b9aca00, %rcx       # imm = 0x3B9ACA00
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x9974
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)