// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r14d
movl %edi, %ebx
movl $0x0, -0x30(%rbp)
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movw $0x1388, -0x40(%rbp)    # imm = 0x1388
movl $0x80000000, %r8d       # imm = 0x80000000
andl %r8d, %r14d
orl %edi, %r14d
shrl $0x10, %r14d
movw %r14w, -0x3e(%rbp)
movw %di, -0x3c(%rbp)
andl %r8d, %edx
orl %esi, %edx
shrl $0x10, %edx
movw %dx, -0x3a(%rbp)
movw %si, -0x38(%rbp)
andl %r8d, %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 0x4897
movl %ebx, %edi
movl $0x10e, %esi            # imm = 0x10E
movl $0x1388, %edx           # imm = 0x1388
callq 0x4897
movl $0x1c0, %edi            # imm = 0x1C0
callq 0x4210
testq %rax, %rax
je 0x483b
movq %rax, %r12
movl $0x1c, %edi
callq 0x4210
testq %rax, %rax
je 0x486c
movq %rax, %r15
movl $0x1c, %edi
callq 0x4210
testq %rax, %rax
je 0x4871
movq %rax, %r13
movq %r12, %rax
addq $0x3b, %rax
movl $0x4, %ecx
xorl %edx, %edx
movabsq $0xf424000000002, %rsi  # imm = 0xF424000000002
xorl %edi, %edi
leal -0x7f04(%rcx), %r8d
rolw $0x8, %r8w
leaq (%r15,%rdi), %r9
movw %r8w, (%r15,%rdi)
leaq (%rdi,%r13), %r8
movw %dx, (%r13,%rdi)
movq %r9, -0x3b(%rax)
movq %r8, -0x33(%rax)
movq %rsi, -0x2b(%rax)
movl $0x80000, -0x23(%rax)   # imm = 0x80000
rolw $0x8, %r14w
leaq (%r15,%rdi), %r8
addq $0x2, %r8
movw %r14w, 0x2(%r15,%rdi)
movw %dx, 0x2(%r13,%rdi)
movq %r8, -0x1b(%rax)
movq $0x0, -0x13(%rax)
movq %rsi, -0xb(%rax)
movw %dx, -0x3(%rax)
movb $0x8, -0x1(%rax)
cmpq $0x18, %rdi
je 0x484a
movb $0x1, (%rax)
movzwl -0x40(%rbp,%rcx), %r14d
addq $0x2, %rcx
addq $0x4, %rdi
addq $0x40, %rax
jmp 0x47bb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, (%rax)
movl $0x41c06b00, %esi       # imm = 0x41C06B00
movl %ebx, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x4220
testl %eax, %eax
jle 0x4892
movq %r12, %rdi
callq 0x41c0
jmp 0x4874
movq %r12, %r15
jmp 0x487c
movq %r12, %r13
movq %r13, %rdi
callq 0x41c0
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41c0
callq 0x4466