// File: /workspace/github_cpp_makefile_star2_O3/awbrenn[P]robot-controller/Middleware.cpp
// Function: detectCommand(char*)
void detectCommand(char *command)
{
    // when satisfied , remove all the cout(s) to make the code more readable and concise.

    char *temp = 0;
    char *value = 0;

    if(strcmp(command , "GET IMAGE")==0)
    {
        FILE_PATH = FILE_PATH + "snapshot?topic=/robot_8/image?width=100?height=100" ; // semi-hd :P  ; constant for now ; change later
        printf("%s\n", FILE_PATH.c_str());
        ROBOT_PORT = 8081;
        cout<<"request for image\n"<<endl;
    }
    else if(strcmp(command , "GET GPS")==0)
    {
        FILE_PATH = FILE_PATH + STATE_ID;
        ROBOT_PORT = 8082;
        printf("%s\n", FILE_PATH.c_str());
        cout<<"request for gps\n"<< endl;
    }
    else if(strcmp(command , "GET DGPS")==0)
    {
        FILE_PATH = FILE_PATH + STATE_ID ;
        printf("%s\n", FILE_PATH.c_str());
        ROBOT_PORT = 8084;
        cout<<"request for dgps\n"<<endl;
    }
    else if(strcmp(command , "GET LASERS")==0)
    {
        FILE_PATH = FILE_PATH + STATE_ID ;
        printf("%s\n", FILE_PATH.c_str());
        ROBOT_PORT = 8083;
        cout<<"request for lasers\n"<<endl;
    }
    else if(strstr(command , "MOVE")!=NULL)
    {
        temp = strrchr(command , ' ');
        temp++;
        value= temp;
        FILE_PATH = FILE_PATH + TWIST_ID + "lx=" + value ;
        ROBOT_PORT = 8082;
        printf("%s\n", FILE_PATH.c_str());
        cout<<"request for movement"<<endl;
        cout<<"move value is : "<<value<<endl;
    }
    else if(strstr(command , "TURN")!=NULL)
    {
        temp = strrchr(command , ' ');
        temp++;
        value = temp;
        FILE_PATH = FILE_PATH + TWIST_ID + "az=" + value ;
        ROBOT_PORT = 8082;
        printf("%s\n", FILE_PATH.c_str());
        cout<<"request for turn"<<endl;
        cout<<"turn value is : "<<value<<endl;
    }
    else if(strstr(command , "STOP")!=NULL)
    {
        FILE_PATH = FILE_PATH + TWIST_ID + "lx=0";
        ROBOT_PORT = 8082;
        printf("%s\n", FILE_PATH.c_str());
        cout<<"request for stop"<<endl;
        cout<<"move value is : 0"<< "\n" << endl;
    }

    else
        cout<<"unknown command"<<endl;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
leaq 0x2227(%rip), %rsi      # 0x5131
callq 0x2280
testl %eax, %eax
je 0x2fdb
leaq 0x2263(%rip), %rsi      # 0x5181
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x305f
leaq 0x2265(%rip), %rsi      # 0x519a
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x30cc
leaq 0x2269(%rip), %rsi      # 0x51b5
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x3136
leaq 0x2271(%rip), %rsi      # 0x51d4
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x31da
movq %rbx, %rdi
movl $0x20, %esi
callq 0x2220
movq %rax, %rbx
leaq 0x4285(%rip), %rsi      # 0x7210
leaq 0x433e(%rip), %rdx      # 0x72d0
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3ca2
leaq 0x2234(%rip), %rsi      # 0x51d9
movq %r14, %rdi
callq 0x2360
incq %rbx
leaq -0x50(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3259
movq %rdx, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x3260
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x4226(%rip), %rsi      # 0x7210
movq 0x4227(%rip), %rdx      # 0x7218
addq %rsi, %rdx
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x3d14
leaq 0x2134(%rip), %rsi      # 0x513b
movq %rbx, %rdi
callq 0x2360
leaq 0x41fa(%rip), %rdi      # 0x7210
movq %rbx, %rsi
callq 0x2260
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x3032
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x41d7(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f91, 0x4189(%rip)   # imm = 0x1F91
movq 0x3f82(%rip), %rbx      # 0x6fd0
leaq 0x2119(%rip), %rsi      # 0x516e
movl $0x12, %edx
jmp 0x319e
leaq 0x41aa(%rip), %rbx      # 0x7210
leaq 0x4243(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x309f
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x4128(%rip)   # imm = 0x1F92
movq 0x4161(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3f15(%rip), %rbx      # 0x6fd0
leaq 0x20c7(%rip), %rsi      # 0x5189
movl $0x10, %edx
jmp 0x319e
leaq 0x413d(%rip), %rbx      # 0x7210
leaq 0x41d6(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x310c
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x40fd(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f94, 0x40af(%rip)   # imm = 0x1F94
movq 0x3ea8(%rip), %rbx      # 0x6fd0
leaq 0x2074(%rip), %rsi      # 0x51a3
movl $0x11, %edx
jmp 0x319e
leaq 0x40d3(%rip), %rbx      # 0x7210
leaq 0x416c(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x3176
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x4093(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f93, 0x4045(%rip)   # imm = 0x1F93
movq 0x3e3e(%rip), %rbx      # 0x6fd0
leaq 0x2027(%rip), %rsi      # 0x51c0
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2022(%rip), %rsi      # 0x5203
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x337f
movq %rbx, %rdi
movl $0x20, %esi
callq 0x2220
movq %rax, %rbx
leaq 0x4007(%rip), %rsi      # 0x7210
leaq 0x40c0(%rip), %rdx      # 0x72d0
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3ca2
leaq 0x1fe5(%rip), %rsi      # 0x5208
movq %r14, %rdi
callq 0x2360
incq %rbx
leaq -0x50(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x33eb
movq %rdx, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x33f2
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq -0x60(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rsi
callq 0x2360
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x32a8
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x32b0
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq -0x40(%rbp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x3f3e(%rip), %rdi      # 0x7210
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x32ee
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x3303
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x331c
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3eab(%rip)   # imm = 0x1F92
movq 0x3ee4(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3c98(%rip), %r14      # 0x6fd0
leaq 0x1e9e(%rip), %rsi      # 0x51dd
movl $0x14, %edx
movq %r14, %rdi
callq 0x2240
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq 0x1e78(%rip), %rsi      # 0x51f2
jmp 0x350c
leaq 0x1ea8(%rip), %rsi      # 0x522e
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x354e
leaq 0x3e72(%rip), %rsi      # 0x7210
leaq 0x3f2b(%rip), %rdx      # 0x72d0
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x3ca2
leaq 0x1e7b(%rip), %rsi      # 0x5233
movq %rbx, %rdi
callq 0x2360
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x357d
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x3584
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq -0x60(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rsi
callq 0x2360
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x343a
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x3442
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq -0x40(%rbp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x3dac(%rip), %rdi      # 0x7210
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x3480
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x3495
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34ae
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3d19(%rip)   # imm = 0x1F92
movq 0x3d52(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3b06(%rip), %r14      # 0x6fd0
leaq 0x1d3b(%rip), %rsi      # 0x520c
movl $0x10, %edx
movq %r14, %rdi
callq 0x2240
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq 0x1d11(%rip), %rsi      # 0x521d
movl $0x10, %edx
movq %r14, %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x20f0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2240
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
jmp 0x31c0
movq 0x3a7b(%rip), %rbx      # 0x6fd0
leaq 0x1cff(%rip), %rsi      # 0x525b
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq %rbx, %rdi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2100
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0x40(%rbp), %rbx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x3c6a(%rip), %rdi      # 0x7210
movq %rbx, %rsi
callq 0x2260
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x35c2
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35db
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3bec(%rip)   # imm = 0x1F92
movq 0x3c25(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x39d9(%rip), %rbx      # 0x6fd0
leaq 0x1c3a(%rip), %rsi      # 0x5238
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2100
leaq 0x1c2f(%rip), %rsi      # 0x5249
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2240
leaq 0x1b01(%rip), %rsi      # 0x512f
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2100
jmp 0x31cd
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36aa
movq -0x50(%rbp), %rsi
jmp 0x36a2
jmp 0x3662
jmp 0x367c
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x367f
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x367f
movq %rax, %rbx
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36aa
movq -0x70(%rbp), %rsi
jmp 0x36a2
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x36aa
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2340