// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
leaq 0x149e(%rip), %rsi      # 0x4136
callq 0x2290
testl %eax, %eax
je 0x2dbc
leaq 0x14da(%rip), %rsi      # 0x4186
movq %rbx, %rdi
callq 0x2290
testl %eax, %eax
je 0x2e14
leaq 0x14dc(%rip), %rsi      # 0x419f
movq %rbx, %rdi
callq 0x2290
testl %eax, %eax
je 0x2e6c
leaq 0x14e0(%rip), %rsi      # 0x41ba
movq %rbx, %rdi
callq 0x2290
testl %eax, %eax
je 0x2ec4
leaq 0x14e8(%rip), %rsi      # 0x41d9
movq %rbx, %rdi
callq 0x2060
testq %rax, %rax
je 0x2f1c
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0x4501(%rip), %rsi      # 0x7218
leaq 0x45ba(%rip), %rdx      # 0x72d8
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x35d8
leaq 0x14ad(%rip), %rdx      # 0x41de
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x3501
incq %rbx
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0x3501
leaq 0x44c1(%rip), %rdi      # 0x7218
leaq -0x50(%rbp), %r14
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
leaq -0x30(%rbp), %rdi
callq 0x2398
leaq -0x70(%rbp), %rdi
callq 0x2398
movw $0x1f92, 0x4452(%rip)   # imm = 0x1F92
movq 0x448b(%rip), %rdi      # 0x7218
callq 0x22e0
movq 0x4237(%rip), %r14      # 0x6fd0
leaq 0x1442(%rip), %rsi      # 0x41e2
movq %r14, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
leaq 0x1440(%rip), %rsi      # 0x41f7
jmp 0x2fe9
leaq 0x4455(%rip), %rbx      # 0x7218
leaq 0x1376(%rip), %rdx      # 0x4140
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x35a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
movq 0x4425(%rip), %rdi      # 0x7218
callq 0x22e0
movw $0x1f91, 0x43d7(%rip)   # imm = 0x1F91
movq 0x41c8(%rip), %rdi      # 0x6fd0
leaq 0x1364(%rip), %rsi      # 0x4173
jmp 0x2ff7
leaq 0x43fd(%rip), %rbx      # 0x7218
leaq 0x4496(%rip), %rdx      # 0x72b8
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x35d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
movw $0x1f92, 0x438b(%rip)   # imm = 0x1F92
movq 0x43c4(%rip), %rdi      # 0x7218
callq 0x22e0
movq 0x4170(%rip), %rdi      # 0x6fd0
leaq 0x1327(%rip), %rsi      # 0x418e
jmp 0x2ff7
leaq 0x43a5(%rip), %rbx      # 0x7218
leaq 0x443e(%rip), %rdx      # 0x72b8
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x35d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
movq 0x4375(%rip), %rdi      # 0x7218
callq 0x22e0
movw $0x1f94, 0x4327(%rip)   # imm = 0x1F94
movq 0x4118(%rip), %rdi      # 0x6fd0
leaq 0x12e9(%rip), %rsi      # 0x41a8
jmp 0x2ff7
leaq 0x434d(%rip), %rbx      # 0x7218
leaq 0x43e6(%rip), %rdx      # 0x72b8
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x35d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
movq 0x431d(%rip), %rdi      # 0x7218
callq 0x22e0
movw $0x1f93, 0x42cf(%rip)   # imm = 0x1F93
movq 0x40c0(%rip), %rdi      # 0x6fd0
leaq 0x12ae(%rip), %rsi      # 0x41c5
jmp 0x2ff7
leaq 0x12e5(%rip), %rsi      # 0x4208
movq %rbx, %rdi
callq 0x2060
testq %rax, %rax
je 0x300d
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0x42cf(%rip), %rsi      # 0x7218
leaq 0x4388(%rip), %rdx      # 0x72d8
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x35d8
leaq 0x12aa(%rip), %rdx      # 0x420d
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x3501
incq %rbx
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0x3501
leaq 0x428f(%rip), %rdi      # 0x7218
leaq -0x50(%rbp), %r14
movq %r14, %rsi
callq 0x2240
movq %r14, %rdi
callq 0x2398
leaq -0x30(%rbp), %rdi
callq 0x2398
leaq -0x70(%rbp), %rdi
callq 0x2398
movw $0x1f92, 0x4220(%rip)   # imm = 0x1F92
movq 0x4259(%rip), %rdi      # 0x7218
callq 0x22e0
movq 0x4005(%rip), %r14      # 0x6fd0
leaq 0x123f(%rip), %rsi      # 0x4211
movq %r14, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
leaq 0x1239(%rip), %rsi      # 0x4222
movq %r14, %rdi
callq 0x21c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x121f(%rip), %rsi      # 0x4233
movq %rbx, %rdi
callq 0x2060
testq %rax, %rax
je 0x30c7
leaq 0x41ec(%rip), %rsi      # 0x7218
leaq 0x42a5(%rip), %rdx      # 0x72d8
leaq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x35d8
leaq 0x11f2(%rip), %rdx      # 0x4238
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x3501
leaq 0x41bf(%rip), %rdi      # 0x7218
leaq -0x50(%rbp), %rbx
movq %rbx, %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x2398
leaq -0x30(%rbp), %rdi
callq 0x2398
movw $0x1f92, 0x4159(%rip)   # imm = 0x1F92
movq 0x4192(%rip), %rdi      # 0x7218
callq 0x22e0
movq 0x3f3e(%rip), %rbx      # 0x6fd0
leaq 0x11a4(%rip), %rsi      # 0x423d
movq %rbx, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
leaq 0x119e(%rip), %rsi      # 0x424e
movq %rbx, %rdi
callq 0x21c0
leaq 0x1075(%rip), %rsi      # 0x4134
movq %rax, %rdi
jmp 0x2ff7
movq 0x3f02(%rip), %rdi      # 0x6fd0
leaq 0x118b(%rip), %rsi      # 0x4260
callq 0x21c0
movq %rax, %rdi
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x20e0
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
jmp 0x310c
jmp 0x30f7
jmp 0x3105
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x2398
jmp 0x3108
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2398
movq %rbx, %rdi
callq 0x2320