// File: richardposner[P]BioNetFit2/src/code/Utils.cpp
// Function: readCommandLine(int, char const**, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>>&)
int readCommandLine(int argc, const char *argv[], map<string,vector<string> > &cmdLine){  //razi added
	int i, j=0; string sw; string temp;
	string s;
	for (i=1; i<argc; i++){
		s=argv[i];
		//cout<<"reading command line str["<<i<<"] = "<<s<<endl;
		if (s.substr(0,1).compare("-")==0){  //a new switch is found
			sw=s.substr(1,s.size()-1);
			if (sw.empty()){
				cout<<"Invalid switch:"<< s  <<"  value not specified, quitting .... "<<endl;
				return 0;
			}else{ //now read the options
				//cout<<"switch found:-"<<sw<<endl;

				vector<string> options; options.clear();
				j=1; bool exitflag=false;
				while(!exitflag){
					if ((i+j) < argc){
						temp = argv[i+j];
						//cout<<"checking options["<<j<<"]=" << temp << endl;
						if  (temp.substr(0,1).compare("-")==0){
							//cout<<"This is not an option, it is a new switch, i set to:"<<i+j<< endl;
							i=i+j-1;  //move the pointer to the new switch
							exitflag=true;
						}
						else{  //a valid option
							//cout<<"Option found: "<<argv[i+j]<<"   added to the list of options"<<endl;
							options.push_back(argv[i+j]);
							j++;  //collect other options
						}
					}else{
						//cout<<"Command line reading finished, reached the end while reading the options i+j:"<<i+j<<endl;
						i=i+j-1;  //move the pointer to the new switch
						exitflag=true;
					}
				}
				//if (options.size()>0), cout<<"# "<<options.size() <<"Options were found and added to the list"<<endl;
				cmdLine[sw]=options;
			}
		}else{
			cout<<"invalid format for switch:"<<s<<" Expecting to start with -, quitting .... "<<endl;
			return 0;
		}
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2f880
leaq -0x60(%rbp), %rdi
callq 0x2f880
leaq -0x80(%rbp), %rdi
callq 0x2f880
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x17de10
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2f9d0
jmp 0x17da42
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x1, %ecx
callq 0x30b40
jmp 0x17da5d
leaq -0xb0(%rbp), %rdi
leaq 0x668c1(%rip), %rsi     # 0x1e432c
callq 0x308a0
movl %eax, -0x140(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x311e8
movl -0x140(%rbp), %eax
cmpl $0x0, %eax
jne 0x17dd87
leaq -0x80(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2f720
movq -0x148(%rbp), %rsi
movq %rax, %rcx
decq %rcx
leaq -0xd0(%rbp), %rdi
movl $0x1, %edx
callq 0x30b40
jmp 0x17dac1
leaq -0x40(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2fd80
leaq -0xd0(%rbp), %rdi
callq 0x311e8
leaq -0x40(%rbp), %rdi
callq 0x2f700
testb $0x1, %al
jne 0x17daef
jmp 0x17db82
movq 0x15745a(%rip), %rdi    # 0x2d4f50
leaq 0x87776(%rip), %rsi     # 0x205273
callq 0x2ff50
movq %rax, -0x150(%rbp)
jmp 0x17db0b
movq -0x150(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2f780
movq %rax, -0x158(%rbp)
jmp 0x17db24
movq -0x158(%rbp), %rdi
leaq 0x87751(%rip), %rsi     # 0x205283
callq 0x2ff50
movq %rax, -0x160(%rbp)
jmp 0x17db40
movq -0x160(%rbp), %rdi
movq 0x15747a(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x17db55
movl $0x0, -0x4(%rbp)
movl $0x1, -0xd4(%rbp)
jmp 0x17de21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x17de48
leaq -0xf0(%rbp), %rdi
callq 0x448b0
leaq -0xf0(%rbp), %rdi
callq 0x451d0
movl $0x1, -0x20(%rbp)
movb $0x0, -0xf1(%rbp)
movb -0xf1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x17dbb9
jmp 0x17dd3b
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x17dd23
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x60(%rbp), %rdi
callq 0x2f9d0
jmp 0x17dbe6
xorl %eax, %eax
movl %eax, %edx
leaq -0x118(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x1, %ecx
callq 0x30b40
jmp 0x17dc01
leaq -0x118(%rbp), %rdi
leaq 0x6671d(%rip), %rsi     # 0x1e432c
callq 0x308a0
movl %eax, -0x164(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x311e8
movl -0x164(%rbp), %eax
cmpl $0x0, %eax
jne 0x17dc60
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movb $0x1, -0xf1(%rbp)
jmp 0x17dd21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x17dd74
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x178(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x30a70
movq -0x178(%rbp), %rsi
movq -0x170(%rbp), %rdx
leaq -0x138(%rbp), %rdi
callq 0x44470
jmp 0x17dca9
leaq -0xf0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xb39c0
jmp 0x17dcbe
leaq -0x138(%rbp), %rdi
callq 0x311e8
leaq -0x139(%rbp), %rdi
callq 0x311c0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x17dd21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x17dd13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x311e8
leaq -0x139(%rbp), %rdi
callq 0x311c0
jmp 0x17dd74
jmp 0x17dd36
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movb $0x1, -0xf1(%rbp)
jmp 0x17dba8
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x17e7c0
movq %rax, -0x180(%rbp)
jmp 0x17dd51
movq -0x180(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x45610
jmp 0x17dd66
leaq -0xf0(%rbp), %rdi
callq 0x448d0
jmp 0x17dd85
leaq -0xf0(%rbp), %rdi
callq 0x448d0
jmp 0x17de48
jmp 0x17de00
movq 0x1571c2(%rip), %rdi    # 0x2d4f50
leaq 0x87514(%rip), %rsi     # 0x2052a9
callq 0x2ff50
movq %rax, -0x188(%rbp)
jmp 0x17dda3
movq -0x188(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2f780
movq %rax, -0x190(%rbp)
jmp 0x17ddbc
movq -0x190(%rbp), %rdi
leaq 0x874fa(%rip), %rsi     # 0x2052c4
callq 0x2ff50
movq %rax, -0x198(%rbp)
jmp 0x17ddd8
movq -0x198(%rbp), %rdi
movq 0x1571e2(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x17dded
movl $0x0, -0x4(%rbp)
movl $0x1, -0xd4(%rbp)
jmp 0x17de21
jmp 0x17de02
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17da1f
movl $0x1, -0x4(%rbp)
movl $0x1, -0xd4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x311e8
leaq -0x60(%rbp), %rdi
callq 0x311e8
leaq -0x40(%rbp), %rdi
callq 0x311e8
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x311e8
leaq -0x60(%rbp), %rdi
callq 0x311e8
leaq -0x40(%rbp), %rdi
callq 0x311e8
movq -0x88(%rbp), %rdi
callq 0x30170
nop