// File: Neuromancer2701[P]OpenTool/src/OpenTool.cpp
// Function: OpenTool::OpenTool(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, int, MID_Revision)
OpenTool::OpenTool(int spindleNumber, string _ip, int _port, int _timeout, int _retries, MID_Revision _rev)
{
	ip_address = _ip;
	port = _port;
	timeout = static_cast<double>(_timeout);
	retries = _retries;
	openToolHeader.SpindleID = spindleNumber;
	openToolHeader.Revision = version = _rev;
	SetStationID();
	SetAckStatus();
	if(ip_address.length() > 0)
	{
		lastSentTime = std::chrono::system_clock::now(); //Client timeout functionality
		timer_count = -1;
	}
	else
	{
		keep_alive_timer.init(timeout, 0, false); //Server KeepAlive
		keep_alive_timer.start();
		timer_count = keep_alive_timer.GetCount();
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdx, -0x60(%rbp)
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movq 0xca41(%rip), %rax      # 0x17f18
addq $0x10, %rax
movq %rax, (%rdi)
addq $0x10, %rdi
movq %rdi, -0x58(%rbp)
callq 0xab90
movq -0x50(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x48(%rbp)
callq 0xa570
jmp 0xb4fe
movq -0x50(%rbp), %rdi
addq $0x378, %rdi            # imm = 0x378
movq %rdi, -0x98(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x398, %rdi            # imm = 0x398
movq %rdi, -0x90(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x3b8, %rdi            # imm = 0x3B8
movq %rdi, -0x88(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x3d8, %rdi            # imm = 0x3D8
movq %rdi, -0x80(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x3f8, %rdi            # imm = 0x3F8
movq %rdi, -0x78(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
movq %rdi, -0x70(%rbp)
callq 0xae80
movq -0x50(%rbp), %rdi
addq $0x438, %rdi            # imm = 0x438
movq %rdi, -0x68(%rbp)
callq 0xa700
jmp 0xb595
movq -0x50(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
movq %rdi, -0xa0(%rbp)
callq 0xa040
jmp 0xb5ae
movq -0x50(%rbp), %rdi
addq $0x898, %rdi            # imm = 0x898
callq 0xafe0
jmp 0xb5c0
movq -0x50(%rbp), %rdi
addq $0x8a8, %rdi            # imm = 0x8A8
movq %rdi, -0xa8(%rbp)
callq 0xa2d0
jmp 0xb5d9
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdi
addq $0x10, %rdi
callq 0xa050
jmp 0xb5ec
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, 0x30(%rdi)
cvtsi2sdl -0x20(%rbp), %xmm0
movsd %xmm0, 0x38(%rdi)
movl -0x24(%rbp), %eax
movl %eax, 0x40(%rdi)
movl -0xc(%rbp), %eax
movl %eax, 0x374(%rdi)
movl 0x10(%rbp), %eax
movl %eax, 0x34(%rdi)
movl %eax, 0x368(%rdi)
xorl %esi, %esi
callq 0xa370
jmp 0xb624
movq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0xa680
jmp 0xb634
movq -0x50(%rbp), %rdi
addq $0x10, %rdi
callq 0xac40
cmpq $0x0, %rax
jbe 0xb6d0
callq 0xa090
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, 0x898(%rax)
movl $0xffffffff, 0x8a0(%rax) # imm = 0xFFFFFFFF
jmp 0xb728
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xb78e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xb746
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xb73d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xb731
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xae50
jmp 0xb731
movq -0x50(%rbp), %rax
movq %rax, %rdi
addq $0x8a8, %rdi            # imm = 0x8A8
cvttsd2si 0x38(%rax), %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xa130
jmp 0xb6ee
movq -0x50(%rbp), %rdi
addq $0x8a8, %rdi            # imm = 0x8A8
callq 0xa4f0
jmp 0xb700
movq -0x50(%rbp), %rdi
addq $0x8a8, %rdi            # imm = 0x8A8
callq 0xa280
movl %eax, -0xac(%rbp)
jmp 0xb718
movq -0x50(%rbp), %rax
movl -0xac(%rbp), %ecx
movl %ecx, 0x8a0(%rax)
addq $0xb0, %rsp
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0xa080
movq -0x68(%rbp), %rdi
callq 0xa170
movq -0x70(%rbp), %rdi
callq 0xa420
movq -0x78(%rbp), %rdi
callq 0xa420
movq -0x80(%rbp), %rdi
callq 0xa420
movq -0x88(%rbp), %rdi
callq 0xa420
movq -0x90(%rbp), %rdi
callq 0xa420
movq -0x98(%rbp), %rdi
callq 0xa420
movq -0x48(%rbp), %rdi
callq 0xa7e0
movq -0x58(%rbp), %rdi
callq 0xa540
movq -0x30(%rbp), %rdi
callq 0xae90