// File: Neuromancer2701[P]OpenTool/src/OpenTool.cpp
// Function: OpenTool::MIDInputAction(Header*)
Error OpenTool::MIDInputAction(Header* message)
{
	 Error result = Error::UNKNOWN;

	 switch(message->Number)
	 {
		 case MID_Number::CommunicationStart:
			  try{
				  Mid_0001* mid0001 = dynamic_cast<Mid_0001*>(message);
				  mid0001->Unpack();
				  result = MID0001Received(mid0001);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;
		 case MID_Number::CommunicationStartAcknowledge:
			  try{
				  Mid_0002* mid0002 = dynamic_cast<Mid_0002*>(message);
				  mid0002->Unpack();
				  result = MID0002Received(mid0002);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;
		 case MID_Number::CommunicationStop:
			  try{
				  Mid_0003* mid0003 = dynamic_cast<Mid_0003*>(message);
				  mid0003->Unpack();
				  result = MID0003Received(mid0003);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;
		 case MID_Number::CommandError:
			  try{
				  Mid_0004* mid0004 = dynamic_cast<Mid_0004*>(message);
				  mid0004->Unpack();
				  result = MID0004Received(mid0004);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;
		 case MID_Number::CommandAccepted:
			  try{
				  Mid_0005* mid0005 = dynamic_cast<Mid_0005*>(message);
				  mid0005->Unpack();
				  result = MID0005Received(mid0005);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;
		 case MID_Number::KeepAliveMessage:
			  try{
				  Mid_9999* mid9999 = dynamic_cast<Mid_9999*>(message);
				  mid9999->Unpack();
				  result = MID9999Received(mid9999);
			  }
			  catch(exception& my_ex)
			  {
				  Log << "Exception: " << my_ex.what();
			  }
			  break;

		 default:
			  break;
	 }

	 if(result == Error::NONE)
		 lastSentTime = std::chrono::system_clock::now();

	 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x31c(%rax), %eax
movl %eax, -0x94(%rbp)
subl $0x1, %eax
je 0xc616
jmp 0xc5bc
movl -0x94(%rbp), %eax
subl $0x2, %eax
je 0xc726
jmp 0xc5cd
movl -0x94(%rbp), %eax
subl $0x3, %eax
je 0xc836
jmp 0xc5de
movl -0x94(%rbp), %eax
subl $0x4, %eax
je 0xc946
jmp 0xc5ef
movl -0x94(%rbp), %eax
subl $0x5, %eax
je 0xca56
jmp 0xc600
movl -0x94(%rbp), %eax
subl $0x270f, %eax           # imm = 0x270F
je 0xcb66
jmp 0xcc76
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0xc64e
movq -0xa8(%rbp), %rdi
movq 0xb9b3(%rip), %rsi      # 0x17fe8
movq 0xb96c(%rip), %rdx      # 0x17fa8
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0xb0(%rbp)
jmp 0xc659
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0xc659
movq -0xb0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xc673
movq -0xa0(%rbp), %rdi
addq $0x378, %rdi            # imm = 0x378
movq -0x20(%rbp), %rsi
callq 0xa600
movl %eax, -0xb4(%rbp)
jmp 0xc692
movl -0xb4(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xc709
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x38(%rbp)
movq 0xb853(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x6930(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0xc0(%rbp)
jmp 0xc6e6
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xc704
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xc721
jmp 0xccae
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0xc75e
movq -0xc8(%rbp), %rdi
movq 0xb8a3(%rip), %rsi      # 0x17fe8
movq 0xb8ac(%rip), %rdx      # 0x17ff8
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0xd0(%rbp)
jmp 0xc769
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
jmp 0xc769
movq -0xd0(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xc783
movq -0xa0(%rbp), %rdi
addq $0x398, %rdi            # imm = 0x398
movq -0x40(%rbp), %rsi
callq 0xa600
movl %eax, -0xd4(%rbp)
jmp 0xc7a2
movl -0xd4(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xc819
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x48(%rbp)
movq 0xb743(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x6820(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0xe0(%rbp)
jmp 0xc7f6
movq -0x48(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xc814
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xc831
jmp 0xccae
movq -0x10(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0xc86e
movq -0xe8(%rbp), %rdi
movq 0xb793(%rip), %rsi      # 0x17fe8
movq 0xb6cc(%rip), %rdx      # 0x17f28
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0xf0(%rbp)
jmp 0xc879
xorl %eax, %eax
movq %rax, -0xf0(%rbp)
jmp 0xc879
movq -0xf0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xc893
movq -0xa0(%rbp), %rdi
addq $0x3b8, %rdi            # imm = 0x3B8
movq -0x50(%rbp), %rsi
callq 0xa600
movl %eax, -0xf4(%rbp)
jmp 0xc8b2
movl -0xf4(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xc929
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x58(%rbp)
movq 0xb633(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x6710(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0x100(%rbp)
jmp 0xc906
movq -0x58(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xc924
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xc941
jmp 0xccae
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
je 0xc97e
movq -0x108(%rbp), %rdi
movq 0xb683(%rip), %rsi      # 0x17fe8
movq 0xb5dc(%rip), %rdx      # 0x17f48
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0x110(%rbp)
jmp 0xc989
xorl %eax, %eax
movq %rax, -0x110(%rbp)
jmp 0xc989
movq -0x110(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xc9a3
movq -0xa0(%rbp), %rdi
addq $0x3d8, %rdi            # imm = 0x3D8
movq -0x60(%rbp), %rsi
callq 0xa600
movl %eax, -0x114(%rbp)
jmp 0xc9c2
movl -0x114(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xca39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x68(%rbp)
movq 0xb523(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x6600(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0x120(%rbp)
jmp 0xca16
movq -0x68(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xca34
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xca51
jmp 0xccae
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0xca8e
movq -0x128(%rbp), %rdi
movq 0xb573(%rip), %rsi      # 0x17fe8
movq 0xb4ec(%rip), %rdx      # 0x17f68
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0x130(%rbp)
jmp 0xca99
xorl %eax, %eax
movq %rax, -0x130(%rbp)
jmp 0xca99
movq -0x130(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xcab3
movq -0xa0(%rbp), %rdi
addq $0x3f8, %rdi            # imm = 0x3F8
movq -0x70(%rbp), %rsi
callq 0xa600
movl %eax, -0x134(%rbp)
jmp 0xcad2
movl -0x134(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xcb49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x78(%rbp)
movq 0xb413(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x64f0(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0x140(%rbp)
jmp 0xcb26
movq -0x78(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x140(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xcb44
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xcb61
jmp 0xccae
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, %rax
je 0xcb9e
movq -0x148(%rbp), %rdi
movq 0xb463(%rip), %rsi      # 0x17fe8
movq 0xb3c4(%rip), %rdx      # 0x17f50
xorl %eax, %eax
movl %eax, %ecx
callq 0xa960
movq %rax, -0x150(%rbp)
jmp 0xcba9
xorl %eax, %eax
movq %rax, -0x150(%rbp)
jmp 0xcba9
movq -0x150(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xcbc3
movq -0xa0(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
movq -0x80(%rbp), %rsi
callq 0xa600
movl %eax, -0x154(%rbp)
jmp 0xcbe2
movl -0x154(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xcc5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xccae
movq -0x28(%rbp), %rdi
callq 0xa330
movq %rax, -0x88(%rbp)
movq 0xb300(%rip), %rdi      # 0x17f20
addq $0x10, %rdi
leaq 0x63dd(%rip), %rsi      # 0x13008
callq 0xa890
movq %rax, -0x160(%rbp)
jmp 0xcc39
movq -0x88(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0xa890
jmp 0xcc5a
callq 0xad60
jmp 0xcc78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0xad60
jmp 0xcc74
jmp 0xccae
jmp 0xcc78
cmpl $0x2, -0x14(%rbp)
jne 0xcca2
callq 0xa090
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x90(%rbp)
movq -0x90(%rbp), %rcx
movq %rcx, 0x898(%rax)
movl -0x14(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0xae90
movq %rax, %rdi
callq 0xd050
nop