// File: /workspace/github_c_makefile_star2_O1/aap[P]rx-0/pdp1/mach.c
// Function: simthread
void*
simthread(void *arg)
{
	PDP1 *pdp = (PDP1*)arg;
	Msg msg;
	for(;;){
		switch(channbrecv(cmdchan, &msg)){
		case -1:	// channel closed
			return nil;
		case 0: break;  // nothing
		case 1:
			handlemsg(pdp, msg);
			break;
		}

		// a cycle takes 5μs
		if(pdp->run) {
			!pdp->cyc ? cycle0(pdp) :
			pdp->df1 ? defer(pdp)
				: cycle1(pdp);
//printf("%s %s  hack/%d\n", pdp->cyc ? "cyc" : "   ", pdp->df1 ? "df1" : "   ", pdp->cychack);
		}
//		handleio(pdp);
	}
	return nil;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0x30(%rbp), %r14
movl $0x40008061, %r12d      # imm = 0x40008061
movl $0xfff, %r15d           # imm = 0xFFF
xorl %r13d, %r13d
movq 0xdcf7(%rip), %rdi      # 0x12678
movq %r14, %rsi
callq 0x4113
cmpl $0x1, %eax
je 0x4998
cmpl $-0x1, %eax
jne 0x49a4
jmp 0x533f
movq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x4782
cmpl $0x0, 0x4034(%rbx)
je 0x497a
cmpl $0x0, 0x403c(%rbx)
je 0x4a1e
cmpl $0x0, 0x4040(%rbx)
je 0x4bef
movl 0x8(%rbx), %eax
andl %r15d, %eax
orl 0xc(%rbx), %eax
movl %eax, 0xc(%rbx)
movl %r13d, 0x8(%rbx)
movl 0x18(%rbx,%rax,4), %ecx
movl %ecx, 0x8(%rbx)
movl %r13d, 0x18(%rbx,%rax,4)
btl $0xc, %ecx
jb 0x4c97
movl 0x14(%rbx), %edx
cmpl $0x18, %edx
je 0x49fb
cmpl $0x19, %edx
jne 0x4a02
movl 0x10(%rbx), %esi
movl %esi, (%rbx)
movl $0x0, 0x10(%rbx)
andl $-0x2, %edx
cmpl $0x18, %edx
jne 0x4ca1
movl %ecx, %edx
andl $0xfff, %edx            # imm = 0xFFF
orl %edx, 0x10(%rbx)
jmp 0x4ca1
cmpl $0x4, 0x4080(%rbx)
je 0x4ac6
cmpl $0x1b, 0x14(%rbx)
jne 0x4a3f
testb $0x20, 0x8(%rbx)
je 0x4a3f
movq %rbx, %rdi
callq 0x55a9
movl 0x10(%rbx), %eax
movl 0x14(%rbx), %ecx
orl %eax, 0xc(%rbx)
cmpl $0x1b, %ecx
jne 0x4a5b
testb $0x40, 0x8(%rbx)
je 0x4a5b
movq %rbx, %rdi
callq 0x55a9
cmpl $0x1b, 0x14(%rbx)
jne 0x4a6f
testb $-0x80, 0x8(%rbx)
je 0x4a6f
movq %rbx, %rdi
callq 0x55a9
movl 0x10(%rbx), %ecx
movl 0x14(%rbx), %eax
incl %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, 0x10(%rbx)
cmpl $0x1d, %eax
jne 0x4aa2
xorl %ecx, %ecx
cmpl $0x0, 0x406c(%rbx)
jne 0x4a9c
xorl %ecx, %ecx
cmpl $0x0, 0x4064(%rbx)
sete %cl
movl %ecx, 0x4060(%rbx)
movl $0x0, 0x4064(%rbx)
cmpl $0x1b, %eax
jne 0x4abf
testb $0x1, 0x9(%rbx)
je 0x4abf
movq %rbx, %rdi
callq 0x55a9
movl $0x0, 0x8(%rbx)
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %ecx
orl 0x18(%rbx,%rcx,4), %eax
movl %eax, 0x8(%rbx)
movl $0x0, 0x18(%rbx,%rcx,4)
movl %eax, %ecx
shrl $0xd, %ecx
movl %ecx, 0x14(%rbx)
movl %eax, %edx
andl $0x1000, %edx           # imm = 0x1000
cmpl $0x1d, %ecx
je 0x4b1d
testl %edx, %edx
je 0x4b1d
cmpl $0x7, %ecx
je 0x4b1d
cmpl $0x1f, %ecx
je 0x4b1d
movl %eax, %esi
andl $0xffffc000, %esi       # imm = 0xFFFFC000
cmpl $0x34000, %esi          # imm = 0x34000
je 0x4b1d
cmpl $0x1c, %ecx
je 0x4b1d
movl $0x1, 0x4040(%rbx)
movl %ecx, %esi
xorl $0x1d, %esi
orl %edx, %esi
jne 0x4b4a
cmpl $0x0, 0x406c(%rbx)
je 0x4b4a
movabsq $0x100000001, %rdx      # imm = 0x100000001
movq %rdx, 0x4060(%rbx)
movl $0x0, 0x406c(%rbx)
cmpl $0x1b, %ecx
setne %cl
testb $0x1, %al
sete %al
orb %cl, %al
jne 0x4b61
movq %rbx, %rdi
callq 0x55a9
movl 0x14(%rbx), %eax
cmpl $0x19, %eax
jne 0x4b72
cmpl $0x0, 0x4040(%rbx)
je 0x4b87
cmpl $0x1c, %eax
je 0x4b87
cmpl $0x1d, %eax
je 0x4ba9
cmpl $0x1f, %eax
jne 0x4bcb
testb $-0x80, 0x8(%rbx)
je 0x4b8d
movl $0x0, (%rbx)
cmpl $0x1d, %eax
je 0x4ba9
cmpl $0x1f, %eax
jne 0x4bcb
testb $0x8, 0x9(%rbx)
je 0x4ba4
movl $0x0, 0x4(%rbx)
cmpl $0x1d, %eax
jne 0x4bcb
testb $0x10, 0x9(%rbx)
je 0x4bcb
cmpl $0x0, 0x406c(%rbx)
jne 0x4bcb
cmpl $0x0, 0x4064(%rbx)
jne 0x4bcb
movl $0x1, 0x406c(%rbx)
cmpl $0x0, 0x4040(%rbx)
je 0x4d06
cmpl $0x1b, %eax
je 0x4e04
cmpl $0x1a, %eax
je 0x4d3a
jmp 0x4e12
cmpl $0x1, 0x4080(%rbx)
je 0x4c45
movl 0x14(%rbx), %eax
cmpl $0x7, %eax
jne 0x4c0b
movl $0x40, %ecx
testb $0x10, 0x9(%rbx)
je 0x4c11
movl 0x8(%rbx), %ecx
andl %r15d, %ecx
orl %ecx, 0xc(%rbx)
cmpl $0x17, %eax
jne 0x4c45
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
movl %eax, %edx
movl $0xfffdffff, %edi       # imm = 0xFFFDFFFF
andl %edi, %edx
movl %ecx, %esi
shrl $0x11, %esi
andl $0x1, %esi
leal (%rsi,%rdx,2), %edx
andl %edi, %ecx
shrl $0x11, %eax
andl $0x1, %eax
leal (%rax,%rcx,2), %eax
xorl $0x1, %eax
movl %eax, 0x4(%rbx)
movl %edx, (%rbx)
movl 0x4(%rbx), %esi
movl 0x14(%rbx), %eax
movl %eax, %ecx
xorl $0x17, %ecx
movl %esi, %edx
andl $0x1, %edx
orl %ecx, %edx
jne 0x4c6e
movl (%rbx), %ecx
leal 0x1(%rcx), %edx
cmpl $0x3ffff, %ecx          # imm = 0x3FFFF
movl $0x1, %ecx
cmovel %ecx, %edx
movl %edx, (%rbx)
movl $0x0, 0x8(%rbx)
cmpl $0x4, %eax
jne 0x4e70
movl $0x0, 0x403c(%rbx)
movl $0x4, 0x4080(%rbx)
jmp 0x497a
movl $0x1, 0x4044(%rbx)
movl %ecx, 0x18(%rbx,%rax,4)
movl 0x14(%rbx), %eax
cmpl $0x1e, %eax
ja 0x4ecd
btl %eax, %r12d
jae 0x4ecd
movl $0x0, 0x4034(%rbx)
cmpl $0x0, 0x4034(%rbx)
je 0x4cd5
movl $0x0, 0xc(%rbx)
cmpl $0x0, 0x4044(%rbx)
jne 0x4cf7
movl $0x0, 0x4040(%rbx)
cmpl $0x18, %eax
jb 0x4cf7
movl $0x0, 0x403c(%rbx)
movl $0x0, 0x4044(%rbx)
jmp 0x497a
cmpl $0x19, %eax
jne 0x4d17
movl 0x10(%rbx), %ecx
orl %ecx, (%rbx)
movl $0x0, 0x10(%rbx)
cmpl $0x1b, %eax
je 0x4e04
cmpl $0x1a, %eax
je 0x4d3a
cmpl $0x18, %eax
jne 0x4e12
movl $0x0, 0x10(%rbx)
jmp 0x4bd8
movl 0x8(%rbx), %ecx
xorl %edx, %edx
btl $0xa, %ecx
jae 0x4d4e
xorl %edx, %edx
testb $0x2, 0x6(%rbx)
sete %dl
btl $0x9, %ecx
jae 0x4d63
cmpl $0x0, 0x4050(%rbx)
movl $0x1, %esi
cmovel %esi, %edx
btl $0x8, %ecx
jae 0x4d75
testb $0x2, 0x2(%rbx)
movl $0x1, %esi
cmovnel %esi, %edx
testb %cl, %cl
jns 0x4d85
testb $0x2, 0x2(%rbx)
movl $0x1, %esi
cmovel %esi, %edx
testb $0x40, %cl
je 0x4d95
cmpl $0x0, (%rbx)
movl $0x1, %esi
cmovel %esi, %edx
testb $0x38, %cl
je 0x4dbc
movl %ecx, %esi
shrl %esi
andl $0x1c, %esi
leaq 0x173c(%rip), %rdi      # 0x64e4
movl (%rsi,%rdi), %edi
movl $0x1, %esi
testl %edi, 0x4070(%rbx)
je 0x4dba
movl %edx, %esi
movl %esi, %edx
movslq %ecx, %rsi
andq $0x7, %rsi
je 0x4dde
leaq 0x161c(%rip), %rdi      # 0x63e8
movl -0x4(%rdi,%rsi,4), %esi
testl %esi, 0x4074(%rbx)
movl $0x1, %esi
cmovel %esi, %edx
xorl %esi, %esi
testl %edx, %edx
sete %sil
btl $0xc, %ecx
cmovael %edx, %esi
testl %esi, %esi
je 0x4dff
movl 0x10(%rbx), %ecx
incl %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, 0x10(%rbx)
cmpl $0x1b, %eax
jne 0x4e12
testb $0x2, 0x8(%rbx)
je 0x4e12
movq %rbx, %rdi
callq 0x55a9
movl 0x14(%rbx), %eax
cmpl $0x1f, %eax
je 0x4e30
cmpl $0x1c, %eax
jne 0x4f17
movl 0x8(%rbx), %ecx
andl %r15d, %ecx
orl %ecx, (%rbx)
jmp 0x4f17
movl 0x8(%rbx), %ecx
btl $0xa, %ecx
jae 0x4e41
movl 0x401c(%rbx), %edx
orl %edx, (%rbx)
testb $0x40, %cl
je 0x4e4b
movl 0x10(%rbx), %edx
orl %edx, (%rbx)
movl %ecx, %edx
andl $0x7, %edx
testb $0x8, %cl
jne 0x4f07
movl %edx, %ecx
leaq 0x16a2(%rip), %rdx      # 0x6504
movl (%rdx,%rcx,4), %ecx
andl %ecx, 0x4074(%rbx)
jmp 0x4f17
movl 0xc(%rbx), %ecx
movl 0x18(%rbx,%rcx,4), %edx
movl %edx, 0x8(%rbx)
movl $0x0, 0x18(%rbx,%rcx,4)
cmpl $0x11, %eax
je 0x4e92
cmpl $0x17, %eax
jne 0x4e98
testb $0x1, %sil
je 0x4e98
xorl $0x3ffff, (%rbx)        # imm = 0x3FFFF
cmpl $0x9, %eax
jne 0x4ea4
movl $0x0, 0x4(%rbx)
cmpl $0x11, %eax
jg 0x5096
cmpl $0x1, %eax
je 0x50da
cmpl $0x2, %eax
je 0x50de
cmpl $0x8, %eax
je 0x50e0
jmp 0x50e2
cmpl $0x0, 0x4078(%rbx)
jne 0x4cbb
cmpl $0x0, 0x407c(%rbx)
je 0x4ef5
cmpl $0x18, %eax
jb 0x4ef5
cmpl $0x0, 0x4044(%rbx)
je 0x4cbb
cmpl $0x0, 0x4038(%rbx)
jne 0x4cc5
jmp 0x4cbb
leaq 0x15d6(%rip), %rcx      # 0x64e4
movl (%rcx,%rdx,4), %ecx
orl %ecx, 0x4074(%rbx)
movl 0x8(%rbx), %ecx
movl 0xc(%rbx), %edx
movl %ecx, 0x18(%rbx,%rdx,4)
movl %eax, %edx
andl $-0x2, %edx
cmpl $0x18, %edx
jne 0x4f3f
cmpl $0x0, 0x4040(%rbx)
jne 0x4f3f
movl %ecx, %edx
andl $0xfff, %edx            # imm = 0xFFF
orl %edx, 0x10(%rbx)
cmpl $0x1a, %eax
setne %dl
btl $0x9, %ecx
setae %sil
orb %dl, %sil
jne 0x4f5c
movl $0x0, 0x4050(%rbx)
cmpl $0x1b, %eax
setne %al
testb $0x4, %cl
sete %cl
orb %al, %cl
jne 0x4f74
movq %rbx, %rdi
callq 0x55a9
movl 0x14(%rbx), %eax
cmpl $0x1f, %eax
jne 0x4f82
testb $0x2, 0x9(%rbx)
jne 0x4f92
cmpl $0x1d, %eax
je 0x4f9d
cmpl $0x1c, %eax
jne 0x4fb9
testb $0x10, 0x9(%rbx)
je 0x4f98
xorl $0x3ffff, (%rbx)        # imm = 0x3FFFF
cmpl $0x1d, %eax
jne 0x4fb9
cmpl $0x0, 0x4064(%rbx)
jne 0x4fb9
cmpl $0x0, 0x4068(%rbx)
je 0x4fb9
movl $0x0, 0x406c(%rbx)
cmpl $0x1f, %eax
jne 0x4fc4
testb $0x1, 0x9(%rbx)
jne 0x4fd7
cmpl $0x1e, %eax
ja 0x50a0
btl %eax, %r12d
jae 0x50a0
movl $0x0, 0x4034(%rbx)
cmpl $0x1b, %eax
jne 0x4ff4
testb $0x8, 0x8(%rbx)
je 0x4ff4
movq %rbx, %rdi
callq 0x55a9
movl 0x14(%rbx), %eax
cmpl $0x1d, %eax
jne 0x501e
cmpl $0x0, 0x406c(%rbx)
je 0x501e
movl 0x10(%rbx), %ecx
decl %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, 0x10(%rbx)
movq $0x0, 0x4040(%rbx)
cmpl $0x0, 0x4034(%rbx)
je 0x502e
movl $0x0, 0xc(%rbx)
cmpl $0x18, %eax
jb 0x503c
cmpl $0x0, 0x4040(%rbx)
je 0x5046
movl $0x1, 0x403c(%rbx)
cmpl $0x1b, %eax
jne 0x5059
testb $0x10, 0x8(%rbx)
je 0x5059
movq %rbx, %rdi
callq 0x55a9
cmpl $0x1d, 0x14(%rbx)
jne 0x5087
cmpl $0x0, 0x4064(%rbx)
je 0x5074
movl $0x1, 0x406c(%rbx)
jmp 0x5087
cmpl $0x0, 0x406c(%rbx)
jne 0x5087
movl $0x0, 0x4068(%rbx)
movl $0x0, 0x4080(%rbx)
jmp 0x497a
leal -0x12(%rax), %esi
cmpl $0x2, %esi
jb 0x50e0
jmp 0x50e2
cmpl $0x0, 0x4078(%rbx)
jne 0x4fd7
cmpl $0x0, 0x407c(%rbx)
je 0x50c8
cmpl $0x18, %eax
jb 0x50c8
cmpl $0x0, 0x4040(%rbx)
je 0x4fd7
cmpl $0x0, 0x4038(%rbx)
jne 0x4fe1
jmp 0x4fd7
andl (%rbx), %edx
jmp 0x50e0
orl (%rbx), %edx
movl %edx, (%rbx)
leal -0xd(%rax), %edx
cmpl $0x1, %edx
ja 0x50f1
movl $0x0, 0x8(%rbx)
cmpl $0x9, %eax
jne 0x50fc
movl 0x8(%rbx), %edx
orl %edx, 0x4(%rbx)
movl %eax, %edx
andl $-0x2, %edx
cmpl $0x10, %edx
jne 0x511b
movl 0x8(%rbx), %esi
xorl (%rbx), %esi
btl $0x11, %esi
jb 0x511b
movl $0x1, 0x4054(%rbx)
cmpl $0x17, %eax
ja 0x5165
movl $0xb30008, %esi         # imm = 0xB30008
btl %eax, %esi
jae 0x5183
movl 0x8(%rbx), %esi
xorl %esi, (%rbx)
leal -0x10(%rax), %esi
cmpl $0x2, %esi
jb 0x5147
cmpl $0x17, %eax
je 0x5147
cmpl $0x16, %eax
jne 0x5165
testb $0x1, 0x4(%rbx)
je 0x5165
movl (%rbx), %esi
movl %esi, %edi
notl %edi
andl 0x8(%rbx), %edi
leal (%rsi,%rdi,2), %r8d
addl %edi, %edi
btl $0x12, %r8d
adcl %esi, %edi
andl $0x3ffff, %edi          # imm = 0x3FFFF
movl %edi, (%rbx)
cmpl $0x12, %edx
jne 0x5198
movl (%rbx), %esi
cmpl $0x3fffe, %esi          # imm = 0x3FFFE
je 0x5190
cmpl $0x3ffff, %esi          # imm = 0x3FFFF
jne 0x5194
movl $0x1, %esi
jmp 0x5196
cmpl $0x16, %eax
jne 0x5165
testb $0x1, 0x4(%rbx)
jne 0x512a
jmp 0x512f
xorl %esi, %esi
jmp 0x5196
incl %esi
movl %esi, (%rbx)
cmpl $0x13, %eax
ja 0x51ac
movl $0xc0400, %esi          # imm = 0xC0400
btl %eax, %esi
jae 0x51ac
movl (%rbx), %esi
movl %esi, 0x8(%rbx)
cmpl $0x7, %eax
jne 0x51bc
movl (%rbx), %esi
movl %esi, 0x8(%rbx)
movl $0x0, (%rbx)
cmpl $0xc, %eax
jg 0x51de
cmpl $0xb, %eax
je 0x5205
cmpl $0xc, %eax
jne 0x5221
movl 0x8(%rbx), %esi
andl %r15d, %esi
movl (%rbx), %edi
movl $0x3f000, %r8d          # imm = 0x3F000
andl %r8d, %edi
jmp 0x5214
cmpl $0xd, %eax
je 0x521b
cmpl $0x16, %eax
jne 0x5221
movl (%rbx), %esi
movl 0x4(%rbx), %edi
movl %esi, %r8d
shrl %r8d
andl $0x1, %esi
shll $0x11, %esi
shrl %edi
orl %esi, %edi
movl %edi, 0x4(%rbx)
movl %r8d, (%rbx)
jmp 0x5221
movl 0x8(%rbx), %esi
movl $0x3f000, %edi          # imm = 0x3F000
andl %edi, %esi
movl (%rbx), %edi
andl %r15d, %edi
orl %esi, %edi
movl %edi, 0x8(%rbx)
jmp 0x5221
movl 0x4(%rbx), %esi
movl %esi, 0x8(%rbx)
cmpl $0x7, %eax
jne 0x5232
movl 0x10(%rbx), %esi
orl %esi, (%rbx)
movl $0x0, 0x10(%rbx)
cmpl $0x13, %eax
je 0x525a
cmpl $0x14, %eax
je 0x5250
cmpl $0x15, %eax
jne 0x526e
cmpl $0x0, (%rbx)
je 0x5260
cmpl $0x13, %eax
je 0x525a
cmpl $0x14, %eax
jne 0x526e
cmpl $0x0, (%rbx)
jne 0x5260
cmpl $0x13, %eax
jne 0x526e
testb $0x2, 0x2(%rbx)
jne 0x526e
movl 0x10(%rbx), %esi
incl %esi
andl $0xfff, %esi            # imm = 0xFFF
movl %esi, 0x10(%rbx)
movl 0x8(%rbx), %esi
movl %esi, 0x18(%rbx,%rcx,4)
cmpl $0x7, %eax
jne 0x527d
orl %ecx, 0x10(%rbx)
cmpl $0x11, %eax
jne 0x5288
xorl $0x3ffff, (%rbx)        # imm = 0x3FFFF
cmpl $0x14, %edx
jne 0x528f
xorl %esi, (%rbx)
cmpl $0x10, %edx
jne 0x52a6
xorl (%rbx), %esi
btl $0x11, %esi
jb 0x52a6
movl $0x0, 0x4054(%rbx)
cmpl $0x1e, %eax
ja 0x531f
btl %eax, %r12d
jae 0x531f
movl $0x0, 0x4034(%rbx)
cmpl $0x17, %eax
je 0x52c5
cmpl $0x10, %eax
jne 0x52d3
cmpl $0x3ffff, (%rbx)        # imm = 0x3FFFF
jne 0x52d3
movl $0x0, (%rbx)
cmpl $0x7, %eax
jne 0x52e5
movl 0x10(%rbx), %eax
incl %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %eax, 0x10(%rbx)
cmpl $0x0, 0x4054(%rbx)
je 0x52f8
movl $0x1, 0x4050(%rbx)
movl %r13d, 0x4054(%rbx)
movl %r13d, 0x403c(%rbx)
cmpl %r13d, 0x4034(%rbx)
je 0x497a
movl $0x0, 0xc(%rbx)
jmp 0x497a
cmpl $0x0, 0x4078(%rbx)
jne 0x52b1
cmpl $0x0, 0x407c(%rbx)
jne 0x52b1
cmpl $0x0, 0x4038(%rbx)
jne 0x52bb
jmp 0x52b1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq