// File: /workspace/github_c_makefile_star2_O2/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 0x49572(%rip), %rdi     # 0x4d678
movq %r14, %rsi
callq 0x3ce7
cmpl $0x1, %eax
je 0x411d
cmpl $-0x1, %eax
jne 0x4129
jmp 0x4381
movq -0x28(%rbp), %rsi
movq %rbx, %rdi
callq 0x4088
cmpl $0x0, (%rbx)
je 0x416c
andl $0x0, 0x18(%rbx)
cmpl $0x0, 0xc(%rbx)
je 0x4186
movl 0x28(%rbx), %eax
cmpl $0x3, %eax
je 0x425b
cmpl $0x1, %eax
je 0x422f
testl %eax, %eax
jne 0x4355
movl 0x10(%rbx), %eax
movl 0x1c(%rbx), %ecx
movl %eax, 0x18(%rbx)
andl $0x3ffff, %eax          # imm = 0x3FFFF
movl %eax, 0x2c(%rbx,%rcx,4)
jmp 0x4355
cmpl $0x0, 0x4(%rbx)
movl 0x8(%rbx), %eax
jne 0x4372
testl %eax, %eax
jne 0x4374
jmp 0x4370
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 0x41d9
movl $0x1, 0xc(%rbx)
cmpl $0x0, 0x40034(%rbx)
jne 0x436c
cmpl $0x0, 0x8(%rbx)
jne 0x4374
jmp 0x4370
cmpl $0x3, %ecx
jne 0x42e9
testw %ax, %ax
jns 0x41ee
andl $0x1ff, 0x10(%rbx)      # imm = 0x1FF
btl $0xe, %eax
jae 0x41fb
andl $0x3fe00, 0x10(%rbx)    # imm = 0x3FE00
movl %eax, %ecx
andl $0x3000, %ecx           # imm = 0x3000
cmpl $0x2000, %ecx           # imm = 0x2000
jne 0x420f
andq $0x0, (%rbx)
shrl $0x9, %eax
andl $0x7, %eax
cmpl $0x4, %eax
je 0x42ff
cmpl $0x2, %eax
jne 0x41b6
movl $0x1, 0x4004c(%rbx)
jmp 0x41b6
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 0x4355
movl 0x1c(%rbx), %eax
movl %eax, %ecx
andl $0x44, %ecx
cmpl $0x4, %ecx
jne 0x4271
movl 0x40030(%rbx), %ecx
orl %ecx, 0x10(%rbx)
xorl %edx, %edx
testb $0x1, %al
je 0x428d
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 0x429f
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 0x42b1
movl 0x14(%rbx), %ecx
movl %ecx, 0x18(%rbx)
movl %eax, %esi
andl $0x180, %esi            # imm = 0x180
cmpl $0x80, %esi
jne 0x42c4
movl %edx, 0x14(%rbx)
testb $0x10, %al
jne 0x42f8
cmpl $0x180, %esi            # imm = 0x180
je 0x430e
cmpl $0x100, %esi            # imm = 0x100
jne 0x4323
movl 0x10(%rbx), %edx
movl %edx, %esi
shrl %esi
andl $0x20000, %edx          # imm = 0x20000
orl %esi, %edx
jmp 0x4320
testb $0x2, 0x12(%rbx)
je 0x41b6
jmp 0x41bd
movl 0x10(%rbx), %edx
xorl %ecx, %edx
jmp 0x4320
movl $0x1, 0x40048(%rbx)
jmp 0x41b6
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
testw $0x3000, %dx            # imm = 0x3000
jne 0x4332
andl $0x0, 0x8(%rbx)
testb $0x8, %al
je 0x4355
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)
andl $0x0, 0xc(%rbx)
cmpl $0x0, 0x40038(%rbx)
je 0x41ca
andl $0x0, 0x8(%rbx)
xorl %eax, %eax
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x3f81
jmp 0x40ff
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq