// File: tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::VcfFileI::sample(sampFiles::VcfFileO&, unsigned long const&)
void VcfFileI::sample(VcfFileO &out, const uint64_t &n){
	if (n == 0) {
		cerr << "WARNING: zero SNPs requested. Nothing to be done." << endl;
		return;
	}
	// start by figuring out the number of SNPs in the file
	if (out._varFile.is_open()) {
		out.close();
	}


	uint64_t N = _numLines(); // Number of SNPs
	try {
		_varFile.open(_fileName.c_str(), ios::in);
		if (!_varFile.is_open()) {
			cerr << "ERROR: failed to open .vcf file " << _fileName << " for input" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .vcf file " << _fileName << " for input: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	try {
		out._varFile.open(out._fileName.c_str(), ios::out | ios::trunc);
		if (!out._varFile.is_open()) {
			cerr << "ERROR: failed to open .vcf file " << out._fileName << " for output" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .vcf file " << out._fileName << " for output: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	// Skip and copy the header
	string headLine;
	while (1) {
		getline(_varFile, headLine);
		if (headLine[0] != '#') {
			uint64_t cur = _varFile.tellg();
			if (cur < headLine.size()) {
				cerr << "ERROR: current position (" << cur << ") smaller than header line length (" << headLine.size() << ")" << endl;
				exit(6);
			}
			_varFile.seekg(cur - headLine.size() - 1); // go back to the start of the line, since this is the first non-header line
			break;
		}
		out._varFile << headLine << endl;
	}

	// Test for potential problems
	if (N < n) {
		cerr << "ERROR: requested a sample of " << n << " SNPs that is greater than the number of SNPs (" << N << ") in the input file." << endl;
		return;
	} else if (N == n) {
		cerr << "WARNING: sample size (" << n << ") the same as the number of SNPs (" << N << ") in the input file. Simply copying the files." << endl;
		char *buf;
		const size_t bufSize = BUF_SIZE;
		try {
			buf = new char[bufSize];
		} catch (bad_alloc&) {
			cerr << "ERROR: failed to allocate buffer" << endl;
			exit(4);
		}

		// Copy .vcf
		while (_varFile) {
			_varFile.read(buf, bufSize);
			out._varFile.write(buf, _varFile.gcount());
		}
		_varFile.close();
		out._varFile.close();
		delete [] buf;
		return;
	}

	// Passed all the tests, proceed to sampling
	string curLine;

	uint64_t nloc = n; // local copy of n
	uint64_t S;
	RanDraw *snpSamp;  // so that I can catch RanDraw constructor exceptions
	try {
		snpSamp = new RanDraw();
	} catch (string error) {
		cerr << "ERROR: " << error << endl;
		exit(5);
	}
	while (nloc) {
		try {
			S = snpSamp->vitter(nloc, N); // sample the number of SNPs to skip
		} catch (string error) {
			cerr << "ERROR: " << error << endl;
			exit(5);
		}
		N -= S + 1;
		while (S) { // skipping S lines in the vcf file
			_varFile.ignore(numeric_limits<streamsize>::max(), '\n');
 			S--;
		}
		getline(_varFile, curLine);
		out._varFile << curLine << endl;
		nloc--;

	}
	_varFile.close();
	out._varFile.close();
	delete snpSamp;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1c773
movq 0xf89d(%rip), %rdi      # 0x2bff0
leaq 0x6e52(%rip), %rsi      # 0x235ac
callq 0x4310
movq %rax, %rdi
movq 0xf847(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1d4c6
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
testb $0x1, %al
jne 0x1c786
jmp 0x1c790
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x178(%rbp), %rdi
callq 0x1c070
movq -0x178(%rbp), %rdi
movq %rax, -0x20(%rbp)
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x180(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq -0x180(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1c7d7
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x181(%rbp)
jmp 0x1c7ef
movb -0x181(%rbp), %al
testb $0x1, %al
jne 0x1c963
jmp 0x1c7ff
movq 0xf7ea(%rip), %rdi      # 0x2bff0
leaq 0x7573(%rip), %rsi      # 0x23d80
callq 0x4310
movq %rax, -0x190(%rbp)
jmp 0x1c81b
movq -0x190(%rbp), %rdi
movq -0x178(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x198(%rbp)
jmp 0x1c83e
movq -0x198(%rbp), %rdi
leaq 0x6d08(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0x1a0(%rbp)
jmp 0x1c85a
movq -0x1a0(%rbp), %rdi
movq 0xf748(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1c86f
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1d4e7
movq -0x28(%rbp), %rdi
callq 0x4130
movq %rax, -0x38(%rbp)
movq 0xf747(%rip), %rdi      # 0x2bff0
leaq 0x74f1(%rip), %rsi      # 0x23da1
callq 0x4310
movq %rax, -0x1a8(%rbp)
jmp 0x1c8be
movq -0x1a8(%rbp), %rdi
movq -0x178(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x1b0(%rbp)
jmp 0x1c8e1
movq -0x1b0(%rbp), %rdi
leaq 0x70f6(%rip), %rsi      # 0x239e5
callq 0x4310
movq %rax, -0x1b8(%rbp)
jmp 0x1c8fd
movq -0x38(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x1eeb0
jmp 0x1c914
movq -0x1b8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x42e0
movq %rax, -0x1c0(%rbp)
jmp 0x1c92d
movq -0x1c0(%rbp), %rdi
movq 0xf68d(%rip), %rsi      # 0x2bfc8
callq 0x4350
jmp 0x1c942
leaq -0x58(%rbp), %rdi
callq 0x46d8
leaq 0x6ea8(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1c959
movl $0x1, %edi
callq 0x4400
jmp 0x1c994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1c988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1c98f
jmp 0x1d4e7
movq -0x10(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x1d8(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq %rax, -0x1d0(%rbp)
movl $0x10, %edi
movl $0x20, %esi
callq 0x1ee70
movl %eax, -0x1c4(%rbp)
jmp 0x1c9d0
movl -0x1c4(%rbp), %edx
movq -0x1d0(%rbp), %rsi
movq -0x1d8(%rbp), %rdi
callq 0x42f0
jmp 0x1c9eb
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x1d9(%rbp)
jmp 0x1ca00
movb -0x1d9(%rbp), %al
testb $0x1, %al
jne 0x1cb6e
jmp 0x1ca10
movq 0xf5d9(%rip), %rdi      # 0x2bff0
leaq 0x7362(%rip), %rsi      # 0x23d80
callq 0x4310
movq %rax, -0x1e8(%rbp)
jmp 0x1ca2c
movq -0x1e8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x1f0(%rbp)
jmp 0x1ca4c
movq -0x1f0(%rbp), %rdi
leaq 0x6c70(%rip), %rsi      # 0x236ca
callq 0x4310
movq %rax, -0x1f8(%rbp)
jmp 0x1ca68
movq -0x1f8(%rbp), %rdi
movq 0xf53a(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1ca7d
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1d4e7
movq -0x28(%rbp), %rdi
callq 0x4130
movq %rax, -0x60(%rbp)
movq 0xf539(%rip), %rdi      # 0x2bff0
leaq 0x72e3(%rip), %rsi      # 0x23da1
callq 0x4310
movq %rax, -0x200(%rbp)
jmp 0x1cacc
movq -0x200(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x208(%rbp)
jmp 0x1caec
movq -0x208(%rbp), %rdi
leaq 0x6bdc(%rip), %rsi      # 0x236d6
callq 0x4310
movq %rax, -0x210(%rbp)
jmp 0x1cb08
movq -0x60(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x1eeb0
jmp 0x1cb1f
movq -0x210(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x42e0
movq %rax, -0x218(%rbp)
jmp 0x1cb38
movq -0x218(%rbp), %rdi
movq 0xf482(%rip), %rsi      # 0x2bfc8
callq 0x4350
jmp 0x1cb4d
leaq -0x80(%rbp), %rdi
callq 0x46d8
leaq 0x6c9d(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1cb64
movl $0x1, %edi
callq 0x4400
jmp 0x1cb9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1cb93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1cb9a
jmp 0x1d4e7
leaq -0xa0(%rbp), %rdi
callq 0x44d0
jmp 0x1cbad
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4080
jmp 0x1cbc6
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x46b0
movq %rax, -0x220(%rbp)
jmp 0x1cbdf
movq -0x220(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x1cdaa
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
callq 0x45f0
movq %rdx, -0x230(%rbp)
movq %rax, -0x228(%rbp)
jmp 0x1cc12
movq -0x230(%rbp), %rax
movq -0x228(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movq %rax, -0xb0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x1ef00
movq %rax, -0x238(%rbp)
jmp 0x1cc43
movq -0x238(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4210
movq %rax, %rcx
movq -0x240(%rbp), %rax
cmpq %rcx, %rax
jae 0x1cd42
movq 0xf36b(%rip), %rdi      # 0x2bff0
leaq 0x718c(%rip), %rsi      # 0x23e18
callq 0x4310
movq %rax, -0x248(%rbp)
jmp 0x1cc9a
movq -0x248(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x40d0
movq %rax, -0x250(%rbp)
jmp 0x1ccb6
movq -0x250(%rbp), %rdi
leaq 0x716e(%rip), %rsi      # 0x23e32
callq 0x4310
movq %rax, -0x258(%rbp)
jmp 0x1ccd2
leaq -0xa0(%rbp), %rdi
callq 0x4210
movq -0x258(%rbp), %rdi
movq %rax, %rsi
callq 0x40d0
movq %rax, -0x260(%rbp)
jmp 0x1ccf6
movq -0x260(%rbp), %rdi
leaq 0x71fa(%rip), %rsi      # 0x23efe
callq 0x4310
movq %rax, -0x268(%rbp)
jmp 0x1cd12
movq -0x268(%rbp), %rdi
movq 0xf290(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1cd27
movl $0x6, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1d4db
movq -0x178(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x278(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x270(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4210
movq %rax, %rsi
movq -0x270(%rbp), %rax
notq %rsi
addq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x1ef20
jmp 0x1cd8c
movq -0x278(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0x4460
jmp 0x1cda8
jmp 0x1cde1
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x42e0
movq %rax, -0x280(%rbp)
jmp 0x1cdc7
movq -0x280(%rbp), %rdi
movq 0xf1db(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1cddc
jmp 0x1cbab
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1ce9f
movq 0xf1f7(%rip), %rdi      # 0x2bff0
leaq 0x67de(%rip), %rsi      # 0x235de
callq 0x4310
movq %rax, -0x288(%rbp)
jmp 0x1ce0e
movq -0x288(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x40d0
movq %rax, -0x290(%rbp)
jmp 0x1ce2a
movq -0x290(%rbp), %rdi
leaq 0x6aa8(%rip), %rsi      # 0x238e0
callq 0x4310
movq %rax, -0x298(%rbp)
jmp 0x1ce46
movq -0x298(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x40d0
movq %rax, -0x2a0(%rbp)
jmp 0x1ce5f
movq -0x2a0(%rbp), %rdi
leaq 0x67bf(%rip), %rsi      # 0x2362c
callq 0x4310
movq %rax, -0x2a8(%rbp)
jmp 0x1ce7b
movq -0x2a8(%rbp), %rdi
movq 0xf127(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1ce90
movl $0x1, -0xcc(%rbp)
jmp 0x1d4ba
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x1d0ef
movq 0xf139(%rip), %rdi      # 0x2bff0
leaq 0x6783(%rip), %rsi      # 0x23641
callq 0x4310
movq %rax, -0x2b0(%rbp)
jmp 0x1cecc
movq -0x2b0(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x40d0
movq %rax, -0x2b8(%rbp)
jmp 0x1cee8
movq -0x2b8(%rbp), %rdi
leaq 0x6a1a(%rip), %rsi      # 0x23910
callq 0x4310
movq %rax, -0x2c0(%rbp)
jmp 0x1cf04
movq -0x2c0(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x40d0
movq %rax, -0x2c8(%rbp)
jmp 0x1cf1d
movq -0x2c8(%rbp), %rdi
leaq 0x6a08(%rip), %rsi      # 0x23933
callq 0x4310
movq %rax, -0x2d0(%rbp)
jmp 0x1cf39
movq -0x2d0(%rbp), %rdi
movq 0xf069(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1cf4e
movq $0xa00000, -0xe0(%rbp) # imm = 0xA00000
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, -0x2d8(%rbp)
jmp 0x1cf6c
movq -0x2d8(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x1cffb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x1d4db
movq -0x28(%rbp), %rdi
callq 0x4130
movq %rax, -0xe8(%rbp)
movq 0xf041(%rip), %rdi      # 0x2bff0
leaq 0x66f3(%rip), %rsi      # 0x236a9
callq 0x4310
movq %rax, -0x2e0(%rbp)
jmp 0x1cfc4
movq -0x2e0(%rbp), %rdi
movq 0xefde(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1cfd9
movl $0x4, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x4580
jmp 0x1cff6
jmp 0x1d4db
jmp 0x1cffd
movq -0x178(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x4440
movb %al, -0x2e1(%rbp)
jmp 0x1d01e
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x1d02a
jmp 0x1d09f
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
movq -0xd8(%rbp), %rsi
movl $0xa00000, %edx         # imm = 0xA00000
callq 0x4450
jmp 0x1d048
movq -0x178(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x300(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x2f8(%rbp)
addq $0x8, %rdi
callq 0x46c0
movq %rax, -0x2f0(%rbp)
jmp 0x1d07e
movq -0x2f0(%rbp), %rdx
movq -0x2f8(%rbp), %rsi
movq -0x300(%rbp), %rdi
callq 0x44a0
jmp 0x1d09a
jmp 0x1cffd
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1d0b1
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1d0c0
movq -0xd8(%rbp), %rax
movq %rax, -0x308(%rbp)
cmpq $0x0, %rax
je 0x1d0e0
movq -0x308(%rbp), %rdi
callq 0x4480
movl $0x1, -0xcc(%rbp)
jmp 0x1d4ba
jmp 0x1d0f1
leaq -0x108(%rbp), %rdi
callq 0x44d0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x110(%rbp)
movl $0x8, %edi
callq 0x4330
movq %rax, -0x310(%rbp)
jmp 0x1d11e
movq -0x310(%rbp), %rdi
callq 0x22380
jmp 0x1d12c
movq -0x310(%rbp), %rax
movq %rax, -0x120(%rbp)
jmp 0x1d222
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1d16a
movq -0x310(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x8, %esi
callq 0x4340
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1d4cf
movq -0x28(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x140(%rbp), %rdi
callq 0x4150
jmp 0x1d19b
movq -0x318(%rbp), %rdi
callq 0x4130
movq 0xee42(%rip), %rdi      # 0x2bff0
leaq 0x6558(%rip), %rsi      # 0x2370d
callq 0x4310
movq %rax, -0x320(%rbp)
jmp 0x1d1c3
movq -0x320(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x42e0
movq %rax, -0x328(%rbp)
jmp 0x1d1df
movq -0x328(%rbp), %rdi
movq 0xedc3(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1d1f4
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1d21d
jmp 0x1d4cf
jmp 0x1d224
cmpq $0x0, -0x110(%rbp)
je 0x1d452
movq -0x120(%rbp), %rdi
movq -0x110(%rbp), %xmm0
movaps 0x6258(%rip), %xmm2     # 0x234a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x625c(%rip), %xmm1     # 0x234b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movsd %xmm0, -0x148(%rbp)
movq -0x20(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
leaq -0x148(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x227a0
movq %rax, -0x330(%rbp)
jmp 0x1d2a7
movq -0x330(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x1d37e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1d4cf
movq -0x28(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x170(%rbp), %rdi
callq 0x4150
jmp 0x1d2f7
movq -0x338(%rbp), %rdi
callq 0x4130
movq 0xece6(%rip), %rdi      # 0x2bff0
leaq 0x63fc(%rip), %rsi      # 0x2370d
callq 0x4310
movq %rax, -0x340(%rbp)
jmp 0x1d31f
movq -0x340(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x42e0
movq %rax, -0x348(%rbp)
jmp 0x1d33b
movq -0x348(%rbp), %rdi
movq 0xec67(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1d350
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1d379
jmp 0x1d4cf
movq -0x118(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x118(%rbp)
je 0x1d3f0
movq -0x178(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x350(%rbp)
callq 0x1f390
movq -0x350(%rbp), %rdi
movq %rax, %rsi
movl $0xa, %edx
callq 0x41f0
jmp 0x1d3cb
movq -0x118(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x1d394
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1d4cf
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
leaq -0x108(%rbp), %rsi
callq 0x4080
jmp 0x1d409
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x108(%rbp), %rsi
callq 0x42e0
movq %rax, -0x358(%rbp)
jmp 0x1d426
movq -0x358(%rbp), %rdi
movq 0xeb7c(%rip), %rsi      # 0x2bfb0
callq 0x4350
jmp 0x1d43b
movq -0x110(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x110(%rbp)
jmp 0x1d224
movq -0x178(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1d464
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1d473
movq -0x120(%rbp), %rax
movq %rax, -0x360(%rbp)
cmpq $0x0, %rax
je 0x1d4a4
movq -0x360(%rbp), %rdi
callq 0x1ef60
movq -0x360(%rbp), %rdi
movl $0x8, %esi
callq 0x4340
leaq -0x108(%rbp), %rdi
callq 0x46d8
movl $0x0, -0xcc(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x46d8
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
leaq -0x108(%rbp), %rdi
callq 0x46d8
leaq -0xa0(%rbp), %rdi
callq 0x46d8
movq -0x28(%rbp), %rdi
callq 0x4610
movq %rax, %rdi
callq 0x82c0
nopl (%rax,%rax)