// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/inputconvert.cpp
// Function: parse_arguments(int, char**, char*, char*)
void parse_arguments(int argc, char **argv, char *input_file_name, char *output_file_name) {
	// parse command line options, starting from 1 (0 is path to executable)
	// go in pairs, looking at whether first in pair starts with '-', if not, stop parsing arguments
	int i;
	for(i=1;i<argc;i++)
	{
		if(argv[i][0] != '-') break; // end of options stop parsing
		if(++i>=argc)
			exit_with_help();
		switch(argv[i-1][1])
		{
			case 's':
				source_format = argv[i][0];
                if( source_format!='t' && source_format!='b') {
					fprintf(stderr,"ERROR! source format should be either text 't', or binary 'b'\n");
					exit_with_help();
				}
				break;
			case 't':
				target_format = argv[i][0];
                if( target_format!='t' && target_format!='b') {
					fprintf(stderr,"ERROR! target format should be either text 't', or binary 'b'\n");
					exit_with_help();
				}
				break;
            case  'd':
				task.multiskill = argv[i][0]; // just grab first character (later, maybe several)
                break;
            case 'z':
                task.sliced = (NPAR)atoi(argv[i]);
                if(task.sliced!=0 && task.sliced!=1) {
                    fprintf(stderr,"ERROR! Multiplexing parameter should be either 0 (off) or 1(on)\n");
                    exit_with_help();
                }
                break;
			default:
				fprintf(stderr,"unknown option: -%c\n", argv[i-1][1]);
				exit_with_help();
				break;
		}
	}
//    post-argument checks
    if( source_format == target_format) {
        fprintf(stderr,"ERROR! source and target formats should not be the same");
        exit_with_help();
    }
	
	// next argument should be input file name
	if(i>=argc) // if not
		exit_with_help(); // leave
	
	strcpy(input_file_name, argv[i++]); // copy and advance
	
	if(i>=argc) { // no output file name specified
        if(target_format=='b')
            strcpy(output_file_name,"output.bin");
        else
            strcpy(output_file_name,"output.txt");
	} else {
		strcpy(output_file_name,argv[i++]); // copy and advance
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
movl %edi, %ebp
movl $0x1, %r12d
cmpl $0x2, %edi
setge %al
jl 0x2a61
movq 0x8(%r14), %rcx
cmpb $0x2d, (%rcx)
jne 0x2a61
movl $0x3, %r12d
movl $0x2, %r13d
cmpl %ebp, %r13d
jge 0x2aed
movzbl 0x1(%rcx), %edi
cmpl $0x73, %edi
jg 0x29f0
cmpl $0x64, %edi
je 0x2a16
cmpl $0x73, %edi
jne 0x2b08
movq (%r14,%r13,8), %rax
movzbl (%rax), %eax
movb %al, 0xb80f(%rip)       # 0xe1f0
cmpl $0x62, %eax
je 0x2a3f
cmpl $0x74, %eax
je 0x2a3f
jmp 0x2b17
cmpl $0x74, %edi
je 0x2a24
cmpl $0x7a, %edi
jne 0x2b08
movq (%r14,%r13,8), %rdi
callq 0x22f0
movb %al, 0xb85e(%rip)       # 0xe26b
testb $-0x2, %al
je 0x2a3f
jmp 0x2b03
movq (%r14,%r13,8), %rax
movb (%rax), %al
movb %al, 0xc126(%rip)       # 0xeb48
jmp 0x2a3f
movq (%r14,%r13,8), %rax
movzbl (%rax), %eax
movb %al, 0xb7c0(%rip)       # 0xe1f1
cmpl $0x62, %eax
je 0x2a3f
cmpl $0x74, %eax
jne 0x2b12
cmpl %ebp, %r12d
setl %al
jge 0x2a61
movq 0x8(%r14,%r13,8), %rcx
addl $0x2, %r12d
addq $0x2, %r13
cmpb $0x2d, (%rcx)
je 0x29b4
addl $-0x2, %r12d
movb 0xb789(%rip), %cl       # 0xe1f0
cmpb 0xb784(%rip), %cl       # 0xe1f1
je 0x2b0d
testb %al, %al
je 0x2aed
movl %r12d, %eax
incl %r12d
movq (%r14,%rax,8), %rsi
movq %r15, %rdi
callq 0x2190
cmpl %ebp, %r12d
jge 0x2aab
movl %r12d, %eax
movq (%r14,%rax,8), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2190
cmpb $0x62, 0xb73f(%rip)     # 0xe1f1
jne 0x2aca
movabsq $0x622e74757074756f, %rax # imm = 0x622E74757074756F
movq %rax, (%rbx)
movl $0x6e6962, 0x7(%rbx)    # imm = 0x6E6962
jmp 0x2ade
movabsq $0x742e74757074756f, %rax # imm = 0x742E74757074756F
movq %rax, (%rbx)
movl $0x747874, 0x7(%rbx)    # imm = 0x747874
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7665(%rip), %rdi      # 0xa159
callq 0x22d0
movl $0x1, %edi
callq 0x2240
callq 0x23d0
callq 0x2494
callq 0x2432
callq 0x2401
callq 0x2463