// File: /workspace/github_cpp_makefile_star2_O1/tplinderoth[P]introDist/introDist.cpp
// Function: distAnalysis(int, char**)
int distAnalysis(int argc, char** argv) {

	int rv = 0;
	std::string dist_t(argv[1]);
	std::fstream freqfile;
	std::fstream genofile;
	std::string genofname;
	unsigned int window = 1;
	unsigned int step = 1;
	int useAvg = 1; // whether to use genome or window average for comp2Dist
	int avgtype = 0;
	double distance = -1;

	if ((rv = parseArgs(argc, argv, freqfile, genofile, window, step, &genofname, useAvg, avgtype, distance, &dist_t)) == 0) {
		if (dist_t.compare("comp2Dist") == 0) {
			double* dptr = distance >= 0 ? &distance : NULL;
			rv = comp2Dist(freqfile, genofile, window, step, useAvg, &genofname, dptr);
		}
		else if (dist_t.compare("comp3Dist") == 0) {
			rv = comp3Dist(freqfile, genofile, window, step);
		}
		else if (dist_t.compare("avgDist") == 0) {
			rv = avgDist(freqfile, genofile, avgtype);
		}
		else {
			rv = -1;
			std::cerr << "\n" << dist_t << " is an invalid function\n";
		}
	} else if (rv == 1) {
		rv = 0;
	}

	if (freqfile.is_open())
		freqfile.close();
	if (genofile.is_open())
		genofile.close();

	return rv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq %rsi, %r14
movl %edi, %r15d
movq 0x8(%rsi), %rsi
leaq -0x58(%rbp), %rbx
leaq -0x290(%rbp), %rdx
movq %rbx, %rdi
callq 0x8108
leaq -0x290(%rbp), %rdi
callq 0x3260
leaq -0x4a0(%rbp), %rdi
callq 0x3260
leaq -0x70(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movl $0x1, %eax
leaq -0x30(%rbp), %r8
movl %eax, (%r8)
leaq -0x2c(%rbp), %r9
movl %eax, (%r9)
leaq -0x38(%rbp), %r10
movl %eax, (%r10)
leaq -0x34(%rbp), %rax
movl $0x0, (%rax)
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
leaq -0x60(%rbp), %r13
movq %rcx, (%r13)
subq $0x8, %rsp
leaq -0x80(%rbp), %r11
leaq -0x290(%rbp), %rdx
leaq -0x4a0(%rbp), %rcx
movl %r15d, %edi
movq %r14, %rsi
pushq %rbx
pushq %r13
pushq %rax
pushq %r10
pushq %r11
callq 0x39eb
addq $0x30, %rsp
testl %eax, %eax
je 0x37ff
xorl %ebx, %ebx
cmpl $0x1, %eax
cmovnel %eax, %ebx
jmp 0x38fc
leaq 0x686a(%rip), %rsi      # 0xa070
leaq -0x58(%rbp), %rdi
callq 0x30d0
testl %eax, %eax
je 0x388a
leaq 0x6860(%rip), %rsi      # 0xa07a
leaq -0x58(%rbp), %rdi
callq 0x30d0
testl %eax, %eax
je 0x38c9
leaq 0x6852(%rip), %rsi      # 0xa084
leaq -0x58(%rbp), %rdi
callq 0x30d0
testl %eax, %eax
je 0x38e4
movq 0xa7a6(%rip), %rdi      # 0xdff0
leaq 0x7361(%rip), %rsi      # 0xabb2
movl $0x1, %edx
callq 0x3250
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0xa786(%rip), %rdi      # 0xdff0
callq 0x3250
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x6811(%rip), %rsi      # 0xa08c
movl $0x18, %edx
movq %rax, %rdi
callq 0x3250
jmp 0x38fc
movsd -0x60(%rbp), %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
cmovaeq %r13, %rax
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl -0x38(%rbp), %r8d
subq $0x8, %rsp
leaq -0x290(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
leaq -0x80(%rbp), %r9
pushq %rax
callq 0x3dc6
addq $0x10, %rsp
jmp 0x38fa
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
leaq -0x290(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x3ec8
jmp 0x38fa
movl -0x34(%rbp), %edx
leaq -0x290(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x49a4
movl %eax, %ebx
leaq -0x210(%rbp), %rdi
callq 0x3090
testb %al, %al
je 0x3918
leaq -0x290(%rbp), %rdi
callq 0x3050
leaq -0x420(%rbp), %rdi
callq 0x3090
testb %al, %al
je 0x3934
leaq -0x4a0(%rbp), %rdi
callq 0x3050
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x3949
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3220
leaq -0x4a0(%rbp), %rdi
callq 0x3080
leaq -0x290(%rbp), %rdi
callq 0x3080
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x397a
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movl %ebx, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x399a
movq %rax, %rbx
jmp 0x39be
movq %rax, %rbx
jmp 0x39ca
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r12, %rdi
je 0x39b2
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3220
leaq -0x4a0(%rbp), %rdi
callq 0x3080
leaq -0x290(%rbp), %rdi
callq 0x3080
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x39e3
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3390