// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/driver.cc
// Function: line_demo(int, int, int, int)
void line_demo(int spi_fd, int x, int y, int z)
{
	uint16_t command_buf[10] = {0};
	int x_direct = 0;
	int y_direct = 0;
	int z_direct = 0;

	if(x>=0)
	{
		x_direct = 0;
	}
	else
	{
		x_direct = 1;
	}
	if(y>=0)
	{
		y_direct = 0;
	}
	else
	{
		y_direct = 1;
	}
	if(z>=0)
	{
		z_direct = 0;
	}
	else
	{
		z_direct = 1;
	}
	x = abs(x);
	y = abs(y);
	z = abs(z);
	command_buf[0] = 100*50;//50~1us
	command_buf[1] = (bit(15)*x_direct)|(x>>16);
	command_buf[2] = x&0x0ffff;
	command_buf[3] = (bit(15)*y_direct)|(y>>16);
	command_buf[4] = y&0x0ffff;
	command_buf[5] = (bit(15)*z_direct)|(z>>16);
	command_buf[6] = z&0x0ffff;
	command_buf[7] = 1;
	spi_write_single(spi_fd, 0x1a, 0xabcd);//reset
	spi_write_single(spi_fd, 0x10e, command_buf[0]);
	spi_write_multi(spi_fd, 0x100, &command_buf[1], 7);
	//usleep(100000);
	//spi_read_single(spi_fd, 0x22);
	//spi_read_single(spi_fd, 0x24);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %edi, %ebx
andl $0x0, -0x30(%rbp)
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
movl %edx, %r8d
negl %r8d
cmovsl %edx, %r8d
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movl $0x80000000, %r9d       # imm = 0x80000000
andl %r9d, %esi
orl %edi, %esi
shrl $0x10, %esi
movw %si, -0x3e(%rbp)
movw %di, -0x3c(%rbp)
andl %r9d, %edx
orl %r8d, %edx
shrl $0x10, %edx
movw %dx, -0x3a(%rbp)
movw %r8w, -0x38(%rbp)
andl %r9d, %ecx
orl %eax, %ecx
shrl $0x10, %ecx
movw %cx, -0x36(%rbp)
movw %ax, -0x34(%rbp)
movw $0x1, -0x32(%rbp)
pushq $0x1a
popq %rsi
movl %ebx, %edi
movl $0xabcd, %edx           # imm = 0xABCD
callq 0x47a0
movl %ebx, %edi
movl $0x10e, %esi            # imm = 0x10E
movl $0x1388, %edx           # imm = 0x1388
callq 0x47a0
movl $0x1c0, %edi            # imm = 0x1C0
callq 0x4220
testq %rax, %rax
je 0x4744
movq %rax, %r15
pushq $0x1c
popq %rdi
callq 0x4220
testq %rax, %rax
je 0x4770
movq %rax, %r14
pushq $0x1c
popq %rdi
callq 0x4220
testq %rax, %rax
je 0x4775
movq %rax, %r12
movq %r15, %rax
addq $0x3b, %rax
pushq $0x2
popq %rcx
xorl %edx, %edx
movabsq $0xf424000000002, %rsi  # imm = 0xF424000000002
cmpq $0x1c, %rdx
je 0x4751
leal -0x7f02(%rcx), %edi
rolw $0x8, %di
leaq (%r14,%rdx), %r8
movw %di, (%r14,%rdx)
leaq (%r12,%rdx), %rdi
andw $0x0, (%r12,%rdx)
movq %r8, -0x3b(%rax)
movq %rdi, -0x33(%rax)
movq %rsi, -0x2b(%rax)
movl $0x80000, -0x23(%rax)   # imm = 0x80000
movzwl -0x40(%rbp,%rcx), %edi
rolw $0x8, %di
leaq (%r14,%rdx), %r8
addq $0x2, %r8
andw $0x0, 0x2(%r12,%rdx)
movq %r8, -0x1b(%rax)
andq $0x0, -0x13(%rax)
movq %rsi, -0xb(%rax)
andw $0x0, -0x3(%rax)
movb $0x8, -0x1(%rax)
cmpq $0x18, %rdx
setne (%rax)
movw %di, 0x2(%r14,%rdx)
addq $0x4, %rdx
addq $0x2, %rcx
addq $0x40, %rax
jmp 0x46be
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x41c06b00, %esi       # imm = 0x41C06B00
movl %ebx, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4230
testl %eax, %eax
jle 0x4794
movq %r15, %rdi
callq 0x41d0
jmp 0x4778
movq %r15, %r14
jmp 0x4780
movq %r15, %r12
movq %r12, %rdi
callq 0x41d0
movq %r14, %rdi
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x41d0
leaq 0x48db(%rip), %rdi      # 0x9076
callq 0x48b7