// File: /workspace/github_cpp_makefile_star2_O1/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
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movl %esi, %r8d
negl %r8d
cmovsl %esi, %r8d
movl %edx, %edi
negl %edi
cmovsl %edx, %edi
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movw $0x1388, -0x40(%rbp)    # imm = 0x1388
movl $0x80000000, %r9d       # imm = 0x80000000
andl %r9d, %esi
orl %r8d, %esi
shrl $0x10, %esi
movw %si, -0x3e(%rbp)
movw %r8w, -0x3c(%rbp)
andl %r9d, %edx
orl %edi, %edx
shrl $0x10, %edx
movw %dx, -0x3a(%rbp)
movw %di, -0x38(%rbp)
andl %r9d, %ecx
orl %eax, %ecx
shrl $0x10, %ecx
movw %cx, -0x36(%rbp)
movw %ax, -0x34(%rbp)
movw $0x1, -0x32(%rbp)
movl %ebx, %edi
movl $0x1a, %esi
movl $0xabcd, %edx           # imm = 0xABCD
callq 0x48b0
movl %ebx, %edi
movl $0x10e, %esi            # imm = 0x10E
movl $0x1388, %edx           # imm = 0x1388
callq 0x48b0
movl $0x1c0, %edi            # imm = 0x1C0
callq 0x4220
testq %rax, %rax
je 0x487a
movq %rax, %r15
movl $0x1c, %edi
callq 0x4220
testq %rax, %rax
je 0x4887
movq %rax, %r14
movl $0x1c, %edi
callq 0x4220
testq %rax, %rax
je 0x488c
movq %rax, %r12
movq %r15, %rax
addq $0x3b, %rax
movl $0x2, %ecx
xorl %edx, %edx
movabsq $0xf424000000002, %rsi  # imm = 0xF424000000002
xorl %edi, %edi
leal 0xfe(%rcx), %r8d
orl $0x8000, %r8d           # imm = 0x8000
rolw $0x8, %r8w
leaq (%r14,%rdi), %r9
movw %r8w, (%r14,%rdi)
leaq (%r12,%rdi), %r8
movw %dx, (%r12,%rdi)
movq %r9, -0x3b(%rax)
movq %r8, -0x33(%rax)
movq %rsi, -0x2b(%rax)
movl $0x80000, -0x23(%rax)   # imm = 0x80000
movzwl -0x40(%rbp,%rcx), %r8d
rolw $0x8, %r8w
leaq (%r14,%rdi), %r9
addq $0x2, %r9
movw %r8w, 0x2(%r14,%rdi)
movw %dx, 0x2(%r12,%rdi)
movq %r9, -0x1b(%rax)
movq $0x0, -0x13(%rax)
movq %rsi, -0xb(%rax)
movw %dx, -0x3(%rax)
movb $0x8, -0x1(%rax)
cmpq $0x18, %rdi
setne (%rax)
addq $0x4, %rdi
addq $0x2, %rcx
addq $0x40, %rax
cmpq $0x1c, %rdi
jne 0x47cf
movl $0x41c06b00, %esi       # imm = 0x41C06B00
movl %ebx, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4230
testl %eax, %eax
jle 0x48ab
movq %r15, %rdi
callq 0x41d0
jmp 0x488f
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %r14
jmp 0x4897
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
callq 0x4476