// File: /workspace/github_cpp_makefile_star2_O3/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 %rdx, (%rsp)
cmpl $0x2, %edi
jl 0x2b44
movq %rcx, %rbx
movq %rsi, %r14
movl %edi, %ebp
movl $0x1, %r12d
movl $0x2, %r15d
movq -0x8(%r14,%r15,8), %rax
movb (%rax), %r13b
cmpb $0x2d, %r13b
jne 0x2a9d
cmpl %ebp, %r15d
jge 0x2b57
movzbl 0x1(%rax), %edi
cmpl $0x73, %edi
jg 0x2a3d
cmpl $0x64, %edi
je 0x2a63
cmpl $0x73, %edi
jne 0x2b35
movq (%r14,%r15,8), %rax
movzbl (%rax), %eax
movb %al, 0xb7c2(%rip)       # 0xe1f0
cmpl $0x62, %eax
je 0x2a8c
cmpl $0x74, %eax
je 0x2a8c
jmp 0x2b3f
cmpl $0x74, %edi
je 0x2a71
cmpl $0x7a, %edi
jne 0x2b35
movq (%r14,%r15,8), %rdi
callq 0x22f0
movb %al, 0xb811(%rip)       # 0xe26b
testb $-0x2, %al
je 0x2a8c
jmp 0x2b30
movq (%r14,%r15,8), %rax
movb (%rax), %al
movb %al, 0xc0d9(%rip)       # 0xeb48
jmp 0x2a8c
movq (%r14,%r15,8), %rax
movzbl (%rax), %eax
movb %al, 0xb773(%rip)       # 0xe1f1
cmpl $0x62, %eax
je 0x2a8c
cmpl $0x74, %eax
jne 0x2b3a
addl $0x2, %r12d
addq $0x2, %r15
cmpl %ebp, %r12d
jl 0x29ef
movb 0xb74d(%rip), %al       # 0xe1f0
cmpb 0xb748(%rip), %al       # 0xe1f1
je 0x2b52
cmpb $0x2d, %r13b
je 0x2b57
movl %r12d, %eax
incl %r12d
movq (%r14,%rax,8), %rsi
movq (%rsp), %rdi
callq 0x2190
cmpl %ebp, %r12d
jge 0x2aee
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, 0xb6fc(%rip)     # 0xe1f1
jne 0x2b0d
movabsq $0x622e74757074756f, %rax # imm = 0x622E74757074756F
movq %rax, (%rbx)
movl $0x6e6962, 0x7(%rbx)    # imm = 0x6E6962
jmp 0x2b21
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
callq 0x23d0
callq 0x2494
callq 0x2401
callq 0x2463
movb 0xb6a6(%rip), %al       # 0xe1f0
cmpb 0xb6a1(%rip), %al       # 0xe1f1
jne 0x2b57
callq 0x2432
leaq 0x75fb(%rip), %rdi      # 0xa159
callq 0x22d0
movl $0x1, %edi
callq 0x2240