// File: lucaong[P]elixir_mlx90640/src/MLX90640_API.cpp
// Function: MLX90640_CalculateTo(unsigned short*, paramsMLX90640 const*, float, float, float*)
void MLX90640_CalculateTo(uint16_t *frameData, const paramsMLX90640 *params, float emissivity, float tr, float *result)
{
    float vdd;
    float ta;
    float ta4;
    float tr4;
    float taTr;
    float gain;
    float irDataCP[2];
    float irData;
    float alphaCompensated;
    uint8_t mode;
    int8_t ilPattern;
    int8_t chessPattern;
    int8_t pattern;
    int8_t conversionPattern;
    float Sx;
    float To;
    float alphaCorrR[4];
    int8_t range;
    uint16_t subPage;
    
    subPage = frameData[833];
    vdd = MLX90640_GetVdd(frameData, params);
    ta = MLX90640_GetTa(frameData, params);
    ta4 = pow((ta + 273.15), (double)4);
    tr4 = pow((tr + 273.15), (double)4);
    taTr = tr4 - (tr4-ta4)/emissivity;
    
    alphaCorrR[0] = 1 / (1 + params->ksTo[0] * 40);
    alphaCorrR[1] = 1 ;
    alphaCorrR[2] = (1 + params->ksTo[2] * params->ct[2]);
    alphaCorrR[3] = alphaCorrR[2] * (1 + params->ksTo[3] * (params->ct[3] - params->ct[2]));
    
//------------------------- Gain calculation -----------------------------------    
    gain = frameData[778];
    if(gain > 32767)
    {
        gain = gain - 65536;
    }
    
    gain = params->gainEE / gain; 
  
//------------------------- To calculation -------------------------------------    
    mode = (frameData[832] & 0x1000) >> 5;
    
    irDataCP[0] = frameData[776];  
    irDataCP[1] = frameData[808];
    for( int i = 0; i < 2; i++)
    {
        if(irDataCP[i] > 32767)
        {
            irDataCP[i] = irDataCP[i] - 65536;
        }
        irDataCP[i] = irDataCP[i] * gain;
    }
    irDataCP[0] = irDataCP[0] - params->cpOffset[0] * (1 + params->cpKta * (ta - 25)) * (1 + params->cpKv * (vdd - 3.3));
    if( mode ==  params->calibrationModeEE)
    {
        irDataCP[1] = irDataCP[1] - params->cpOffset[1] * (1 + params->cpKta * (ta - 25)) * (1 + params->cpKv * (vdd - 3.3));
    }
    else
    {
      irDataCP[1] = irDataCP[1] - (params->cpOffset[1] + params->ilChessC[0]) * (1 + params->cpKta * (ta - 25)) * (1 + params->cpKv * (vdd - 3.3));
    }

    for( int pixelNumber = 0; pixelNumber < 768; pixelNumber++)
    {
        ilPattern = pixelNumber / 32 - (pixelNumber / 64) * 2; 
        chessPattern = ilPattern ^ (pixelNumber - (pixelNumber/2)*2); 
        conversionPattern = ((pixelNumber + 2) / 4 - (pixelNumber + 3) / 4 + (pixelNumber + 1) / 4 - pixelNumber / 4) * (1 - 2 * ilPattern);
        
        if(mode == 0)
        {
          pattern = ilPattern; 
        }
        else 
        {
          pattern = chessPattern; 
        }               
        
        if(pattern == frameData[833])
        {    
            irData = frameData[pixelNumber];
            if(irData > 32767)
            {
                irData = irData - 65536;
            }
            irData = irData * gain;
            
            irData = irData - params->offset[pixelNumber]*(1 + params->kta[pixelNumber]*(ta - 25))*(1 + params->kv[pixelNumber]*(vdd - 3.3));
            if(mode !=  params->calibrationModeEE)
            {
              irData = irData + params->ilChessC[2] * (2 * ilPattern - 1) - params->ilChessC[1] * conversionPattern; 
            }
            
            irData = irData / emissivity;
    
            irData = irData - params->tgc * irDataCP[subPage];
            
            alphaCompensated = (params->alpha[pixelNumber] - params->tgc * params->cpAlpha[subPage])*(1 + params->KsTa * (ta - 25));
            
            Sx = pow((double)alphaCompensated, (double)3) * (irData + alphaCompensated * taTr);
            Sx = sqrt(sqrt(Sx)) * params->ksTo[1];
            
            To = sqrt(sqrt(irData/(alphaCompensated * (1 - params->ksTo[1] * 273.15) + Sx) + taTr)) - 273.15;
                    
            if(To < params->ct[1])
            {
                range = 0;
            }
            else if(To < params->ct[2])   
            {
                range = 1;            
            }   
            else if(To < params->ct[3])
            {
                range = 2;            
            }
            else
            {
                range = 3;            
            }      
            
            To = sqrt(sqrt(irData / (alphaCompensated * alphaCorrR[range] * (1 + params->ksTo[range] * (To - params->ct[range]))) + taTr)) - 273.15;
            
            result[pixelNumber] = To;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movss %xmm1, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movw 0x682(%rax), %ax
movw %ax, -0x74(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4710
movss %xmm0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4810
movss %xmm0, -0x28(%rbp)
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x22bb(%rip), %xmm1     # 0x60a0
movsd %xmm1, -0x90(%rbp)
addsd %xmm1, %xmm0
movsd 0x22af(%rip), %xmm1     # 0x60a8
movsd %xmm1, -0x88(%rbp)
callq 0x1110
movsd -0x90(%rbp), %xmm2
movsd -0x88(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm2, %xmm0
callq 0x1110
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm0
movss -0x2c(%rbp), %xmm2
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
movss -0x14(%rbp), %xmm2
divss %xmm2, %xmm1
subss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movss 0x2c(%rax), %xmm1
movss 0x2212(%rip), %xmm0     # 0x6080
mulss %xmm0, %xmm1
movss 0x2196(%rip), %xmm2     # 0x6010
addss %xmm2, %xmm1
movaps %xmm2, %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movl $0x3f800000, -0x6c(%rbp) # imm = 0x3F800000
movq -0x10(%rbp), %rax
movss 0x34(%rax), %xmm0
movswl 0x40(%rax), %eax
cvtsi2ss %eax, %xmm1
mulss %xmm1, %xmm0
addss %xmm2, %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x68(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movss 0x38(%rcx), %xmm1
movswl 0x42(%rcx), %eax
movswl 0x40(%rcx), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x64(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x614(%rax), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movss 0x217f(%rip), %xmm1     # 0x607c
ucomiss %xmm1, %xmm0
jbe 0x3f18
movss -0x38(%rbp), %xmm0
movss 0x2175(%rip), %xmm1     # 0x6084
subss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movswl 0x14(%rax), %eax
cvtsi2ss %eax, %xmm0
movss -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x680(%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
shrl $0x5, %eax
movb %al, -0x49(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x610(%rax), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x650(%rax), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x3c(%rbp)
movl $0x0, -0x78(%rbp)
cmpl $0x2, -0x78(%rbp)
jge 0x3fd8
movslq -0x78(%rbp), %rax
movss -0x40(%rbp,%rax,4), %xmm0
movss 0x20ed(%rip), %xmm1     # 0x607c
ucomiss %xmm1, %xmm0
jbe 0x3fb4
movslq -0x78(%rbp), %rax
movss -0x40(%rbp,%rax,4), %xmm0
movss 0x20de(%rip), %xmm1     # 0x6084
subss %xmm1, %xmm0
movslq -0x78(%rbp), %rax
movss %xmm0, -0x40(%rbp,%rax,4)
movslq -0x78(%rbp), %rax
movss -0x40(%rbp,%rax,4), %xmm0
mulss -0x38(%rbp), %xmm0
movslq -0x78(%rbp), %rax
movss %xmm0, -0x40(%rbp,%rax,4)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x3f77
movss -0x40(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movswl 0x2a4c(%rax), %eax
cvtsi2ss %eax, %xmm0
movq -0x10(%rbp), %rax
movss 0x20(%rax), %xmm2
movss -0x28(%rbp), %xmm3
movss 0x2082(%rip), %xmm4     # 0x6088
subss %xmm4, %xmm3
mulss %xmm3, %xmm2
movss 0x1ffa(%rip), %xmm3     # 0x6010
addss %xmm3, %xmm2
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movss -0x24(%rbp), %xmm3
cvtss2sd %xmm3, %xmm3
movsd 0x2078(%rip), %xmm4     # 0x60b8
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm2
movsd 0x2060(%rip), %xmm3     # 0x60b0
addsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
movzbl -0x49(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl 0x25(%rcx), %ecx
cmpl %ecx, %eax
jne 0x4139
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movswl 0x2a4e(%rax), %eax
cvtsi2ss %eax, %xmm0
movq -0x10(%rbp), %rax
movss 0x20(%rax), %xmm2
movss -0x28(%rbp), %xmm3
movss 0x1fca(%rip), %xmm4     # 0x6088
subss %xmm4, %xmm3
mulss %xmm3, %xmm2
movss 0x1f42(%rip), %xmm3     # 0x6010
addss %xmm3, %xmm2
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movss -0x24(%rbp), %xmm3
cvtss2sd %xmm3, %xmm3
movsd 0x1fc0(%rip), %xmm4     # 0x60b8
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm2
movsd 0x1fa8(%rip), %xmm3     # 0x60b0
addsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
jmp 0x41e9
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movswl 0x2a4e(%rax), %eax
cvtsi2ss %eax, %xmm0
movq -0x10(%rbp), %rax
addss 0x2a50(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x20(%rax), %xmm2
movss -0x28(%rbp), %xmm3
movss 0x1f15(%rip), %xmm4     # 0x6088
subss %xmm4, %xmm3
mulss %xmm3, %xmm2
movss 0x1e8d(%rip), %xmm3     # 0x6010
addss %xmm3, %xmm2
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movss -0x24(%rbp), %xmm3
cvtss2sd %xmm3, %xmm3
movsd 0x1f0b(%rip), %xmm4     # 0x60b8
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm2
movsd 0x1ef3(%rip), %xmm3     # 0x60b0
addsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movl $0x0, -0x7c(%rbp)
cmpl $0x300, -0x7c(%rbp)     # imm = 0x300
jge 0x46f8
movl -0x7c(%rbp), %eax
movl $0x20, %ecx
cltd
idivl %ecx
movl %eax, -0xa4(%rbp)
movl -0x7c(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa4(%rbp), %eax
shll %ecx
subl %ecx, %eax
movb %al, -0x4a(%rbp)
movsbl -0x4a(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x7c(%rbp), %ecx
movl -0x7c(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0xa0(%rbp), %eax
shll %edx
subl %edx, %ecx
xorl %ecx, %eax
movb %al, -0x4b(%rbp)
movl -0x7c(%rbp), %eax
addl $0x2, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0x9c(%rbp)
movl -0x7c(%rbp), %eax
addl $0x3, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x9c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x98(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x98(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x94(%rbp)
movl -0x7c(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x94(%rbp), %eax
subl %ecx, %eax
movsbl -0x4a(%rbp), %edx
shll %edx
movl $0x1, %ecx
subl %edx, %ecx
imull %ecx, %eax
movb %al, -0x4d(%rbp)
movzbl -0x49(%rbp), %eax
cmpl $0x0, %eax
jne 0x42da
movb -0x4a(%rbp), %al
movb %al, -0x4c(%rbp)
jmp 0x42e0
movb -0x4b(%rbp), %al
movb %al, -0x4c(%rbp)
movsbl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0x682(%rcx), %ecx
cmpl %ecx, %eax
jne 0x46e8
movq -0x8(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
movss 0x1d63(%rip), %xmm1     # 0x607c
ucomiss %xmm1, %xmm0
jbe 0x4334
movss -0x44(%rbp), %xmm0
movss 0x1d59(%rip), %xmm1     # 0x6084
subss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movswl 0xc44(%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movss 0x1244(%rax,%rcx,4), %xmm2
movss -0x28(%rbp), %xmm3
movss 0x1d0a(%rip), %xmm4     # 0x6088
subss %xmm4, %xmm3
mulss %xmm3, %xmm2
movss 0x1c82(%rip), %xmm3     # 0x6010
addss %xmm3, %xmm2
mulss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movss 0x1e44(%rax,%rcx,4), %xmm2
cvtss2sd %xmm2, %xmm2
movss -0x24(%rbp), %xmm3
cvtss2sd %xmm3, %xmm3
movsd 0x1cf8(%rip), %xmm4     # 0x60b8
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm2
movsd 0x1ce0(%rip), %xmm3     # 0x60b0
addsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
movzbl -0x49(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl 0x25(%rcx), %ecx
cmpl %ecx, %eax
je 0x4460
movss -0x44(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss 0x2a58(%rax), %xmm1
movsbl -0x4a(%rbp), %eax
shll %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm2
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq -0x10(%rbp), %rax
movss 0x2a54(%rax), %xmm0
movsbl -0x4d(%rbp), %eax
cvtsi2ss %eax, %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
divss -0x14(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm1
movq -0x10(%rbp), %rax
movss 0x18(%rax), %xmm0
movzwl -0x74(%rbp), %eax
movss -0x40(%rbp,%rax,4), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movss 0x44(%rax,%rcx,4), %xmm1
movq -0x10(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movzwl -0x74(%rbp), %ecx
movss 0x2a44(%rax,%rcx,4), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss 0x28(%rax), %xmm1
movss -0x28(%rbp), %xmm2
movss 0x1b94(%rip), %xmm3     # 0x6088
subss %xmm3, %xmm2
mulss %xmm2, %xmm1
movss 0x1b0c(%rip), %xmm2     # 0x6010
addss %xmm2, %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1b9e(%rip), %xmm1     # 0x60c0
callq 0x1110
movss -0x44(%rbp), %xmm2
movss -0x48(%rbp), %xmm1
movss -0x34(%rbp), %xmm3
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
callq 0x5a90
callq 0x5a90
movq -0x10(%rbp), %rax
mulss 0x30(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x44(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x48(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x10(%rbp), %rax
movss 0x30(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
movsd 0x1af6(%rip), %xmm2     # 0x60a0
mulsd %xmm2, %xmm3
movsd 0x1afa(%rip), %xmm2     # 0x60b0
addsd %xmm2, %xmm3
movss -0x54(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movss -0x34(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
callq 0x10b0
callq 0x10b0
movsd 0x1ab2(%rip), %xmm1     # 0x60a0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm1
movq -0x10(%rbp), %rax
movswl 0x3e(%rax), %eax
cvtsi2ss %eax, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x4617
movb $0x0, -0x71(%rbp)
jmp 0x4657
movss -0x58(%rbp), %xmm1
movq -0x10(%rbp), %rax
movswl 0x40(%rax), %eax
cvtsi2ss %eax, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x4633
movb $0x1, -0x71(%rbp)
jmp 0x4655
movss -0x58(%rbp), %xmm1
movq -0x10(%rbp), %rax
movswl 0x42(%rax), %eax
cvtsi2ss %eax, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x464f
movb $0x2, -0x71(%rbp)
jmp 0x4653
movb $0x3, -0x71(%rbp)
jmp 0x4655
jmp 0x4657
movss -0x44(%rbp), %xmm0
movss -0x48(%rbp), %xmm1
movsbq -0x71(%rbp), %rax
mulss -0x70(%rbp,%rax,4), %xmm1
movq -0x10(%rbp), %rax
movsbq -0x71(%rbp), %rcx
movss 0x2c(%rax,%rcx,4), %xmm2
movss -0x58(%rbp), %xmm3
movq -0x10(%rbp), %rax
movsbq -0x71(%rbp), %rcx
movswl 0x3c(%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm4
subss %xmm4, %xmm3
mulss %xmm3, %xmm2
movss 0x196e(%rip), %xmm3     # 0x6010
addss %xmm3, %xmm2
mulss %xmm2, %xmm1
divss %xmm1, %xmm0
addss -0x34(%rbp), %xmm0
callq 0x5a90
callq 0x5a90
cvtss2sd %xmm0, %xmm0
movsd 0x19d7(%rip), %xmm1     # 0x60a0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x46ea
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x41f0
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)