// File: /workspace/github_cpp_makefile_star2_O2/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
movslq %edi, %r13
pushq $0x2
popq %r12
leaq -0x1(%r12), %rax
cmpq %r13, %rax
jge 0x2682
movq -0x8(%r14,%r12,8), %rcx
cmpb $0x2d, (%rcx)
jne 0x2606
incl %eax
cmpl %ebp, %eax
jge 0x26a5
movzbl 0x1(%rcx), %eax
cmpl $0x64, %eax
je 0x25d8
cmpl $0x7a, %eax
je 0x25e6
cmpl $0x74, %eax
je 0x25bc
cmpl $0x73, %eax
jne 0x26aa
movq (%r14,%r12,8), %rax
movzbl (%rax), %eax
movb %al, 0x9c63(%rip)       # 0xc210
cmpl $0x62, %eax
je 0x25fd
cmpl $0x74, %eax
je 0x25fd
jmp 0x26f2
movq (%r14,%r12,8), %rax
movzbl (%rax), %eax
movb %al, 0x9c48(%rip)       # 0xc211
cmpl $0x62, %eax
je 0x25fd
cmpl $0x74, %eax
je 0x25fd
jmp 0x26df
movq (%r14,%r12,8), %rax
movb (%rax), %al
movb %al, 0xa584(%rip)       # 0xcb68
jmp 0x25fd
movq (%r14,%r12,8), %rdi
callq 0x2300
movb %al, 0x9c96(%rip)       # 0xc28b
testb $-0x2, %al
jne 0x26ca
addq $0x2, %r12
jmp 0x255e
movb 0x9c04(%rip), %al       # 0xc210
cmpb 0x9bff(%rip), %al       # 0xc211
je 0x2690
movq -0x8(%r14,%r12,8), %rsi
movq %r15, %rdi
callq 0x2190
cmpl %ebp, %r12d
jge 0x2640
movq (%r14,%r12,8), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2190
cmpb $0x62, 0x9bca(%rip)     # 0xc211
jne 0x265f
movabsq $0x622e74757074756f, %rax # imm = 0x622E74757074756F
movq %rax, (%rbx)
movl $0x6e6962, 0x7(%rbx)    # imm = 0x6E6962
jmp 0x2673
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
movb 0x9b88(%rip), %al       # 0xc210
cmpb 0x9b83(%rip), %al       # 0xc211
jne 0x26a5
movq 0x9941(%rip), %rax      # 0xbfd8
movq (%rax), %rcx
leaq 0x5a43(%rip), %rdi      # 0x80e4
pushq $0x37
jmp 0x2705
callq 0x252c
movsbl %al, %edx
movq 0x9924(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
leaq 0x5a11(%rip), %rsi      # 0x80cf
xorl %eax, %eax
callq 0x22b0
callq 0x252c
movq 0x9907(%rip), %rax      # 0xbfd8
movq (%rax), %rcx
leaq 0x59b3(%rip), %rdi      # 0x808e
pushq $0x40
jmp 0x2705
movq 0x98f2(%rip), %rax      # 0xbfd8
movq (%rax), %rcx
leaq 0x595f(%rip), %rdi      # 0x804f
jmp 0x2703
movq 0x98df(%rip), %rax      # 0xbfd8
movq (%rax), %rcx
leaq 0x590d(%rip), %rdi      # 0x8010
pushq $0x3e
popq %rsi
pushq $0x1
popq %rdx
callq 0x23e0
callq 0x252c