// File: kebwi[P]Trifid/src/ImageProcs.cpp
// Function: addSensorNoiseWithAutoISO(Image3ChnlReal&, bool, NoiseParam)
void addSensorNoiseWithAutoISO(Image3ChnlReal &rgbImage, bool applyBayer, NoiseParam noiseParams)
{
	cout << "Adding color sensor noise with autoISO..." << endl;
	
	//Check to see if the image is normalized
	int totalPixels = rgbImage.totalPixels();
	Float_t maxVal = 0;
	for (int c = 0; c < 3; c++)
		for (int i = 0; i < totalPixels; i++)
		{
			assert((*rgbImage[c])[i] >= 0 && (*rgbImage[c])[i] <= 1.0);
			if ((*rgbImage[c])[i] > maxVal)
				maxVal = (*rgbImage[c])[i];
		}
	if (maxVal != 1.0)
		cout << "  ***  NOTE  ***  This input image is not normalized yet" << endl;
	
	cout << "Performing auto-ISO search for proper amplifier gain to achieve good saturation..." << endl;
	
	//Perform "auto-ISO" by altering the amplifier gain until image saturation is achieved which matches the input image.
	//This is not how a digital camera would perform auto-ISO (there is no "input image").
	//A real camera would aim for some rational indication of good saturation,
	//e.g., a mean pixel value of X some fraction of 1.0, or perhaps some ratio Y of clipped pixels to total pixels, something like that.
	//Using the input image as the target saturation ensures that all output images have the same saturation and that they correspond to the input image,
	//which then enables subsequent comparisons across a set of images (PSNR, Lab Delta E, etc.).
	Float_t nonOutlierMeanPixelValOri = calcNonoutlierMeanPixelValue(rgbImage, 3);
	cout << "  Input image mean intensity (auto-gain target intensity): " << nonOutlierMeanPixelValOri << endl << endl;
	Image3ChnlReal rgbImageOri = rgbImage;
	Float_t maxPPFD = luxToPPFD(noiseParams.lux_, 0, noiseParams.focalRatio_, noiseParams.pixelPitchMicrons_, noiseParams.fullWellCapacity_);
	noiseParams.ampGain_ = noiseParams.fullWellCapacity_ / (maxPPFD * noiseParams.exposureSecs_);
	Float_t stepSize = noiseParams.ampGain_ * .5;	//Beginning of binary search (well, approximately a binary search at any rate)
	vector<pair<Float_t, Float_t> > ampGainHistory;
	Float_t nonOutlierMeanPixelVal = 0;
	int lastStepDir = 0;
	while (true)
	{
		cout << endl << "--------------------------------------------------------------------------------" << endl;
		
		int historyIdx = 0;
		for (historyIdx = 0; historyIdx < ampGainHistory.size(); historyIdx++)
			if (ampGainHistory[historyIdx].first == noiseParams.ampGain_)
				break;
		
		int numSaturatedPixels = totalPixels;
		if (historyIdx == ampGainHistory.size())
		{
			//Restore the original image
			rgbImage = rgbImageOri;
			
			//Noisify the image
			cout << endl << setw(40) << left << "  Noisifying with ags: " << noiseParams.ampGain_ << endl;
			for (int c = 0; c < 3; c++)
				addSensorNoise(*rgbImage[c], applyBayer, noiseParams);
			
			//Determine the saturation
			nonOutlierMeanPixelVal = calcNonoutlierMeanPixelValue(rgbImage, 3);
			cout << endl << "    nonOutlierMeanPixelVal: " << nonOutlierMeanPixelVal << endl;
		}
		else	//This amp gain has already been tried
		{
			maxVal = ampGainHistory[historyIdx].second;
			cout << "  Already tried amp gain " << noiseParams.ampGain_ << ".  maxVal = " << maxVal << endl;
		}
		
		if (nonOutlierMeanPixelVal >= nonOutlierMeanPixelValOri - kAutoGainConvergence
			&& nonOutlierMeanPixelVal <= nonOutlierMeanPixelValOri + kAutoGainConvergence)	//Acceptable saturation
		{
			assert(historyIdx == ampGainHistory.size());
			cout << "    Good saturation achieved" << endl;
			break;
		}
		
		if (stepSize < .001)
		{
			cout << "Bailing on binary search, step size is too small." << endl;
			break;
		}
		
		ampGainHistory.push_back(pair<Float_t, Float_t>(noiseParams.ampGain_, maxVal));
		
		//cout << "    lastStepDir:" << setw(21) << lastStepDir << endl;
		if (nonOutlierMeanPixelVal < nonOutlierMeanPixelValOri - kAutoGainConvergence)	//Increase gain
		{
			if (lastStepDir == -1)
				stepSize *= .5;
			//cout << "    Increasing ags from " << setw(13) << ampGainScalar;
			noiseParams.ampGain_ += stepSize;
			lastStepDir = 1;
			//cout << " to " << setw(10) << ampGainScalar << " with ss " << setw(10) << stepSize << endl;
		}
		else	//Decrease gain
		{
			if (lastStepDir == 1)
				stepSize *= .5;
			//cout << "    Decreasing ags from " << setw(13) << ampGainScalar;
			noiseParams.ampGain_ -= stepSize;
			if (noiseParams.ampGain_ < 1)
			{
				noiseParams.ampGain_ = 1;
				cout << "Bailing on binary search, auto-gain descended below 1.0." << endl;
				break;
			}
			lastStepDir = -1;
			//cout << " to " << setw(10) << ampGainScalar << " with ss " << setw(10) << stepSize << endl;
		}
		//cout << "    lastStepDir:" << setw(21) << lastStepDir << endl;
		
		assert(noiseParams.ampGain_ >= 1);//0);
	}
	
	cout << "Final ags: " << noiseParams.ampGain_ << endl;
	
	rgbImage.appendFilename("_n-");
	rgbImage.appendFilename(noiseParams.label_);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdx, -0x1c8(%rbp)
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq 0x36757(%rip), %rdi     # 0x59fd0
leaq 0x2814c(%rip), %rsi     # 0x4b9cc
callq 0x4390
movq %rax, %rdi
movq 0x36729(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq -0x8(%rbp), %rdi
callq 0xf200
movl %eax, -0x1c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x3, -0x2c(%rbp)
jge 0x239b3
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x239a3
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0xef40
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0xef70
movsd (%rax), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x1c9(%rbp)
jb 0x23924
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0xef40
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0xef70
movsd 0x25709(%rip), %xmm0    # 0x49020
ucomisd (%rax), %xmm0
setae %al
movb %al, -0x1c9(%rbp)
movb -0x1c9(%rbp), %al
testb $0x1, %al
jne 0x23930
jmp 0x23932
jmp 0x23951
leaq 0x28028(%rip), %rdi     # 0x4b961
leaq 0x273f1(%rip), %rsi     # 0x4ad31
movl $0x48d, %edx            # imm = 0x48D
leaq 0x280aa(%rip), %rcx     # 0x4b9f6
callq 0x4240
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0xef40
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0xef70
movsd (%rax), %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x23993
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0xef40
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0xef70
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x23995
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x238c0
jmp 0x239a5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x238af
movsd -0x28(%rbp), %xmm0
movsd 0x25660(%rip), %xmm1    # 0x49020
ucomisd %xmm1, %xmm0
jne 0x239ca
jp 0x239ca
jmp 0x239ec
movq 0x365ff(%rip), %rdi     # 0x59fd0
leaq 0x27d5e(%rip), %rsi     # 0x4b736
callq 0x4390
movq %rax, %rdi
movq 0x365d1(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq 0x365dd(%rip), %rdi     # 0x59fd0
movq %rdi, -0x1e8(%rbp)
leaq 0x27d6e(%rip), %rsi     # 0x4b76f
callq 0x4390
movq %rax, %rdi
movq 0x365a8(%rip), %rsi     # 0x59fb8
movq %rsi, -0x1e0(%rbp)
callq 0x43d0
movq -0x8(%rbp), %rdi
movsd 0x272f0(%rip), %xmm0    # 0x4ad18
callq 0x1fcc0
movq -0x1e8(%rbp), %rdi
movsd %xmm0, -0x38(%rbp)
leaq 0x27d82(%rip), %rsi     # 0x4b7c2
callq 0x4390
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x4670
movq -0x1e0(%rbp), %rsi
movq %rax, %rdi
callq 0x43d0
movq -0x1e0(%rbp), %rsi
movq %rax, %rdi
callq 0x43d0
movq -0x8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x17170
movq -0x1c8(%rbp), %rax
movsd 0xa8(%rax), %xmm2
movsd 0x20(%rax), %xmm0
movsd 0x40(%rax), %xmm3
movq 0x48(%rax), %xmm4
movaps 0x255ab(%rip), %xmm1    # 0x49050
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
movapd 0x255af(%rip), %xmm1    # 0x49060
subpd %xmm1, %xmm4
movaps %xmm4, %xmm1
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
addsd %xmm1, %xmm4
xorps %xmm1, %xmm1
callq 0x1ff20
movsd %xmm0, -0x1d8(%rbp)
jmp 0x23ad2
movq -0x1c8(%rbp), %rax
movsd -0x1d8(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movq 0x48(%rax), %xmm0
movaps 0x2555b(%rip), %xmm1    # 0x49050
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2555f(%rip), %xmm1    # 0x49060
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x90(%rbp), %xmm1
mulsd 0x98(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xa0(%rax)
movsd 0x254dc(%rip), %xmm0    # 0x49010
mulsd 0xa0(%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x25a20
xorps %xmm0, %xmm0
movsd %xmm0, -0xc8(%rbp)
movl $0x0, -0xcc(%rbp)
jmp 0x23b67
movq 0x36462(%rip), %rdi     # 0x59fd0
movq 0x36443(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq %rax, -0x1f0(%rbp)
jmp 0x23b83
movq -0x1f0(%rbp), %rdi
leaq 0x27c6d(%rip), %rsi     # 0x4b7fe
callq 0x4390
movq %rax, -0x1f8(%rbp)
jmp 0x23b9f
movq -0x1f8(%rbp), %rdi
movq 0x3640b(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x23bb4
movl $0x0, -0xd0(%rbp)
movl $0x0, -0xd0(%rbp)
movslq -0xd0(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x25a40
movq %rax, %rcx
movq -0x200(%rbp), %rax
cmpq %rcx, %rax
jae 0x23c64
movslq -0xd0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x25a60
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0xa0(%rax), %xmm0
jne 0x23c4e
jp 0x23c4e
jmp 0x23c64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x242f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x242e9
jmp 0x23c50
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x23bc8
movl -0x1c(%rbp), %eax
movl %eax, -0xd4(%rbp)
movslq -0xd0(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x25a40
movq %rax, %rcx
movq -0x208(%rbp), %rax
cmpq %rcx, %rax
jne 0x23ebd
movq -0x8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x17300
jmp 0x23cac
movq 0x3631d(%rip), %rdi     # 0x59fd0
movq 0x362fe(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq %rax, -0x210(%rbp)
jmp 0x23cc8
movl $0x28, %edi
callq 0xe410
movl %eax, -0x214(%rbp)
jmp 0x23cda
movq -0x210(%rbp), %rdi
movl -0x214(%rbp), %eax
movl %eax, -0xd8(%rbp)
movl -0xd8(%rbp), %esi
callq 0x4430
movq %rax, -0x220(%rbp)
jmp 0x23d01
movq -0x220(%rbp), %rdi
leaq -0x158df(%rip), %rsi    # 0xe430
callq 0x4110
movq %rax, -0x228(%rbp)
jmp 0x23d1d
movq -0x228(%rbp), %rdi
leaq 0x27b24(%rip), %rsi     # 0x4b84f
callq 0x4390
movq %rax, -0x230(%rbp)
jmp 0x23d39
movq -0x230(%rbp), %rdi
movq -0x1c8(%rbp), %rax
movsd 0xa0(%rax), %xmm0
callq 0x4670
movq %rax, -0x238(%rbp)
jmp 0x23d5d
movq -0x238(%rbp), %rdi
movq 0x3624d(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x23d72
movl $0x0, -0xdc(%rbp)
cmpl $0x3, -0xdc(%rbp)
jge 0x23e23
movq -0x8(%rbp), %rdi
movl -0xdc(%rbp), %esi
callq 0xef40
movq %rax, -0x240(%rbp)
jmp 0x23da1
movq -0x1c8(%rbp), %rsi
movb -0x9(%rbp), %al
movb %al, -0x241(%rbp)
leaq -0x190(%rbp), %rdi
callq 0xec90
jmp 0x23dbf
movq -0x240(%rbp), %rdi
movb -0x241(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x190(%rbp), %rdx
callq 0x203e0
jmp 0x23de0
leaq -0x190(%rbp), %rdi
callq 0xe3d0
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0x23d7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0xe3d0
jmp 0x242e9
movq -0x8(%rbp), %rdi
movsd 0x26ee9(%rip), %xmm0    # 0x4ad18
callq 0x1fcc0
movsd %xmm0, -0x250(%rbp)
jmp 0x23e3e
movsd -0x250(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq 0x3617b(%rip), %rdi     # 0x59fd0
movq 0x3615c(%rip), %rsi     # 0x59fb8
callq 0x43d0
movq %rax, -0x258(%rbp)
jmp 0x23e6a
movq -0x258(%rbp), %rdi
leaq 0x279ef(%rip), %rsi     # 0x4b867
callq 0x4390
movq %rax, -0x260(%rbp)
jmp 0x23e86
movq -0x260(%rbp), %rdi
movsd -0xc8(%rbp), %xmm0
callq 0x4670
movq %rax, -0x268(%rbp)
jmp 0x23ea3
movq -0x268(%rbp), %rdi
movq 0x36107(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x23eb8
jmp 0x23f67
movslq -0xd0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x25a60
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq 0x360ef(%rip), %rdi     # 0x59fd0
leaq 0x2799c(%rip), %rsi     # 0x4b884
callq 0x4390
movq %rax, -0x270(%rbp)
jmp 0x23ef6
movq -0x270(%rbp), %rdi
movq -0x1c8(%rbp), %rax
movsd 0xa0(%rax), %xmm0
callq 0x4670
movq %rax, -0x278(%rbp)
jmp 0x23f1a
movq -0x278(%rbp), %rdi
leaq 0x27976(%rip), %rsi     # 0x4b89e
callq 0x4390
movq %rax, -0x280(%rbp)
jmp 0x23f36
movq -0x280(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
callq 0x4670
movq %rax, -0x288(%rbp)
jmp 0x23f50
movq -0x288(%rbp), %rdi
movq 0x3605a(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x23f65
jmp 0x23f67
movsd -0xc8(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd 0x26d14(%rip), %xmm2    # 0x4ac90
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x24029
movsd -0xc8(%rbp), %xmm1
movsd 0x26cf6(%rip), %xmm0    # 0x4ac90
addsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x24029
movslq -0xd0(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x25a40
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
jne 0x23fd4
jmp 0x23ff3
leaq 0x278d0(%rip), %rdi     # 0x4b8ab
leaq 0x26d4f(%rip), %rsi     # 0x4ad31
movl $0x4c6, %edx            # imm = 0x4C6
leaq 0x27a08(%rip), %rcx     # 0x4b9f6
callq 0x4240
movq 0x35fd6(%rip), %rdi     # 0x59fd0
leaq 0x278ce(%rip), %rsi     # 0x4b8cf
callq 0x4390
movq %rax, -0x298(%rbp)
jmp 0x2400f
movq -0x298(%rbp), %rdi
movq 0x35f9b(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x24024
jmp 0x24202
movsd 0x26c5f(%rip), %xmm0    # 0x4ac90
ucomisd -0xa8(%rbp), %xmm0
jbe 0x24071
movq 0x35f8e(%rip), %rdi     # 0x59fd0
leaq 0x278a3(%rip), %rsi     # 0x4b8ec
callq 0x4390
movq %rax, -0x2a0(%rbp)
jmp 0x24057
movq -0x2a0(%rbp), %rdi
movq 0x35f53(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x2406c
jmp 0x24202
movq -0x1c8(%rbp), %rsi
addq $0xa0, %rsi
leaq -0x1a0(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x25ab0
jmp 0x24091
leaq -0xc0(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x25a80
jmp 0x240a6
movsd -0xc8(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
movsd 0x26bd5(%rip), %xmm2    # 0x4ac90
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x24114
cmpl $-0x1, -0xcc(%rbp)
jne 0x240e6
movsd 0x24f3a(%rip), %xmm0    # 0x49010
mulsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x1c8(%rbp), %rax
movsd -0xa8(%rbp), %xmm0
addsd 0xa0(%rax), %xmm0
movsd %xmm0, 0xa0(%rax)
movl $0x1, -0xcc(%rbp)
jmp 0x241bf
cmpl $0x1, -0xcc(%rbp)
jne 0x24135
movsd 0x24eeb(%rip), %xmm0    # 0x49010
mulsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x1c8(%rbp), %rax
movsd -0xa8(%rbp), %xmm1
movsd 0xa0(%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0xa0(%rax)
movsd 0x24ec0(%rip), %xmm0    # 0x49020
ucomisd 0xa0(%rax), %xmm0
jbe 0x241b5
movq -0x1c8(%rbp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, 0xa0(%rax)
movq 0x35e47(%rip), %rdi     # 0x59fd0
leaq 0x278a9(%rip), %rsi     # 0x4ba39
callq 0x4390
movq %rax, -0x2a8(%rbp)
jmp 0x2419e
movq -0x2a8(%rbp), %rdi
movq 0x35e0c(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x241b3
jmp 0x24202
movl $0xffffffff, -0xcc(%rbp) # imm = 0xFFFFFFFF
movq -0x1c8(%rbp), %rax
movsd 0xa0(%rax), %xmm0
movsd 0x24e4a(%rip), %xmm1    # 0x49020
ucomisd %xmm1, %xmm0
jb 0x241de
jmp 0x241fd
leaq 0x27739(%rip), %rdi     # 0x4b91e
leaq 0x26b45(%rip), %rsi     # 0x4ad31
movl $0x4ee, %edx            # imm = 0x4EE
leaq 0x277fe(%rip), %rcx     # 0x4b9f6
callq 0x4240
jmp 0x23b65
movq 0x35dc7(%rip), %rdi     # 0x59fd0
leaq 0x27728(%rip), %rsi     # 0x4b938
callq 0x4390
movq %rax, -0x2b0(%rbp)
jmp 0x2421e
movq -0x2b0(%rbp), %rdi
movq -0x1c8(%rbp), %rax
movsd 0xa0(%rax), %xmm0
callq 0x4670
movq %rax, -0x2b8(%rbp)
jmp 0x24242
movq -0x2b8(%rbp), %rdi
movq 0x35d68(%rip), %rsi     # 0x59fb8
callq 0x43d0
jmp 0x24257
movq -0x8(%rbp), %rdi
leaq 0x273d5(%rip), %rsi     # 0x4b637
callq 0xf220
jmp 0x24269
movq -0x1c8(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x4180
jmp 0x24289
movq -0x2c0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x154f0
jmp 0x2429e
leaq -0x1c0(%rbp), %rdi
callq 0x46c8
leaq -0xc0(%rbp), %rdi
callq 0x25ae0
leaq -0x88(%rbp), %rdi
callq 0x175b0
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x46c8
leaq -0xc0(%rbp), %rdi
callq 0x25ae0
leaq -0x88(%rbp), %rdi
callq 0x175b0
movq -0x98(%rbp), %rdi
callq 0x4620
nopl (%rax)