// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: luxToPPFD(double, double, double, double, double)
Float_t luxToPPFD(
	Float_t lux,
	Float_t lensFocalLength,	//Unused in the current PPFD calculation, remnant of an earlier version
	Float_t lensFnumber,
	Float_t pixelPitchMicrons,
	Float_t fullWellCapacity
)
{
	cout.precision(15);
	
	cout << setw(40) << left << "  lux:" << lux << endl;
	Float_t luxAfterLensTransmission = lux * .9;
	cout << setw(40) << left << "  luxAfterLensTransmission:" << luxAfterLensTransmission << endl;
	cout << setw(40) << left << "  lensFnumber:" << lensFnumber << endl;
	Float_t luxAtImagePlane = luxAfterLensTransmission / pow(lensFnumber, 2);
	cout << setw(40) << left << "  luxAtImagePlane:" << luxAtImagePlane << endl;
	Float_t photoSensitivePixelPitchMicrons = pixelPitchMicrons - .25;	// half of a .5u width dead zone between pixels
	cout << setw(40) << left << "  photoSensitivePixelPitchMicrons:" << photoSensitivePixelPitchMicrons << endl;
	Float_t photoSensitivePixelAreaM = pow((photoSensitivePixelPitchMicrons / 1000000), 2);
	cout << setw(40) << left << "  photoSensitivePixelAreaM:" << photoSensitivePixelAreaM << endl;
	Float_t lumensPerPixel = luxAtImagePlane * photoSensitivePixelAreaM;
	cout << setw(40) << left << "  lumensPerPixel:" << lumensPerPixel << endl;
	Float_t ppfdPerPixel = lumensPerPixel * .0185;
	cout << setw(40) << left << "  ppfdPerPixel:" << ppfdPerPixel << endl;
	Float_t photonsPerPixelPerSec = ppfdPerPixel * 6.0221415e17;
	cout << setw(40) << left << "  photonsPerPixelPerSec:" << photonsPerPixelPerSec << endl;
	
	Float_t saturationTime = fullWellCapacity / photonsPerPixelPerSec;
	cout << setw(40) << left << "  saturationTime at 100% reflectance:" << saturationTime << endl;
	
	cout.precision(6);
	return photonsPerPixelPerSec;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movsd %xmm4, 0x18(%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x233a0(%rip), %rbx     # 0x36fd0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x8(%rbx,%rcx)
movq -0x18(%rax), %rcx
movl $0x28, %r15d
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl $0xffffff4f, %ebp       # imm = 0xFFFFFF4F
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x192d2(%rip), %rsi     # 0x2cf3e
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x10(%rsp), %xmm0
mulsd 0x18f61(%rip), %xmm0    # 0x2cc20
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1925c(%rip), %rsi     # 0x2cf45
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1920f(%rip), %rsi     # 0x2cf61
movl $0xe, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x20(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x1919b(%rip), %rsi     # 0x2cf70
movl $0x12, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
addsd 0x18e00(%rip), %xmm0    # 0x2cc28
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x19131(%rip), %rsi     # 0x2cf83
movl $0x22, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
divsd 0x18d8b(%rip), %xmm0    # 0x2cc30
mulsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x190d3(%rip), %rsi     # 0x2cfa6
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x19074(%rip), %rsi     # 0x2cfc2
movl $0x11, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x18c97(%rip), %xmm0    # 0x2cc38
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x19009(%rip), %rsi     # 0x2cfd4
movl $0xf, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x8(%rsp), %xmm0
mulsd 0x18c22(%rip), %xmm0    # 0x2cc40
movsd %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl %ebp, %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%rbx,%rax)
leaq 0x18f9c(%rip), %rsi     # 0x2cfe4
movl $0x18, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movsd 0x18(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq %r15, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
andl 0x18(%rbx,%rax), %ebp
orl $0x20, %ebp
movl %ebp, 0x18(%rbx,%rax)
leaq 0x18f3c(%rip), %rsi     # 0x2cffd
movl $0x25, %edx
movq %rbx, %rdi
callq 0x3360
movq %rbx, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x3480
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x8(%rbx,%rax)
movsd 0x8(%rsp), %xmm0
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq