// File: Eba-M[P]E3DC-Control/awattar.cpp
// Function: openmeteo(std::vector<watt_s, std::allocator<watt_s>>&, std::vector<wetter_s, std::allocator<wetter_s>>&, e3dc_config_t&, int, unsigned int*)
void openmeteo(std::vector<watt_s> &w,std::vector<wetter_s>  &wetter, e3dc_config_t &e3dc,int anlage,u_int32_t iDayStat[25*4*2+1])
{
    FILE * fp;
    char line[1024];
    char path [65000];
    char value[25];
    char var[25];
    char var2[25];

    int x1 = 0;
    int x2 = 0;
    int x3 = 10; // 10kWp
    if (w.size()==0)
    {
        printf("keine Börsenpreise");
        return;
    }
    if (wetter.size()==0) 
    {
        printf("keine Wetterdaten");
        return;
    }
    int len = strlen(e3dc.Forecast[anlage]);
    
    if (anlage >=0)
    {
        if (len>sizeof(line)||len==0)
        {
            //            printf("forecast #%i kann nicht verarbeitet werden ",anlage+1);
            if (anlage >0)
            return;
        }
        else
        {
            memcpy(&line,&e3dc.Forecast[anlage],len);
            memset(var, 0, sizeof(var));
            memset(var2, 0, sizeof(var2));
            memset(value, 0, sizeof(value));
            for(int j = 0;j<len&&x1==0;j++)
            {
                if (line[j]=='/') x1=j;
            }
            x2=0;
            for(int j=x1+1;j<len&&x2==0;j++)
            {
                if (line[j]=='/') x2=j;
            }
            if (x1>0&&x2-x1-1>0&&len-x2-1>0)
            {
                memcpy(&var,&line[0],x1);
                memcpy(&var2,&line[x1+1],x2-x1-1);
                memcpy(&value,&line[x2+1],len-x2-1);
            }
            else
                return;
            x1 = atoi(var);
            x2 = atoi(var2);
            x3 = atoi(value);
        }
    }

   if (x3>0)
      {
          if (e3dc.debug)
              printf("om.1\n");
          sprintf(line,"curl -s -X GET 'https://api.open-meteo.com/v1/forecast?latitude=%f&longitude=%f&minutely_15=global_tilted_irradiance_instant&timeformat=unixtime&forecast_minutely_15=192&tilt=%i&azimuth=%i'",e3dc.hoehe,e3dc.laenge,x1,x2);

          fp = NULL;
          fp = popen(line, "r");
          int fd = fileno(fp);
          int flags = fcntl(fd, F_GETFL, 0);
          flags |= O_NONBLOCK;
          fcntl(fd, F_SETFL, flags);
          fp_status = 2;

        int timeout = 0;
          if (e3dc.debug)
              printf("om.2\n");
          if (fp != NULL)
          while (fgets(path, sizeof(path), fp) == NULL&&timeout < 30)
        {
            sleep(1);
            timeout++;
        }
          if (e3dc.debug)
              printf("om%i.3\n",timeout);

          if (timeout >= 30)
          {
              if (fp!=NULL) pclose(fp);
              return;
          }
        {
            const cJSON *item = NULL;
            const cJSON *item1 = NULL;
            const cJSON *item2 = NULL;

            std::string feld;
            cJSON *wolf_json = cJSON_Parse(path);
            feld = "minutely_15";
            char * c = &feld[0];
            item = cJSON_GetObjectItemCaseSensitive(wolf_json, c );
            feld = "time";
            item1 = cJSON_GetObjectItemCaseSensitive(item, c );
            feld = "global_tilted_irradiance_instant";
            c = &feld[0];
            item2 = cJSON_GetObjectItemCaseSensitive(item, c );
            if (item1!=NULL)
            item1 = item1->child;
            if (item1!=NULL)
            item2 = item2->child;
            int x1 = 0;
            int x2 = 0;
            if (e3dc.debug)
                printf("om.4\n");
            while (item1!=NULL)
            {
                if (w.size()>0)
//                while (w[x1].hh < item1->valueint&&x1<w.size())
//                    x1++;
                while (x2<wetter.size()-1&&wetter[x2].hh < item1->valueint)  // um 15min verschieben
//                while (x2<wetter.size()-1&&wetter[x2].hh < item1->valueint-900)  // um 15min verschieben
                    x2++;
                if (x2 >= wetter.size()-1)
                    break;
                if (wetter[x2].hh == item1->valueint)
//                    if (wetter[x2].hh == item1->valueint-900)
                {
                    // index 200 heutiger Ertrag 15min
                    // index 199 heutige Prognose kumuliert
                    // Index 198 heutiger Ertrag kumuliert

                    int y1 = wetter[x2].hh%(24*3600)/900;
                    float f2 = iDayStat[y1]/100.0;  // Soll
                    float f3 = iDayStat[y1+96]/(e3dc.speichergroesse*10*3600);  //Ist
                    // aktuelle PV-Leistung ermitteln aus Prog
                    float f4 = (iDayStat[199]) * e3dc.speichergroesse/10000.0;
                    float f5 = iDayStat[198]/3600.0/1000.0;
                    float f6 = 1;
//                    if (f4>1&&f5>0&&(wetter[x2].hh-wetter[0].hh)<12*3600) // erst nach der ersten kWh
                        if (f4>1&&f5>0) // erst nach der ersten kWh
                        f6 = f5/f4;
                    if (f6<0.1) f6 = 0.1;  // schneebedeckte Module?
                    if (f6>10) f6 = 10;
                    float f7 = 0;
//                    if (iDayStat[y1]>0&&f2>f3)
                    if (f2>0.1)
                        f7 = f3/f2;
// absoluter Ertrag des letzen 15min
                    float f8 = iDayStat[197] /(e3dc.speichergroesse*10*3600);
                    f8 = f8 * (10 - x2)/10;
                    
                    // relativer ertrag aus statistik höher als aktueller ertrag
                    if (f4 > 1&&x2<10)
                        f6 = (f7*(x2+1)+(10-x2)*f6)/(11);
                    else
                        if (f7>0)
                            f6=f7;
//                    if (x2<10)
//                    f6 = (f6*(x2)+f8*(10-x2))/10;

                    if (anlage==0){
                        wetter[x2].progsolar = item2->valuedouble*x3/4/e3dc.speichergroesse/10;
                        
                            wetter[x2].solar = wetter[x2].progsolar*f6;

                        // (15min Intervall daher /4
                    }
                    else {
                            wetter[x2].progsolar = wetter[x2].progsolar+item2->valuedouble*x3/4/e3dc.speichergroesse/10;
                            wetter[x2].solar = wetter[x2].progsolar*f6;

                    }
                    int hh = wetter[x2].hh-wetter[0].hh;
                    if (wetter[x2].solar<f8&&wetter[x2].progsolar*f6>f8
                        &&
                        (wetter[x2].hh-wetter[0].hh)<12*3600)    // 12h
                            (wetter[x2].solar=(2*f8+wetter[x2].progsolar*f6)/3);
                    else
                        if (wetter[x2].solar<f8&&wetter[x2].progsolar*f6>f8
                            &&
                            (wetter[x2].hh-wetter[0].hh)<12*3600)    // 12h
                                (wetter[x2].solar=(1*f8+wetter[x2].progsolar*f6)/2);
                        else
                            if (wetter[x2].solar<f8&&wetter[x2].progsolar*f6<f8
                                && (wetter[x2].progsolar > 1) &&
                                (wetter[x2].hh-wetter[0].hh)<12*3600)    // 12h
                                    (wetter[x2].solar=(wetter[x2].progsolar*f6+f8)/2);
                            else
                        wetter[x2].solar = wetter[x2].progsolar*f6;
                    if (x2=1&&wetter[0].solar==0&&wetter[0].progsolar==0)
                    {
                        wetter[0].solar = wetter[1].solar;
                        wetter[0].progsolar = wetter[1].progsolar;
                    }
                    x1++;
                    x2++;
                    if (x2 > wetter.size())
                    {                        
                        if (e3dc.debug)
                            printf("om.bfc\n");
                        if (fp!=NULL) pclose(fp);
                        if (e3dc.debug)
                        printf("om.afc\n");
                        return;
                    }
                }
                item1 = item1->next;
                item2 = item2->next;

            }
            if (e3dc.debug)
                printf("om.bfc\n");
            if (fp!=NULL) pclose(fp);
            if (e3dc.debug)
            printf("om.afc\n");
            return;
        }
    }
    if (e3dc.debug)
        printf("om.5");
    return;
}

// Assembly:
subq $0x103f8, %rsp          # imm = 0x103F8
movq %rdi, 0x103f0(%rsp)
movq %rsi, 0x103e8(%rsp)
movq %rdx, 0x103e0(%rsp)
movl %ecx, 0x103dc(%rsp)
movq %r8, 0x103d0(%rsp)
movl $0x0, 0x16c(%rsp)
movl $0x0, 0x168(%rsp)
movl $0xa, 0x164(%rsp)
movq 0x103f0(%rsp), %rdi
callq 0x1ce80
cmpq $0x0, %rax
jne 0x464c5
leaq 0x1bdc3(%rip), %rdi     # 0x6227c
movb $0x0, %al
callq 0x2040
jmp 0x47852
movq 0x103e8(%rsp), %rdi
callq 0x1cc80
cmpq $0x0, %rax
jne 0x464eb
leaq 0x1bdb1(%rip), %rdi     # 0x62290
movb $0x0, %al
callq 0x2040
jmp 0x47852
movq 0x103e0(%rsp), %rdi
addq $0x664, %rdi            # imm = 0x664
movslq 0x103dc(%rsp), %rax
imulq $0x14, %rax, %rax
addq %rax, %rdi
callq 0x2130
movl %eax, 0x160(%rsp)
cmpl $0x0, 0x103dc(%rsp)
jl 0x467db
movslq 0x160(%rsp), %rax
cmpq $0x400, %rax            # imm = 0x400
ja 0x4653d
cmpl $0x0, 0x160(%rsp)
jne 0x46551
cmpl $0x0, 0x103dc(%rsp)
jle 0x4654c
jmp 0x47852
jmp 0x467d9
movq 0x103e0(%rsp), %rsi
addq $0x664, %rsi            # imm = 0x664
movslq 0x103dc(%rsp), %rax
imulq $0x14, %rax, %rax
addq %rax, %rsi
movslq 0x160(%rsp), %rdx
leaq 0xffc0(%rsp), %rdi
callq 0x2220
leaq 0x190(%rsp), %rdi
xorl %esi, %esi
movl $0x19, %edx
callq 0x2170
leaq 0x170(%rsp), %rdi
xorl %esi, %esi
movl $0x19, %edx
callq 0x2170
leaq 0x1b0(%rsp), %rdi
xorl %esi, %esi
movl $0x19, %edx
callq 0x2170
movl $0x0, 0x15c(%rsp)
movl 0x15c(%rsp), %ecx
xorl %eax, %eax
cmpl 0x160(%rsp), %ecx
movb %al, 0xbf(%rsp)
jge 0x465f6
cmpl $0x0, 0x16c(%rsp)
sete %al
movb %al, 0xbf(%rsp)
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0x46603
jmp 0x4663b
movslq 0x15c(%rsp), %rax
movsbl 0xffc0(%rsp,%rax), %eax
cmpl $0x2f, %eax
jne 0x46626
movl 0x15c(%rsp), %eax
movl %eax, 0x16c(%rsp)
jmp 0x46628
movl 0x15c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x15c(%rsp)
jmp 0x465cb
movl $0x0, 0x168(%rsp)
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
movl 0x158(%rsp), %ecx
xorl %eax, %eax
cmpl 0x160(%rsp), %ecx
movb %al, 0xbe(%rsp)
jge 0x46682
cmpl $0x0, 0x168(%rsp)
sete %al
movb %al, 0xbe(%rsp)
movb 0xbe(%rsp), %al
testb $0x1, %al
jne 0x4668f
jmp 0x466c7
movslq 0x158(%rsp), %rax
movsbl 0xffc0(%rsp,%rax), %eax
cmpl $0x2f, %eax
jne 0x466b2
movl 0x158(%rsp), %eax
movl %eax, 0x168(%rsp)
jmp 0x466b4
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0x46657
cmpl $0x0, 0x16c(%rsp)
jle 0x46798
movl 0x168(%rsp), %eax
subl 0x16c(%rsp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jle 0x46798
movl 0x160(%rsp), %eax
subl 0x168(%rsp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jle 0x46798
leaq 0xffc0(%rsp), %rsi
movslq 0x16c(%rsp), %rdx
leaq 0x190(%rsp), %rdi
callq 0x2220
movl 0x16c(%rsp), %eax
addl $0x1, %eax
cltq
leaq 0xffc0(%rsp), %rsi
addq %rax, %rsi
movl 0x168(%rsp), %eax
subl 0x16c(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rdx
leaq 0x170(%rsp), %rdi
callq 0x2220
movl 0x168(%rsp), %eax
addl $0x1, %eax
cltq
leaq 0xffc0(%rsp), %rsi
addq %rax, %rsi
movl 0x160(%rsp), %eax
subl 0x168(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rdx
leaq 0x1b0(%rsp), %rdi
callq 0x2220
jmp 0x4679d
jmp 0x47852
leaq 0x190(%rsp), %rdi
callq 0x2430
movl %eax, 0x16c(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x2430
movl %eax, 0x168(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x2430
movl %eax, 0x164(%rsp)
jmp 0x467db
cmpl $0x0, 0x164(%rsp)
jle 0x47831
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x46808
leaq 0x1baa1(%rip), %rdi     # 0x622a2
movb $0x0, %al
callq 0x2040
leaq 0xffc0(%rsp), %rdi
movq 0x103e0(%rsp), %rax
movss 0x5e0(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x103e0(%rsp), %rax
movss 0x5e4(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movl 0x16c(%rsp), %edx
movl 0x168(%rsp), %ecx
leaq 0x1ba5b(%rip), %rsi     # 0x622a8
movb $0x2, %al
callq 0x2060
movq $0x0, 0x103c8(%rsp)
leaq 0xffc0(%rsp), %rdi
leaq 0x19f94(%rip), %rsi     # 0x60803
callq 0x20b0
movq %rax, 0x103c8(%rsp)
movq 0x103c8(%rsp), %rdi
callq 0x22f0
movl %eax, 0x154(%rsp)
movl 0x154(%rsp), %edi
movl $0x3, %esi
xorl %edx, %edx
movb $0x0, %al
callq 0x2190
movl %eax, 0x150(%rsp)
movl 0x150(%rsp), %eax
orl $0x800, %eax            # imm = 0x800
movl %eax, 0x150(%rsp)
movl 0x154(%rsp), %edi
movl 0x150(%rsp), %edx
movl $0x4, %esi
movb $0x0, %al
callq 0x2190
movl $0x2, 0x27aed(%rip)     # 0x6e3d0
movl $0x0, 0x14c(%rsp)
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x4690d
leaq 0x1ba60(%rip), %rdi     # 0x62366
movb $0x0, %al
callq 0x2040
cmpq $0x0, 0x103c8(%rsp)
je 0x46984
jmp 0x4691a
leaq 0x1d0(%rsp), %rdi
movq 0x103c8(%rsp), %rdx
movl $0xfde8, %esi           # imm = 0xFDE8
callq 0x2450
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0xbd(%rsp)
jne 0x46958
cmpl $0x1e, 0x14c(%rsp)
setl %al
movb %al, 0xbd(%rsp)
movb 0xbd(%rsp), %al
testb $0x1, %al
jne 0x46965
jmp 0x46982
movl $0x1, %edi
callq 0x21e0
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x4691a
jmp 0x46984
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x469aa
movl 0x14c(%rsp), %esi
leaq 0x1b9c9(%rip), %rdi     # 0x6236c
movb $0x0, %al
callq 0x2040
cmpl $0x1e, 0x14c(%rsp)
jl 0x469d1
cmpq $0x0, 0x103c8(%rsp)
je 0x469cc
movq 0x103c8(%rsp), %rdi
callq 0x23d0
jmp 0x47852
movq $0x0, 0x140(%rsp)
movq $0x0, 0x138(%rsp)
movq $0x0, 0x130(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x23a0
leaq 0x1d0(%rsp), %rdi
callq 0x599d0
movq %rax, 0xb0(%rsp)
jmp 0x46a19
movq 0xb0(%rsp), %rax
movq %rax, 0x108(%rsp)
leaq 0x1b52a(%rip), %rsi     # 0x61f5a
leaq 0x110(%rsp), %rdi
callq 0x2380
jmp 0x46a3f
xorl %eax, %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0x2550
movq %rax, 0xa8(%rsp)
jmp 0x46a5a
movq 0xa8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x108(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x5a2f0
movq %rax, 0xa0(%rsp)
jmp 0x46a89
movq 0xa0(%rsp), %rax
movq %rax, 0x140(%rsp)
leaq 0x1b4c6(%rip), %rsi     # 0x61f66
leaq 0x110(%rsp), %rdi
callq 0x2380
jmp 0x46aaf
movq 0x140(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x5a2f0
movq %rax, 0x98(%rsp)
jmp 0x46ace
movq 0x98(%rsp), %rax
movq %rax, 0x138(%rsp)
leaq 0x1b88f(%rip), %rsi     # 0x62374
leaq 0x110(%rsp), %rdi
callq 0x2380
jmp 0x46af4
xorl %eax, %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0x2550
movq %rax, 0x90(%rsp)
jmp 0x46b0f
movq 0x90(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x140(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x5a2f0
movq %rax, 0x88(%rsp)
jmp 0x46b3e
movq 0x88(%rsp), %rax
movq %rax, 0x130(%rsp)
cmpq $0x0, 0x138(%rsp)
je 0x46b95
movq 0x138(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x138(%rsp)
jmp 0x46b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x2578
jmp 0x4785a
cmpq $0x0, 0x138(%rsp)
je 0x46bb4
movq 0x130(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x130(%rsp)
movl $0x0, 0xec(%rsp)
movl $0x0, 0xe8(%rsp)
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x46bed
leaq 0x1b7b3(%rip), %rdi     # 0x62395
xorl %eax, %eax
callq 0x2040
jmp 0x46beb
jmp 0x46bed
jmp 0x46bef
cmpq $0x0, 0x138(%rsp)
je 0x477b5
movq 0x103f0(%rsp), %rdi
callq 0x1ce80
cmpq $0x0, %rax
jbe 0x46ca1
jmp 0x46c17
movslq 0xe8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x103e8(%rsp), %rdi
callq 0x1cc80
movq 0x78(%rsp), %rcx
movq %rax, %rdx
subq $0x1, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x87(%rsp)
jae 0x46c7c
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq 0x138(%rsp), %rcx
movslq 0x28(%rcx), %rcx
cmpq %rcx, %rax
setl %al
movb %al, 0x87(%rsp)
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x46c89
jmp 0x46c9f
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x46c17
jmp 0x46ca1
movslq 0xe8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x103e8(%rsp), %rdi
callq 0x1cc80
movq %rax, %rcx
movq 0x70(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jb 0x46cd1
jmp 0x477b5
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq 0x138(%rsp), %rcx
movslq 0x28(%rcx), %rcx
cmpq %rcx, %rax
jne 0x4778a
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movabsq $0x1845c8a0ce512957, %rcx # imm = 0x1845C8A0CE512957
imulq %rcx
movq 0x68(%rsp), %rax
movq %rdx, %rcx
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0xd, %rcx
addq %rdx, %rcx
imulq $0x15180, %rcx, %rcx    # imm = 0x15180
subq %rcx, %rax
movabsq $0x48d159e26af37c05, %rcx # imm = 0x48D159E26AF37C05
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
movl %eax, %ecx
shrq $0x8, %rdx
movl %edx, %eax
addl %ecx, %eax
movl %eax, 0xe4(%rsp)
movq 0x103d0(%rsp), %rax
movslq 0xe4(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cvtsi2sd %rax, %xmm0
movsd 0x19373(%rip), %xmm1    # 0x60100
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xe0(%rsp)
movq 0x103d0(%rsp), %rax
movslq 0xe4(%rsp), %rcx
movl 0x180(%rax,%rcx,4), %eax
cvtsi2ss %rax, %xmm0
movq 0x103e0(%rsp), %rax
movss 0x5b0(%rax), %xmm1
movss 0x19252(%rip), %xmm2    # 0x60024
mulss %xmm2, %xmm1
movss 0x19282(%rip), %xmm2    # 0x60060
mulss %xmm2, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0xdc(%rsp)
movq 0x103d0(%rsp), %rax
movl 0x31c(%rax), %eax
cvtsi2ss %rax, %xmm0
movq 0x103e0(%rsp), %rax
movss 0x5b0(%rax), %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x19326(%rip), %xmm1    # 0x60148
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xd8(%rsp)
movq 0x103d0(%rsp), %rax
movl 0x318(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x192c2(%rip), %xmm1    # 0x60110
divsd %xmm1, %xmm0
movsd 0x192e6(%rip), %xmm1    # 0x60140
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xd4(%rsp)
movss 0x191a9(%rip), %xmm0    # 0x6001c
movss %xmm0, 0xd0(%rsp)
movss 0xd8(%rsp), %xmm0
movss 0x1918f(%rip), %xmm1    # 0x6001c
ucomiss %xmm1, %xmm0
jbe 0x46ebe
movss 0xd4(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x46ebe
movss 0xd4(%rsp), %xmm0
divss 0xd8(%rsp), %xmm0
movss %xmm0, 0xd0(%rsp)
movss 0xd0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x19245(%rip), %xmm0    # 0x60118
ucomisd %xmm1, %xmm0
jbe 0x46eea
movss 0x1b32f(%rip), %xmm0    # 0x62210
movss %xmm0, 0xd0(%rsp)
movss 0xd0(%rsp), %xmm0
movss 0x19129(%rip), %xmm1    # 0x60024
ucomiss %xmm1, %xmm0
jbe 0x46f11
movss 0x1911c(%rip), %xmm0    # 0x60024
movss %xmm0, 0xd0(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xcc(%rsp)
movss 0xe0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x191e6(%rip), %xmm1    # 0x60118
ucomisd %xmm1, %xmm0
jbe 0x46f53
movss 0xdc(%rsp), %xmm0
divss 0xe0(%rsp), %xmm0
movss %xmm0, 0xcc(%rsp)
movq 0x103d0(%rsp), %rax
movl 0x314(%rax), %eax
cvtsi2ss %rax, %xmm0
movq 0x103e0(%rsp), %rax
movss 0x190ae(%rip), %xmm1    # 0x60024
mulss 0x5b0(%rax), %xmm1
movss 0x190da(%rip), %xmm2    # 0x60060
mulss %xmm2, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0xc8(%rsp)
movss 0xc8(%rsp), %xmm0
movl $0xa, %eax
subl 0xe8(%rsp), %eax
cvtsi2ss %eax, %xmm1
mulss %xmm1, %xmm0
movss 0x19068(%rip), %xmm1    # 0x60024
divss %xmm1, %xmm0
movss %xmm0, 0xc8(%rsp)
movss 0xd8(%rsp), %xmm0
movss 0x19042(%rip), %xmm1    # 0x6001c
ucomiss %xmm1, %xmm0
jbe 0x47038
cmpl $0xa, 0xe8(%rsp)
jge 0x47038
movss 0xcc(%rsp), %xmm0
movl 0xe8(%rsp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm2
movl $0xa, %eax
subl 0xe8(%rsp), %eax
cvtsi2ss %eax, %xmm1
mulss 0xd0(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x1b1eb(%rip), %xmm1    # 0x62214
divss %xmm1, %xmm0
movss %xmm0, 0xd0(%rsp)
jmp 0x4705d
movss 0xcc(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4705b
movss 0xcc(%rsp), %xmm0
movss %xmm0, 0xd0(%rsp)
jmp 0x4705d
cmpl $0x0, 0x103dc(%rsp)
jne 0x4712d
movq 0x130(%rsp), %rax
movsd 0x30(%rax), %xmm0
cvtsi2sdl 0x164(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x190d3(%rip), %xmm1    # 0x60160
divsd %xmm1, %xmm0
movq 0x103e0(%rsp), %rax
movss 0x5b0(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
movsd 0x19057(%rip), %xmm1    # 0x60108
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x60(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x60(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
mulss 0xd0(%rsp), %xmm0
movss %xmm0, 0x64(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x64(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
jmp 0x4720c
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x130(%rsp), %rax
movsd 0x30(%rax), %xmm1
cvtsi2sdl 0x164(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x18ff3(%rip), %xmm2    # 0x60160
divsd %xmm2, %xmm1
movq 0x103e0(%rsp), %rax
movss 0x5b0(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
divsd %xmm2, %xmm1
movsd 0x18f77(%rip), %xmm2    # 0x60108
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x58(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x58(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
mulss 0xd0(%rsp), %xmm0
movss %xmm0, 0x5c(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x5c(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movq %rax, %rcx
movq 0x50(%rsp), %rax
subq (%rcx), %rax
movl %eax, 0xc4(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x1c(%rax), %xmm1
movss 0xc8(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x47361
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
mulss 0xd0(%rsp), %xmm0
ucomiss 0xc8(%rsp), %xmm0
jbe 0x47361
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movq %rax, %rcx
movq 0x48(%rsp), %rax
subq (%rcx), %rax
cmpq $0xa8c0, %rax           # imm = 0xA8C0
jge 0x47361
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x40(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x40(%rsp), %xmm0
movss 0x20(%rax), %xmm1
mulss 0xd0(%rsp), %xmm1
addss %xmm0, %xmm0
addss %xmm1, %xmm0
movss 0x18d3e(%rip), %xmm1    # 0x60070
divss %xmm1, %xmm0
movss %xmm0, 0x44(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x44(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
jmp 0x475f4
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x1c(%rax), %xmm1
movss 0xc8(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x47472
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
mulss 0xd0(%rsp), %xmm0
ucomiss 0xc8(%rsp), %xmm0
jbe 0x47472
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movq %rax, %rcx
movq 0x38(%rsp), %rax
subq (%rcx), %rax
cmpq $0xa8c0, %rax           # imm = 0xA8C0
jge 0x47472
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x30(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x30(%rsp), %xmm0
movss 0x20(%rax), %xmm1
mulss 0xd0(%rsp), %xmm1
addss %xmm1, %xmm0
movss 0x18bc1(%rip), %xmm1    # 0x60004
divss %xmm1, %xmm0
movss %xmm0, 0x34(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
jmp 0x475f2
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x1c(%rax), %xmm1
movss 0xc8(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x475a7
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm1
mulss 0xd0(%rsp), %xmm1
movss 0xc8(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x475a7
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
movss 0x18b27(%rip), %xmm1    # 0x6001c
ucomiss %xmm1, %xmm0
jbe 0x475a7
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq (%rcx), %rax
cmpq $0xa8c0, %rax           # imm = 0xA8C0
jge 0x475a7
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
movss 0xd0(%rsp), %xmm2
movss 0xc8(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x18a89(%rip), %xmm1    # 0x60004
divss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x24(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
jmp 0x475f0
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rax), %xmm0
mulss 0xd0(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x103e8(%rsp), %rdi
movslq 0xe8(%rsp), %rsi
callq 0x1cca0
movss 0x20(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
jmp 0x475f2
jmp 0x475f4
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movss 0x1c(%rax), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
movb %al, 0x1f(%rsp)
jne 0x47642
jp 0x47642
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
movb %al, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, 0xe8(%rsp)
testb $0x1, %al
jne 0x4765b
jmp 0x476cd
movq 0x103e8(%rsp), %rdi
movl $0x1, %esi
callq 0x1cca0
movss 0x1c(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x1c(%rax)
movq 0x103e8(%rsp), %rdi
movl $0x1, %esi
callq 0x1cca0
movss 0x20(%rax), %xmm0
movss %xmm0, 0x18(%rsp)
movq 0x103e8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1cca0
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x20(%rax)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
movslq 0xe8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x103e8(%rsp), %rdi
callq 0x1cc80
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jbe 0x47788
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x47739
leaq 0x1ac6d(%rip), %rdi     # 0x6239b
xorl %eax, %eax
callq 0x2040
jmp 0x47737
jmp 0x47739
cmpq $0x0, 0x103c8(%rsp)
je 0x47755
movq 0x103c8(%rsp), %rdi
callq 0x23d0
jmp 0x47753
jmp 0x47755
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x47778
leaq 0x1ac36(%rip), %rdi     # 0x623a3
xorl %eax, %eax
callq 0x2040
jmp 0x47776
jmp 0x47778
movl $0x1, 0xc0(%rsp)
jmp 0x47822
jmp 0x4778a
movq 0x138(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x138(%rsp)
movq 0x130(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x130(%rsp)
jmp 0x46bef
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x477d8
leaq 0x1abce(%rip), %rdi     # 0x6239b
xorl %eax, %eax
callq 0x2040
jmp 0x477d6
jmp 0x477d8
cmpq $0x0, 0x103c8(%rsp)
je 0x477f4
movq 0x103c8(%rsp), %rdi
callq 0x23d0
jmp 0x477f2
jmp 0x477f4
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x47817
leaq 0x1ab97(%rip), %rdi     # 0x623a3
xorl %eax, %eax
callq 0x2040
jmp 0x47815
jmp 0x47817
movl $0x1, 0xc0(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x2578
jmp 0x47852
movq 0x103e0(%rsp), %rax
testb $0x1, 0x52d(%rax)
je 0x47850
leaq 0x1ab62(%rip), %rdi     # 0x623ab
movb $0x0, %al
callq 0x2040
jmp 0x47852
addq $0x103f8, %rsp          # imm = 0x103F8
retq
movq 0x100(%rsp), %rdi
callq 0x24c0
nopw (%rax,%rax)