// File: /workspace/github_cpp_makefile_star2_O1/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 0x221b(%rip), %rsi      # 0x5131
callq 0x2280
testl %eax, %eax
je 0x2fe7
leaq 0x2257(%rip), %rsi      # 0x5181
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x306b
leaq 0x2259(%rip), %rsi      # 0x519a
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x30d8
leaq 0x225d(%rip), %rsi      # 0x51b5
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x3142
leaq 0x2265(%rip), %rsi      # 0x51d4
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x31e6
movq %rbx, %rdi
movl $0x20, %esi
callq 0x2220
movq %rax, %rbx
leaq 0x4279(%rip), %rsi      # 0x7210
leaq 0x4332(%rip), %rdx      # 0x72d0
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3c90
leaq 0x2228(%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 0x3265
movq %rdx, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x326c
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x421a(%rip), %rsi      # 0x7210
movq 0x421b(%rip), %rdx      # 0x7218
addq %rsi, %rdx
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x3d02
leaq 0x2128(%rip), %rsi      # 0x513b
movq %rbx, %rdi
callq 0x2360
leaq 0x41ee(%rip), %rdi      # 0x7210
movq %rbx, %rsi
callq 0x2260
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x303e
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x41cb(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f91, 0x417d(%rip)   # imm = 0x1F91
movq 0x3f76(%rip), %rbx      # 0x6fd0
leaq 0x210d(%rip), %rsi      # 0x516e
movl $0x12, %edx
jmp 0x31aa
leaq 0x419e(%rip), %rbx      # 0x7210
leaq 0x4237(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x30ab
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x411c(%rip)   # imm = 0x1F92
movq 0x4155(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3f09(%rip), %rbx      # 0x6fd0
leaq 0x20bb(%rip), %rsi      # 0x5189
movl $0x10, %edx
jmp 0x31aa
leaq 0x4131(%rip), %rbx      # 0x7210
leaq 0x41ca(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x3118
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x40f1(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f94, 0x40a3(%rip)   # imm = 0x1F94
movq 0x3e9c(%rip), %rbx      # 0x6fd0
leaq 0x2068(%rip), %rsi      # 0x51a3
movl $0x11, %edx
jmp 0x31aa
leaq 0x40c7(%rip), %rbx      # 0x7210
leaq 0x4160(%rip), %rdx      # 0x72b0
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x3182
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq 0x4087(%rip), %rdi      # 0x7210
callq 0x22e0
movw $0x1f93, 0x4039(%rip)   # imm = 0x1F93
movq 0x3e32(%rip), %rbx      # 0x6fd0
leaq 0x201b(%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 0x2016(%rip), %rsi      # 0x5203
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x338b
movq %rbx, %rdi
movl $0x20, %esi
callq 0x2220
movq %rax, %rbx
leaq 0x3ffb(%rip), %rsi      # 0x7210
leaq 0x40b4(%rip), %rdx      # 0x72d0
leaq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3c90
leaq 0x1fd9(%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 0x33f7
movq %rdx, -0x60(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x50(%rbp)
jmp 0x33fe
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 0x32b4
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x32bc
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 0x3f32(%rip), %rdi      # 0x7210
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x32fa
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x330f
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3328
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3e9f(%rip)   # imm = 0x1F92
movq 0x3ed8(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3c8c(%rip), %r14      # 0x6fd0
leaq 0x1e92(%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 0x1e6c(%rip), %rsi      # 0x51f2
jmp 0x3518
leaq 0x1e9c(%rip), %rsi      # 0x522e
movq %rbx, %rdi
callq 0x2070
testq %rax, %rax
je 0x355a
leaq 0x3e66(%rip), %rsi      # 0x7210
leaq 0x3f1f(%rip), %rdx      # 0x72d0
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x3c90
leaq 0x1e6f(%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 0x3589
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x3590
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 0x3446
movq %rdx, -0x40(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x344e
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 0x3da0(%rip), %rdi      # 0x7210
movq %r14, %rsi
callq 0x2260
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x348c
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x34a1
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34ba
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3d0d(%rip)   # imm = 0x1F92
movq 0x3d46(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x3afa(%rip), %r14      # 0x6fd0
leaq 0x1d2f(%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 0x1d05(%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 0x31cc
movq 0x3a6f(%rip), %rbx      # 0x6fd0
leaq 0x1cf3(%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 0x3c5e(%rip), %rdi      # 0x7210
movq %rbx, %rsi
callq 0x2260
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x35ce
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35e7
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
movw $0x1f92, 0x3be0(%rip)   # imm = 0x1F92
movq 0x3c19(%rip), %rdi      # 0x7210
callq 0x22e0
movq 0x39cd(%rip), %rbx      # 0x6fd0
leaq 0x1c2e(%rip), %rsi      # 0x5238
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2100
leaq 0x1c23(%rip), %rsi      # 0x5249
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2240
leaq 0x1af5(%rip), %rsi      # 0x512f
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2100
jmp 0x31d9
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36b6
movq -0x50(%rbp), %rsi
jmp 0x36ae
jmp 0x366e
jmp 0x3688
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x368b
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x368b
movq %rax, %rbx
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36b6
movq -0x70(%rbp), %rsi
jmp 0x36ae
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x36b6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2340