// File: tonymugen[P]sampleSNPs/sampleLD.cpp
// Function: main
int main(int argc, char *argv[]){
	string inFileStub;  // input file name stub (without extension)
	string popFileName; // population index file name
	string nSampTxt;    // string version of the number of samples
	uint64_t n;         // number of samples
	bool pop = false;   // are we stratifying by population?

	// set usage message
	string cliHelp = "Command line flags required (in any order):\n  -s NNN (number of samples)\n  -i fileStub (input file name, without extension)\n  -p popIndexFile (optional file with the population index)";
	unordered_map <char, string> clInfo;
	parseCL(argc, argv, clInfo);
	auto clIter = clInfo.begin(); // iterator of the command line flags

	// processing CL input
	clIter = clInfo.find('s');
	if (clIter == clInfo.end()) { // if not there, complain
		cerr << "ERROR: specification of the number of samples is required" << endl;
		cerr << cliHelp << endl;
		exit(1);
	} else {
		n        = stoi(clIter->second);
		nSampTxt = clIter->second;
	}
	clIter = clInfo.find('i');
	if (clIter == clInfo.end()) { // if not there, complain
		cerr << "ERROR: specification of the input file name is required" << endl;
		cerr << cliHelp << endl;
		exit(1);
	} else {
		inFileStub = clIter->second;
	}

	clIter = clInfo.find('p');
	if (clIter != clInfo.end()) {
		pop         = true;
		popFileName = clIter->second;
	}
	if (pop) { // stratify by population
		PopIndex popIdx(popFileName);
		BedFileI inBed(inFileStub);
		inBed.sampleLD(popIdx, n);
	} else {
		BedFileI inBed(inFileStub);
		inBed.sampleLD(n);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xed0, %rsp            # imm = 0xED0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4480
leaq -0x50(%rbp), %rdi
callq 0x4480
leaq -0x70(%rbp), %rdi
callq 0x4480
movb $0x0, -0x79(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0xe78(%rbp)
callq 0x45b0
movq -0xe78(%rbp), %rdx
leaq 0x1e2ba(%rip), %rsi     # 0x23083
leaq -0xa0(%rbp), %rdi
callq 0x52c0
jmp 0x4dd7
leaq -0xa1(%rbp), %rdi
callq 0x4340
leaq -0xf0(%rbp), %rdi
movq %rdi, -0xe80(%rbp)
callq 0x5370
movq -0xe80(%rbp), %rdx
movq -0x10(%rbp), %rsi
leaq -0x8(%rbp), %rdi
callq 0x4c60
jmp 0x4e0c
leaq -0xf0(%rbp), %rdi
movq %rdi, -0xe90(%rbp)
callq 0x5390
movq -0xe90(%rbp), %rdi
movq %rax, -0xf8(%rbp)
movb $0x73, -0x101(%rbp)
leaq -0x101(%rbp), %rsi
callq 0x53c0
movq %rax, -0xe88(%rbp)
jmp 0x4e49
movq -0xe88(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5420
movq %rax, -0x110(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x53f0
testb $0x1, %al
jne 0x4e94
jmp 0x4f3a
movq 0x28155(%rip), %rdi     # 0x2cff0
leaq 0x1e299(%rip), %rsi     # 0x2313b
callq 0x42f0
movq %rax, -0xe98(%rbp)
jmp 0x4eb0
movq -0xe98(%rbp), %rdi
movq 0x280f2(%rip), %rsi     # 0x2cfb0
callq 0x4320
jmp 0x4ec5
movq 0x28124(%rip), %rdi     # 0x2cff0
leaq -0xa0(%rbp), %rsi
callq 0x42c0
movq %rax, -0xea0(%rbp)
jmp 0x4ee1
movq -0xea0(%rbp), %rdi
movq 0x280c1(%rip), %rsi     # 0x2cfb0
callq 0x4320
jmp 0x4ef6
movl $0x1, %edi
callq 0x43b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x4340
jmp 0x5265
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x524d
leaq -0xf8(%rbp), %rdi
callq 0x5490
movq %rax, %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x5450
movl %eax, -0xea4(%rbp)
jmp 0x4f63
movl -0xea4(%rbp), %eax
cltq
movq %rax, -0x78(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5490
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x70(%rbp), %rdi
callq 0x4040
jmp 0x4f8d
jmp 0x4f8f
movb $0x69, -0x119(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x119(%rbp), %rsi
callq 0x53c0
movq %rax, -0xeb0(%rbp)
jmp 0x4fb2
movq -0xeb0(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5420
movq %rax, -0x128(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x53f0
testb $0x1, %al
jne 0x4ffa
jmp 0x5066
movq 0x27fef(%rip), %rdi     # 0x2cff0
leaq 0x1e16d(%rip), %rsi     # 0x23175
callq 0x42f0
movq %rax, -0xeb8(%rbp)
jmp 0x5016
movq -0xeb8(%rbp), %rdi
movq 0x27f8c(%rip), %rsi     # 0x2cfb0
callq 0x4320
jmp 0x502b
movq 0x27fbe(%rip), %rdi     # 0x2cff0
leaq -0xa0(%rbp), %rsi
callq 0x42c0
movq %rax, -0xec0(%rbp)
jmp 0x5047
movq -0xec0(%rbp), %rdi
movq 0x27f5b(%rip), %rsi     # 0x2cfb0
callq 0x4320
jmp 0x505c
movl $0x1, %edi
callq 0x43b0
leaq -0xf8(%rbp), %rdi
callq 0x5490
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x30(%rbp), %rdi
callq 0x4040
jmp 0x5084
jmp 0x5086
movb $0x70, -0x131(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x131(%rbp), %rsi
callq 0x53c0
movq %rax, -0xec8(%rbp)
jmp 0x50a9
movq -0xec8(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5420
movq %rax, -0x140(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x54c0
testb $0x1, %al
jne 0x50f1
jmp 0x5115
movb $0x1, -0x79(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x5490
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x50(%rbp), %rdi
callq 0x4040
jmp 0x5113
jmp 0x5115
testb $0x1, -0x79(%rbp)
je 0x51bc
leaq -0x160(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x20b40
jmp 0x5131
leaq -0x7e8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x54f0
jmp 0x5143
leaq -0x7e8(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x119f0
jmp 0x515c
leaq -0x7e8(%rbp), %rdi
callq 0x5530
leaq -0x160(%rbp), %rdi
callq 0x5550
jmp 0x520e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x51ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x7e8(%rbp), %rdi
callq 0x5530
leaq -0x160(%rbp), %rdi
callq 0x5550
jmp 0x524d
leaq -0xe70(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x54f0
jmp 0x51ce
leaq -0xe70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xfad0
jmp 0x51e0
leaq -0xe70(%rbp), %rdi
callq 0x5530
jmp 0x520e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0xe70(%rbp), %rdi
callq 0x5530
jmp 0x524d
leaq -0xf0(%rbp), %rdi
callq 0x5570
leaq -0xa0(%rbp), %rdi
callq 0x4668
leaq -0x70(%rbp), %rdi
callq 0x4668
leaq -0x50(%rbp), %rdi
callq 0x4668
leaq -0x30(%rbp), %rdi
callq 0x4668
movl -0x4(%rbp), %eax
addq $0xed0, %rsp            # imm = 0xED0
popq %rbp
retq
leaq -0xf0(%rbp), %rdi
callq 0x5570
leaq -0xa0(%rbp), %rdi
callq 0x4668
leaq -0x70(%rbp), %rdi
callq 0x4668
leaq -0x50(%rbp), %rdi
callq 0x4668
leaq -0x30(%rbp), %rdi
callq 0x4668
movq -0xb0(%rbp), %rdi
callq 0x45a0
nopl (%rax)