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

		// a cycle takes around 6μs
		cycle(tx);
		handleio(tx);
	}
	return nil;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x28(%rbp), %r14
movl $0xffff, %r15d          # imm = 0xFFFF
movl $0x3ffff, %r12d         # imm = 0x3FFFF
movq 0x49124(%rip), %rdi     # 0x4d678
movq %r14, %rsi
callq 0x40eb
cmpl $0x1, %eax
je 0x456b
cmpl $-0x1, %eax
jne 0x4577
jmp 0x47df
movq -0x28(%rbp), %rsi
movq %rbx, %rdi
callq 0x44d0
cmpl $0x0, (%rbx)
je 0x45bd
movl $0x0, 0x18(%rbx)
cmpl $0x0, 0xc(%rbx)
je 0x45d7
movl 0x28(%rbx), %eax
cmpl $0x3, %eax
je 0x46af
cmpl $0x1, %eax
je 0x4683
testl %eax, %eax
jne 0x47ad
movl 0x10(%rbx), %eax
movl 0x1c(%rbx), %ecx
movl %eax, 0x18(%rbx)
andl $0x3ffff, %eax          # imm = 0x3FFFF
movl %eax, 0x2c(%rbx,%rcx,4)
jmp 0x47ad
cmpl $0x0, 0x4(%rbx)
movl 0x8(%rbx), %eax
jne 0x47d0
testl %eax, %eax
jne 0x47d2
jmp 0x47ce
movl 0x1c(%rbx), %edx
movl %edx, 0x24(%rbx)
movl 0x2c(%rbx,%rdx,4), %eax
movl %eax, %ecx
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %ecx, 0x18(%rbx)
shrl $0x10, %ecx
movl %ecx, 0x28(%rbx)
incl %edx
andl %r15d, %edx
movl %edx, 0x20(%rbx)
movl %eax, %edx
andl %r15d, %edx
movl %edx, 0x1c(%rbx)
cmpl $0x2, %ecx
jae 0x462a
movl $0x1, 0xc(%rbx)
cmpl $0x0, 0x40034(%rbx)
jne 0x47c7
cmpl $0x0, 0x8(%rbx)
jne 0x47d2
jmp 0x47ce
cmpl $0x3, %ecx
jne 0x473d
testw %ax, %ax
jns 0x463f
andl $0x1ff, 0x10(%rbx)      # imm = 0x1FF
btl $0xe, %eax
jae 0x464c
andl $0x3fe00, 0x10(%rbx)    # imm = 0x3FE00
movl %eax, %ecx
andl $0x3000, %ecx           # imm = 0x3000
cmpl $0x2000, %ecx           # imm = 0x2000
jne 0x4663
movq $0x0, (%rbx)
shrl $0x9, %eax
andl $0x7, %eax
cmpl $0x4, %eax
je 0x4753
cmpl $0x2, %eax
jne 0x4607
movl $0x1, 0x4004c(%rbx)
jmp 0x4607
movl 0x10(%rbx), %eax
movl 0x1c(%rbx), %ecx
movl 0x2c(%rbx,%rcx,4), %ecx
andl %r12d, %ecx
movl %ecx, 0x18(%rbx)
movl %eax, %edx
xorl %ecx, %edx
andl %eax, %ecx
leal (%rdx,%rcx,2), %eax
addl %ecx, %ecx
btl $0x12, %eax
adcl %edx, %ecx
andl %r12d, %ecx
movl %ecx, 0x10(%rbx)
jmp 0x47ad
movl 0x1c(%rbx), %eax
movl %eax, %ecx
andl $0x44, %ecx
cmpl $0x4, %ecx
jne 0x46c5
movl 0x40030(%rbx), %ecx
orl %ecx, 0x10(%rbx)
xorl %edx, %edx
testb $0x1, %al
je 0x46e1
leaq 0x4002c(%rbx), %rcx
leaq 0x10(%rbx), %rdx
testb $0x2, %al
cmoveq %rdx, %rcx
movl (%rcx), %edx
movl %edx, 0x18(%rbx)
testb $0x20, %al
je 0x46f3
movl 0x10(%rbx), %ecx
notl %ecx
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %ecx, 0x10(%rbx)
movl %eax, %esi
andl $0x3, %esi
movl %edx, %ecx
cmpl $0x2, %esi
jne 0x4705
movl 0x14(%rbx), %ecx
movl %ecx, 0x18(%rbx)
movl %eax, %esi
andl $0x180, %esi            # imm = 0x180
cmpl $0x80, %esi
jne 0x4718
movl %edx, 0x14(%rbx)
testb $0x10, %al
jne 0x474c
cmpl $0x180, %esi            # imm = 0x180
je 0x4762
cmpl $0x100, %esi            # imm = 0x100
jne 0x4777
movl 0x10(%rbx), %edx
movl %edx, %esi
shrl %esi
andl $0x20000, %edx          # imm = 0x20000
orl %esi, %edx
jmp 0x4774
testb $0x2, 0x12(%rbx)
je 0x4607
jmp 0x460e
movl 0x10(%rbx), %edx
xorl %ecx, %edx
jmp 0x4774
movl $0x1, 0x40048(%rbx)
jmp 0x4607
movl 0x10(%rbx), %edx
movl %edx, %esi
shrl %esi
shll $0x11, %edx
orl %esi, %edx
andl $0x3ffff, %edx          # imm = 0x3FFFF
movl %edx, 0x10(%rbx)
movl %eax, %edx
notl %edx
testl $0x3000, %edx           # imm = 0x3000
jne 0x478a
movl $0x0, 0x8(%rbx)
testb $0x8, %al
je 0x47ad
movl 0x10(%rbx), %eax
movl %eax, %edx
notl %edx
andl %edx, %ecx
movl %ecx, %edx
addl %ecx, %edx
leal (%rax,%rcx,2), %ecx
btl $0x12, %ecx
adcl %eax, %edx
andl $0x3ffff, %edx          # imm = 0x3FFFF
movl %edx, 0x10(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
movl $0x0, 0xc(%rbx)
cmpl $0x0, 0x40038(%rbx)
je 0x461b
movl $0x0, 0x8(%rbx)
xorl %eax, %eax
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x43b3
jmp 0x454d
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq