// File: /workspace/github_c_makefile_star2_O1/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 0x490be(%rip), %rdi     # 0x4d678
movq %r14, %rsi
callq 0x413f
cmpl $0x1, %eax
je 0x45d1
cmpl $-0x1, %eax
jne 0x45dd
jmp 0x4831
movq -0x28(%rbp), %rsi
movq %rbx, %rdi
callq 0x4536
cmpl $0x0, (%rbx)
je 0x4623
movl $0x0, 0x18(%rbx)
cmpl $0x0, 0xc(%rbx)
je 0x4635
movl 0x28(%rbx), %eax
cmpl $0x3, %eax
je 0x4700
cmpl $0x1, %eax
je 0x46d7
testl %eax, %eax
jne 0x47fd
movl 0x10(%rbx), %eax
movl 0x1c(%rbx), %ecx
movl %eax, 0x18(%rbx)
andl $0x3ffff, %eax          # imm = 0x3FFFF
movl %eax, 0x2c(%rbx,%rcx,4)
jmp 0x47fd
cmpl $0x0, 0x4(%rbx)
je 0x481a
movl 0x8(%rbx), %eax
jmp 0x4822
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 0x467e
movl $0x1, 0xc(%rbx)
cmpl $0x0, 0x40034(%rbx)
jne 0x4813
jmp 0x481a
cmpl $0x3, %ecx
jne 0x478d
testw %ax, %ax
jns 0x4693
andl $0x1ff, 0x10(%rbx)      # imm = 0x1FF
btl $0xe, %eax
jae 0x46a0
andl $0x3fe00, 0x10(%rbx)    # imm = 0x3FE00
movl %eax, %ecx
andl $0x3000, %ecx           # imm = 0x3000
cmpl $0x2000, %ecx           # imm = 0x2000
jne 0x46b7
movq $0x0, (%rbx)
shrl $0x9, %eax
andl $0x7, %eax
cmpl $0x4, %eax
je 0x47a4
cmpl $0x2, %eax
jne 0x4665
movl $0x1, 0x4004c(%rbx)
jmp 0x4665
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
jmp 0x47fa
movl 0x1c(%rbx), %eax
movl %eax, %ecx
andl $0x44, %ecx
cmpl $0x4, %ecx
jne 0x4716
movl 0x40030(%rbx), %ecx
orl %ecx, 0x10(%rbx)
testb $0x1, %al
je 0x4730
leaq 0x4002c(%rbx), %rcx
leaq 0x10(%rbx), %rdx
testb $0x2, %al
cmoveq %rdx, %rcx
movl (%rcx), %ecx
movl %ecx, 0x18(%rbx)
testb $0x20, %al
je 0x4742
movl 0x10(%rbx), %ecx
notl %ecx
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %ecx, 0x10(%rbx)
movl 0x18(%rbx), %edx
movl %eax, %ecx
andl $0x3, %ecx
cmpl $0x2, %ecx
jne 0x4755
movl 0x14(%rbx), %ecx
movl %ecx, 0x18(%rbx)
movl %eax, %ecx
andl $0x180, %ecx            # imm = 0x180
cmpl $0x80, %ecx
jne 0x4768
movl %edx, 0x14(%rbx)
testb $0x10, %al
jne 0x479c
cmpl $0x180, %ecx            # imm = 0x180
je 0x47b3
cmpl $0x100, %ecx            # imm = 0x100
jne 0x47c8
movl 0x10(%rbx), %ecx
movl %ecx, %edx
shrl %edx
andl $0x20000, %ecx          # imm = 0x20000
orl %edx, %ecx
jmp 0x47c5
testb $0x2, 0x12(%rbx)
je 0x4665
jmp 0x466c
movl 0x18(%rbx), %ecx
xorl %ecx, 0x10(%rbx)
jmp 0x47c8
movl $0x1, 0x40048(%rbx)
jmp 0x4665
movl 0x10(%rbx), %ecx
movl %ecx, %edx
shrl %edx
shll $0x11, %ecx
orl %edx, %ecx
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %ecx, 0x10(%rbx)
movl %eax, %ecx
notl %ecx
testl $0x3000, %ecx           # imm = 0x3000
jne 0x47db
movl $0x0, 0x8(%rbx)
testb $0x8, %al
je 0x47fd
movl 0x10(%rbx), %eax
movl %eax, %ecx
notl %ecx
andl 0x18(%rbx), %ecx
leal (%rax,%rcx,2), %edx
addl %ecx, %ecx
btl $0x12, %edx
adcl %eax, %ecx
andl $0x3ffff, %ecx          # imm = 0x3FFFF
movl %ecx, 0x10(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
movl $0x0, 0xc(%rbx)
cmpl $0x0, 0x40038(%rbx)
je 0x481a
movl $0x0, 0x8(%rbx)
cmpl $0x0, 0x8(%rbx)
jne 0x4824
xorl %eax, %eax
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x440a
jmp 0x45b3
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq