// File: /workspace/github_cpp_makefile_star2_O1/Eba-M[P]E3DC-Control/RscpExampleMain.cpp
// Function: main
int main(int argc, char *argv[])
{
/*
    static int ret = -1;
    while (true)
    {
        ret = iModbusTCP();
        sleep(1);
    }
 */
//    signgam(EPIPE, SIG_IGN);
 for (int i=1; i < argc; i++)
 {
     // Ausgabe aller Parameter
     printf(" %i %s",i,argv[i]);
     // Auf speziellen Parameter prüfen
     if((strcmp(argv[i], "-config") == 0)||(strcmp(argv[i], "-conf") == 0)||(strcmp(argv[i], "-c") == 0))
     strcpy(e3dc_config.conffile, argv[i+1]);
 }
    

static int iEC = 0;
 time(&t);
    t_alt = t;
    float f1=0,f2=0;
//    shellyem_get(f1,f2);

    // endless application which re-connections to server on connection lost
    int res = system("pwd");
    GetConfig();
    e3dc_config.stop = 0; // Stop ausschalten
    
    if (e3dc_config.statistik)
    {
        FILE * pFile;
        pFile = NULL;
        pFile = fopen ("Weekhour.dat","rb");
        if (pFile!=NULL)
        {
            size_t x1 = sizeof(iWeekhour);
            x1 = fread (&iWeekhour , sizeof(uint32_t), sizeof(iWeekhour)/sizeof(uint32_t), pFile);
            fclose (pFile);
        }
        pFile = NULL;
        pFile = fopen ("WeekhourWP.dat","rb");
        if (pFile!=NULL)
        {
            size_t x1 = sizeof(iWeekhourWP);
            x1 = fread (&iWeekhourWP , sizeof(uint32_t), sizeof(iWeekhourWP)/sizeof(uint32_t), pFile);
            fclose (pFile);
        }
        pFile = NULL;
        pFile = fopen ("HeatStat.dat","rb");
        if (pFile!=NULL)
        {
            size_t x1 = sizeof(iHeatStat);
            x1 = fread (&iHeatStat , sizeof(uint32_t), sizeof(iHeatStat)/sizeof(uint32_t), pFile);
            fclose (pFile);
        }

        pFile = NULL;
        char fname[100];
        time(&t);
        int day = (t%(24*3600*28))/(24*3600);
        sprintf(fname,"%s.dat","PVStat");
        pFile = fopen(fname,"rb");       // altes logfile löschen

        if (pFile!=NULL)
        {
            size_t x1 = sizeof(iDayStat);
            x1 = fread (&iDayStat , sizeof(uint32_t), sizeof(iDayStat)/sizeof(uint32_t), pFile);
            fclose (pFile);
        }
        pFile = NULL;
        sprintf(fnameGrid,"Grid.%i.%i.dat",ptm->tm_year%100,ptm->tm_mon+1);
        pFile = fopen(fnameGrid,"rb");       // altes logfile löschen

        if (pFile!=NULL)
        {
            size_t x1 = sizeof(iGridStat);
            x1 = fread (&iGridStat, sizeof(int32_t), sizeof(iGridStat)/sizeof(int32_t), pFile);
            fclose (pFile);
        }
        GetWallbox(ch);
    }
    
        while(iEC < 10&&e3dc_config.stop==0||e3dc_config.stop>99)
        {

            e3dc_config.stop=0;
            iEC++; // Schleifenzähler erhöhen
            int hh1 = sunsetAt / 60;
            int mm1 = sunsetAt % 60;
            int hh = sunriseAt / 60;
            int mm = sunriseAt % 60;
            sprintf(Log,"Start %s %s", strtok(asctime(ptm),"\n"),VERSION);
            WriteLog();
            // connect to server
            printf("Program Start Version:%s\n",VERSION);
            printf("Sonnenaufgang %i:%i %i:%i\n", hh, mm, hh1, mm1);
//            CheckConfig();
//            printf("GetConfig done");
            if ((e3dc_config.aWATTar||e3dc_config.openmeteo))
            {
                mewp(w,wetter,fatemp,fcop,sunriseAt,sunsetAt,e3dc_config,55.5,ireq_Heistab,-99,fNotstromreserve,iHeatStat[1]);
                aWATTar(ch,w,wetter,e3dc_config,fBatt_SOC, fNotstromreserve, sunriseAt, iDayStat); // im Master nicht aufrufen
                if (e3dc_config.test)
                    mewp(w,wetter,fatemp,fcop,sunriseAt,sunsetAt,e3dc_config,55.5,ireq_Heistab,5,fNotstromreserve,iHeatStat[1]);
            }
            while (e3dc_config.test)
                LoadDataProcess();

            LoadDataProcess();

        printf("Connecting to server %s:%i\n", e3dc_config.server_ip, e3dc_config.server_port);
        iSocket = SocketConnect(e3dc_config.server_ip, e3dc_config.server_port);
        if(iSocket < 0) 
        {
            printf("Connection failed\n");
            sleep(1);
            continue;
        }
        printf("Connected successfully\n");

        // reset authentication flag
        iAuthenticated = 0;

        // create AES key and set AES parameters
        {
            // initialize AES encryptor and decryptor IV
            memset(ucDecryptionIV, 0xff, AES_BLOCK_SIZE);
            memset(ucEncryptionIV, 0xff, AES_BLOCK_SIZE);

            // limit password length to AES_KEY_SIZE
            int64_t iPasswordLength = strlen(e3dc_config.aes_password);
            if(iPasswordLength > AES_KEY_SIZE)
                iPasswordLength = AES_KEY_SIZE;

            // copy up to 32 bytes of AES key password
            uint8_t ucAesKey[AES_KEY_SIZE];
            memset(ucAesKey, 0xff, AES_KEY_SIZE);
            memcpy(ucAesKey, e3dc_config.aes_password, iPasswordLength);

            // set encryptor and decryptor parameters
            aesDecrypter.SetParameters(AES_KEY_SIZE * 8, AES_BLOCK_SIZE * 8);
            aesEncrypter.SetParameters(AES_KEY_SIZE * 8, AES_BLOCK_SIZE * 8);
            aesDecrypter.StartDecryption(ucAesKey);
            aesEncrypter.StartEncryption(ucAesKey);
        }

        // enter the main transmit / receive loop
        mainLoop();
        printf("mainloop beendet %i\n",iEC);
        // close socket connection
        SocketClose(iSocket);
        iSocket = -1;
        if (!e3dc_config.stop)
            sleep(1);
            printf("Program stop Reason e3dc_config.stop=%i",e3dc_config.stop);
            if (e3dc_config.statistik)
            {
                FILE * pFile;
                pFile = NULL;
                pFile = fopen ("Weekhour.dat","wb");
                if (pFile!=NULL)
                {
                    fwrite (iWeekhour , sizeof(uint32_t), sizeof(iWeekhour)/sizeof(uint32_t), pFile);
                    fclose (pFile);
                }
                pFile = fopen ("WeekhourWP.dat","wb");
                if (pFile!=NULL)
                {
                    fwrite (iWeekhourWP , sizeof(uint32_t), sizeof(iWeekhourWP)/sizeof(uint32_t), pFile);
                    fclose (pFile);
                }
                pFile = fopen ("HeatStat.dat","wb");
                if (pFile!=NULL)
                {
                    size_t x1;
                    x1 = fwrite (iHeatStat , sizeof(uint32_t), sizeof(iHeatStat)/sizeof(uint32_t), pFile);
                    fclose (pFile);
                }
                char fname[100];
                time(&t);
                int day = (t%(24*3600*28))/(24*3600);
                sprintf(fname,"%s.dat","PVStat");
                pFile = fopen(fname,"wb");       // altes logfile löschen

                if (pFile!=NULL)
                {
                    x1 = fwrite (iDayStat , sizeof(uint32_t), sizeof(iDayStat)/sizeof(uint32_t), pFile);
                    fclose (pFile);
                }
                pFile = fopen(fnameGrid,"wb");       // datei zurückschreiben
                if (pFile!=NULL)
                {
                    x1 = fwrite (iGridStat , sizeof(int32_t), sizeof(iGridStat)/sizeof(int32_t), pFile);
                    fclose (pFile);
                }
                PutWallbox(ch);
            }

    }

    printf("Programm wirklich beendet\n");
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
cmpl $0x2, %edi
jl 0x140c7
movq %rsi, %rbx
movl %edi, %r13d
movl $0x1, %r14d
leaq 0x1dbe6(%rip), %r15     # 0x31c43
leaq 0x1dbe6(%rip), %r12     # 0x31c4a
movq (%rbx,%r14,8), %rdx
movq %r15, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x2040
movq (%rbx,%r14,8), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2390
testl %eax, %eax
je 0x140ae
movq %rbp, %rdi
leaq 0x1dbc0(%rip), %rsi     # 0x31c52
callq 0x2390
testl %eax, %eax
je 0x140ae
movq %rbp, %rdi
leaq 0x1dbb3(%rip), %rsi     # 0x31c58
callq 0x2390
testl %eax, %eax
jne 0x140bf
movq 0x8(%rbx,%r14,8), %rsi
leaq 0x25b5a(%rip), %rdi     # 0x39c14
callq 0x2260
incq %r14
cmpq %r14, %r13
jne 0x14064
leaq 0x26aea(%rip), %rdi     # 0x3abb8
callq 0x2250
movq 0x26ade(%rip), %rax     # 0x3abb8
movq %rax, 0x27ebf(%rip)     # 0x3bfa0
leaq 0x1db73(%rip), %rdi     # 0x31c5b
callq 0x2210
callq 0x33b3
movb $0x0, 0x25d41(%rip)     # 0x39e3a
cmpb $0x0, 0x25d30(%rip)     # 0x39e30
je 0x142a3
leaq 0x1cee2(%rip), %rdi     # 0x30fef
leaq 0x1c827(%rip), %rsi     # 0x3093b
callq 0x22e0
testq %rax, %rax
je 0x14142
movq %rax, %rbx
leaq 0x2b808(%rip), %rdi     # 0x3f930
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x1ceb3(%rip), %rdi     # 0x30ffc
leaq 0x1c7eb(%rip), %rsi     # 0x3093b
callq 0x22e0
testq %rax, %rax
je 0x1417e
movq %rax, %rbx
leaq 0x2ad1c(%rip), %rdi     # 0x3ee80
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x1dada(%rip), %rdi     # 0x31c5f
leaq 0x1c7af(%rip), %rsi     # 0x3093b
callq 0x22e0
testq %rax, %rax
je 0x141ba
movq %rax, %rbx
leaq 0x2c240(%rip), %rdi     # 0x403e0
movl $0x4, %esi
movl $0x62, %edx
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x269f7(%rip), %rdi     # 0x3abb8
callq 0x2250
leaq 0x1ce05(%rip), %rsi     # 0x30fd2
leaq 0x1ce05(%rip), %rdx     # 0x30fd9
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0x1c74e(%rip), %rsi     # 0x3093b
movq %rbx, %rdi
callq 0x22e0
testq %rax, %rax
je 0x1421e
movq %rax, %rbx
leaq 0x2c36c(%rip), %rdi     # 0x40570
movl $0x4, %esi
movl $0xc9, %edx
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
movq 0x26983(%rip), %rax     # 0x3aba8
movslq 0x14(%rax), %rdx
imulq $0x51eb851f, %rdx, %rcx # imm = 0x51EB851F
movq %rcx, %rsi
shrq $0x3f, %rsi
sarq $0x25, %rcx
addl %esi, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %edx
movl 0x10(%rax), %ecx
incl %ecx
leaq 0x2c652(%rip), %rbx     # 0x408a0
leaq 0x1cd8b(%rip), %rsi     # 0x30fe0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0x1c6d5(%rip), %rsi     # 0x3093b
movq %rbx, %rdi
callq 0x22e0
testq %rax, %rax
je 0x14297
movq %rax, %rbx
leaq 0x27d43(%rip), %rdi     # 0x3bfc0
movl $0x4, %esi
movl $0xba0, %edx            # imm = 0xBA0
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x255ca(%rip), %rdi     # 0x39868
callq 0x24c25
movl 0x2c7f7(%rip), %eax     # 0x40aa0
cmpl $0xa, %eax
setl %cl
movb 0x25b85(%rip), %dl      # 0x39e3a
testb %dl, %dl
sete %sil
andb %cl, %sil
cmpb $0x64, %dl
setae %cl
orb %sil, %cl
cmpb $0x1, %cl
jne 0x150b4
leaq 0x78(%rsp), %r15
movb $0x0, 0x25b5e(%rip)     # 0x39e3a
incl %eax
movl %eax, 0x2c7bc(%rip)     # 0x40aa0
movslq 0x268d9(%rip), %rbp     # 0x3abc4
imulq $-0x77777777, %rbp, %r12 # imm = 0x88888889
shrq $0x20, %r12
addl %ebp, %r12d
movl %r12d, %eax
shrl $0x1f, %eax
sarl $0x5, %r12d
addl %eax, %r12d
imull $0x3c, %r12d, %eax
subl %eax, %ebp
movslq 0x268ad(%rip), %r14     # 0x3abc0
imulq $-0x77777777, %r14, %r13 # imm = 0x88888889
shrq $0x20, %r13
addl %r14d, %r13d
movl %r13d, %eax
shrl $0x1f, %eax
sarl $0x5, %r13d
addl %eax, %r13d
imull $0x3c, %r13d, %eax
subl %eax, %r14d
movq 0x2686c(%rip), %rdi     # 0x3aba8
callq 0x20f0
movq %rax, %rdi
leaq 0x1e0ee(%rip), %rsi     # 0x32439
callq 0x2430
leaq 0x25c69(%rip), %rdi     # 0x39fc0
leaq 0x1d90e(%rip), %rsi     # 0x31c6c
movq %rax, %rdx
leaq 0x1d910(%rip), %rbx     # 0x31c78
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
callq 0x2cfc
leaq 0x1d906(%rip), %rdi     # 0x31c84
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1d90f(%rip), %rdi     # 0x31c9e
movl %r13d, %esi
movl %r14d, %edx
movl %r12d, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2040
cmpb $0x0, 0x25a8d(%rip)     # 0x39e36
jne 0x143b8
cmpb $0x1, 0x25a7d(%rip)     # 0x39e2f
jne 0x144d0
movl 0x26801(%rip), %r8d     # 0x3abc0
movl 0x267fe(%rip), %r9d     # 0x3abc4
movl 0x27b14(%rip), %eax     # 0x3bee0
movss 0x2c56c(%rip), %xmm2    # 0x40940
movl 0x2c009(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x24fe2(%rip), %r12     # 0x393c8
movq %r12, %rdi
leaq 0x24ff0(%rip), %r13     # 0x393e0
movq %r13, %rsi
leaq 0x2c532(%rip), %rdx     # 0x4092c
leaq 0x2c557(%rip), %rcx     # 0x40958
movss 0x1c0c7(%rip), %xmm0    # 0x304d0
movss 0x1bfe7(%rip), %xmm1    # 0x303f8
pushq %r10
pushq %rax
leaq 0x254dd(%rip), %r14     # 0x398f8
pushq %r14
callq 0x2129d
addq $0x20, %rsp
movd 0x24f02(%rip), %xmm0    # 0x39330
movss 0x2c50a(%rip), %xmm1    # 0x40940
movl 0x26783(%rip), %r8d     # 0x3abc0
leaq 0x25424(%rip), %rdi     # 0x39868
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
leaq 0x2c11c(%rip), %r9      # 0x40570
callq 0x26c76
cmpb $0x0, 0x259db(%rip)     # 0x39e3b
je 0x144d0
movl 0x26757(%rip), %r8d     # 0x3abc0
movl 0x26754(%rip), %r9d     # 0x3abc4
movl 0x27a6a(%rip), %eax     # 0x3bee0
movss 0x2c4c2(%rip), %xmm2    # 0x40940
movl 0x2bf5f(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x24f38(%rip), %rdi     # 0x393c8
leaq 0x24f49(%rip), %rsi     # 0x393e0
leaq 0x2c48e(%rip), %rdx     # 0x4092c
leaq 0x2c4b3(%rip), %rcx     # 0x40958
movd 0x1c023(%rip), %xmm0    # 0x304d0
movss 0x1bfbf(%rip), %xmm1    # 0x30474
pushq %r10
pushq %rax
leaq 0x25439(%rip), %rax     # 0x398f8
pushq %rax
callq 0x2129d
addq $0x20, %rsp
jmp 0x144d0
callq 0x7dad
cmpb $0x0, 0x25964(%rip)     # 0x39e3b
jne 0x144cb
callq 0x7dad
movl 0x25524(%rip), %edx     # 0x39a08
leaq 0x1d7ce(%rip), %rdi     # 0x31cb9
leaq 0x25406(%rip), %r14     # 0x398f8
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movl 0x25506(%rip), %esi     # 0x39a08
movq %r14, %rdi
callq 0x20786
movl %eax, 0xc(%rsp)
testl %eax, %eax
js 0x147cc
leaq 0x1d9f2(%rip), %rdi     # 0x31f0f
callq 0x2400
movb $0x0, 0x2c54f(%rip)     # 0x40a78
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x2c57b(%rip)    # 0x40ab0
movdqa %xmm0, 0x2c583(%rip)    # 0x40ac0
movdqa %xmm0, 0x2c58b(%rip)    # 0x40ad0
movdqa %xmm0, 0x2c593(%rip)    # 0x40ae0
leaq 0x255c0(%rip), %r14     # 0x39b14
movq %r14, %rdi
callq 0x2100
cmpq $0x20, %rax
movl $0x20, %ecx
cmovgeq %rcx, %rax
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x90(%rsp)
movdqa %xmm0, 0x80(%rsp)
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
leaq 0x25098(%rip), %r14     # 0x39634
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x100, %edx            # imm = 0x100
callq 0x16d76
leaq 0x24e73(%rip), %r13     # 0x39428
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x100, %edx            # imm = 0x100
callq 0x16d76
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b3cc
movq %r13, %rdi
movq %r12, %rsi
callq 0x16df6
leaq 0x50(%rsp), %rdi
callq 0x1599c
cmpb $0x0, 0x2584c(%rip)     # 0x39e3a
je 0x14811
leaq 0x1d797(%rip), %rdi     # 0x31d92
xorl %eax, %eax
callq 0x2040
leaq 0x50(%rsp), %rdi
callq 0x159a8
movl 0x2c48e(%rip), %esi     # 0x40aa0
leaq 0x1d6bc(%rip), %rdi     # 0x31cd5
xorl %eax, %eax
callq 0x2040
movl 0xc(%rsp), %edi
callq 0x20a6d
cmpb $0x0, 0x2580a(%rip)     # 0x39e3a
jne 0x1463c
movl $0x1, %edi
callq 0x21b0
movzbl 0x257f7(%rip), %esi     # 0x39e3a
leaq 0x1d6a0(%rip), %rdi     # 0x31cea
xorl %eax, %eax
callq 0x2040
cmpb $0x1, 0x257d8(%rip)     # 0x39e30
jne 0x147e2
leaq 0x1c98a(%rip), %rdi     # 0x30fef
leaq 0x1c153(%rip), %rsi     # 0x307bf
callq 0x22e0
testq %rax, %rax
je 0x1469a
movq %rax, %r14
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x2b2a6(%rip), %rdi     # 0x3f930
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x1c95b(%rip), %rdi     # 0x30ffc
leaq 0x1c117(%rip), %rsi     # 0x307bf
callq 0x22e0
testq %rax, %rax
je 0x146d6
movq %rax, %r14
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x2a7ba(%rip), %rdi     # 0x3ee80
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x1d582(%rip), %rdi     # 0x31c5f
leaq 0x1c0db(%rip), %rsi     # 0x307bf
callq 0x22e0
testq %rax, %rax
je 0x14712
movq %rax, %r14
movl $0x4, %esi
movl $0x62, %edx
leaq 0x2bcde(%rip), %rdi     # 0x403e0
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x2649f(%rip), %rdi     # 0x3abb8
callq 0x2250
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x1c8a2(%rip), %rsi     # 0x30fd2
leaq 0x1c8a2(%rip), %rdx     # 0x30fd9
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
leaq 0x1c077(%rip), %rsi     # 0x307bf
callq 0x22e0
testq %rax, %rax
je 0x1477c
movq %rax, %r14
movl $0x4, %esi
movl $0xc9, %edx
leaq 0x2be0a(%rip), %rdi     # 0x40570
movq %rax, %rcx
callq 0x2510
movl %eax, 0x2661c(%rip)     # 0x3ad90
movq %r14, %rdi
callq 0x2290
leaq 0x2c11d(%rip), %rdi     # 0x408a0
leaq 0x1c035(%rip), %rsi     # 0x307bf
callq 0x22e0
testq %rax, %rax
je 0x147be
movq %rax, %r14
movl $0x4, %esi
movl $0xba0, %edx            # imm = 0xBA0
leaq 0x27818(%rip), %rdi     # 0x3bfc0
movq %rax, %rcx
callq 0x2510
movl %eax, 0x265da(%rip)     # 0x3ad90
movq %r14, %rdi
callq 0x2290
leaq 0x250a3(%rip), %rdi     # 0x39868
callq 0x24b35
jmp 0x147e2
leaq 0x1d753(%rip), %rdi     # 0x31f26
callq 0x2400
movl $0x1, %edi
callq 0x21b0
movl 0x2c2b8(%rip), %eax     # 0x40aa0
cmpl $0xa, %eax
setl %cl
movb 0x25646(%rip), %dl      # 0x39e3a
testb %dl, %dl
sete %sil
andb %cl, %sil
cmpb $0x64, %dl
setae %cl
orb %sil, %cl
jne 0x142d5
jmp 0x150b4
movl $0x0, 0x28(%rsp)
xorl %ebx, %ebx
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
cmpb $0x1, 0x2c24c(%rip)     # 0x40a78
jne 0x14a28
movl 0x26388(%rip), %ebp     # 0x3abc0
cmpb $0x1, 0x255e6(%rip)     # 0x39e25
jne 0x1484d
leaq 0x1d6f0(%rip), %rdi     # 0x31f38
callq 0x2400
cmpb $0x0, 0x255e2(%rip)     # 0x39e36
jne 0x1485f
cmpb $0x1, 0x255d2(%rip)     # 0x39e2f
jne 0x1489a
movd 0x24ac9(%rip), %xmm0    # 0x39330
movss 0x2c0d1(%rip), %xmm1    # 0x40940
leaq 0x24ff2(%rip), %rdi     # 0x39868
leaq 0x24b4b(%rip), %rsi     # 0x393c8
leaq 0x24b5c(%rip), %rdx     # 0x393e0
leaq 0x2506d(%rip), %rcx     # 0x398f8
movl %ebp, %r8d
leaq 0x2bcdb(%rip), %r9      # 0x40570
callq 0x26c76
cmpb $0x1, 0x25584(%rip)     # 0x39e25
jne 0x148af
leaq 0x1d691(%rip), %rdi     # 0x31f3b
callq 0x2400
cmpb $0x1, 0x25576(%rip)     # 0x39e2c
movss 0x1bb3a(%rip), %xmm1    # 0x303f8
jne 0x148e9
movq 0x24b31(%rip), %rax     # 0x393f8
movss 0x1bb29(%rip), %xmm1    # 0x303f8
cmpq %rax, 0x24b2a(%rip)     # 0x39400
je 0x148e9
movslq 0x26309(%rip), %rcx     # 0x3abe8
imulq $0x70, %rcx, %rcx
movss 0x68(%rax,%rcx), %xmm1
movss 0x24a3f(%rip), %xmm0    # 0x39330
ucomiss 0x1bb10(%rip), %xmm0    # 0x30408
jb 0x14951
movl 0x262bf(%rip), %r8d     # 0x3abc0
movl 0x262bc(%rip), %r9d     # 0x3abc4
movl 0x275d2(%rip), %eax     # 0x3bee0
movss 0x2c02a(%rip), %xmm2    # 0x40940
movl 0x2bac7(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x24aa0(%rip), %rdi     # 0x393c8
leaq 0x24ab1(%rip), %rsi     # 0x393e0
leaq 0x2bff6(%rip), %rdx     # 0x4092c
leaq 0x2c01b(%rip), %rcx     # 0x40958
pushq %r10
pushq %rax
leaq 0x24fb1(%rip), %rax     # 0x398f8
pushq %rax
callq 0x2129d
addq $0x20, %rsp
cmpb $0x1, 0x254cd(%rip)     # 0x39e25
jne 0x14966
leaq 0x1d5dd(%rip), %rdi     # 0x31f3e
callq 0x2400
movq 0x24fb3(%rip), %rax     # 0x39920
bswapq %rax
movabsq $0x302e302e302e3001, %rcx # imm = 0x302E302E302E3001
cmpq %rcx, %rax
jb 0x14984
callq 0x5a8c
cmpb $0x1, 0x2549a(%rip)     # 0x39e25
jne 0x14999
leaq 0x1d5ad(%rip), %rdi     # 0x31f41
callq 0x2400
cmpl $0x0, 0x18(%rsp)
jne 0x149cf
cmpl $0x0, 0x254d5(%rip)     # 0x39e7c
js 0x149cf
testb $0x1, 0x28(%rsp)
je 0x149cf
cmpb $0x1, 0x2546e(%rip)     # 0x39e25
jne 0x149c5
leaq 0x1d585(%rip), %rdi     # 0x31f45
callq 0x2400
leaq 0x10(%rsp), %rdi
callq 0xea42
cmpb $0x1, 0x2544f(%rip)     # 0x39e25
jne 0x149e4
leaq 0x1d56a(%rip), %rdi     # 0x31f49
callq 0x2400
cmpl $0x0, 0x18(%rsp)
sete %al
movl %eax, 0x28(%rsp)
cmpb $0x1, 0x2542e(%rip)     # 0x39e25
jne 0x14a05
leaq 0x1d54c(%rip), %rdi     # 0x31f4c
callq 0x2400
cmpl $0x0, 0x18(%rsp)
jne 0x14a11
callq 0x7dad
cmpb $0x1, 0x2540d(%rip)     # 0x39e25
jne 0x14a28
leaq 0x1d2f1(%rip), %rdi     # 0x31d12
xorl %eax, %eax
callq 0x2040
cmpl $0x0, 0x18(%rsp)
jne 0x14a39
leaq 0x10(%rsp), %rdi
callq 0xfdd4
movl 0x18(%rsp), %esi
testl %esi, %esi
je 0x1506d
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
addl $0x1f, %esi
andl $-0x20, %esi
leaq 0x30(%rsp), %rdi
callq 0x152b0
movl 0x18(%rsp), %edi
addq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
xorl %esi, %esi
callq 0x2140
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %edx
callq 0x21f0
leaq 0x24990(%rip), %rdi     # 0x39428
leaq 0x2c031(%rip), %rsi     # 0x40ad0
movl $0x20, %edx
callq 0x16dde
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
subq %rdx, %rcx
shrq $0x5, %rcx
leaq 0x24967(%rip), %rdi     # 0x39428
movq %rdx, %rsi
movl $0x1, %r8d
callq 0x1b2f4
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movups -0x20(%rax), %xmm0
movups -0x10(%rax), %xmm1
movl %eax, %edx
subl %esi, %edx
movaps %xmm0, 0x2bfe4(%rip)    # 0x40ad0
movaps %xmm1, 0x2bfed(%rip)    # 0x40ae0
movl 0xc(%rsp), %edi
callq 0x20a84
movl %eax, %ebp
testl %eax, %eax
js 0x14ce8
movl $0x1, %edi
callq 0x21b0
leaq 0x1d21e(%rip), %rdi     # 0x31d35
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
cmpb $0x1, 0x252fb(%rip)     # 0x39e25
jne 0x14b3f
leaq 0x1d207(%rip), %rdi     # 0x31d3a
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
movq 0x2606a(%rip), %r8      # 0x3abb0
movq %r8, %rax
movabsq $0x1845c8a0ce512957, %r14 # imm = 0x1845C8A0CE512957
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xd, %rdx
addq %rax, %rdx
imulq $0x15180, %rdx, %rcx    # imm = 0x15180
movq %r8, %rax
subq %rcx, %rax
movabsq $0x48d159e26af37c05, %rsi # imm = 0x48D159E26AF37C05
imulq %rsi
movq %rdx, %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xa, %rcx
addq %rax, %rcx
movq %r8, %rax
imulq %rsi
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xa, %rdx
addq %rax, %rdx
imulq $0xe10, %rdx, %rax      # imm = 0xE10
movq %r8, %r9
subq %rax, %r9
movq %r9, %rax
movabsq $-0x7777777777777777, %rsi # imm = 0x8888888888888889
imulq %rsi
addq %rdx, %r9
movq %r9, %rax
shrq $0x3f, %rax
sarq $0x5, %r9
addq %rax, %r9
movq %r8, %rax
imulq %rsi
addq %r8, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x5, %rdx
addq %rax, %rdx
imulq $0x3c, %rdx, %rax
subq %rax, %r8
leaq 0x1d14a(%rip), %rdi     # 0x31d40
leaq 0x1d07b(%rip), %rsi     # 0x31c78
movq %rcx, %rdx
movq %r9, %rcx
xorl %eax, %eax
callq 0x2040
cvtss2sd 0x2bd4e(%rip), %xmm0    # 0x40960
movss 0x2528e(%rip), %xmm4    # 0x39ea8
movss 0x2bd16(%rip), %xmm1    # 0x40938
mulss %xmm4, %xmm1
movss 0x1b7b2(%rip), %xmm5    # 0x303e0
divss %xmm5, %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x2bd2a(%rip), %xmm2    # 0x40968
mulss %xmm4, %xmm2
divss %xmm5, %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x2bcea(%rip), %xmm3    # 0x4093c
mulss %xmm4, %xmm3
divss %xmm5, %xmm3
cvtss2sd %xmm3, %xmm3
mulss 0x2bcf6(%rip), %xmm4    # 0x4095c
divss %xmm5, %xmm4
cvtss2sd %xmm4, %xmm4
leaq 0x1d0dd(%rip), %rdi     # 0x31d52
movb $0x5, %al
callq 0x2040
movq 0x25f35(%rip), %rcx     # 0x3abb8
movq %rcx, %rax
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xd, %rdx
addq %rax, %rdx
imulq $0x15180, %rdx, %rax    # imm = 0x15180
subq %rax, %rcx
cmpq $-0x383, %rcx           # imm = 0xFC7D
jl 0x14d49
cmpb $0x1, 0x2517b(%rip)     # 0x39e30
jne 0x14d49
movl 0x2bbc3(%rip), %eax     # 0x40884
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x1b5d7(%rip), %xmm0    # 0x302a8
movq 0x24708(%rip), %rax     # 0x393e0
cmpq %rax, 0x24709(%rip)     # 0x393e8
je 0x14d06
movss 0x1c(%rax), %xmm1
jmp 0x14d09
callq 0x2030
movl (%rax), %edx
leaq 0x1d01f(%rip), %rdi     # 0x31d15
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
movb $0x1, %bl
jmp 0x15056
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm0
movl 0x2bb7d(%rip), %eax     # 0x40890
cvtss2sd %xmm0, %xmm0
mulss 0x25189(%rip), %xmm1    # 0x39ea8
divss 0x1b6b9(%rip), %xmm1    # 0x303e0
cvtss2sd %xmm1, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
divsd 0x1b56d(%rip), %xmm2    # 0x302a8
leaq 0x1d037(%rip), %rdi     # 0x31d79
movb $0x3, %al
callq 0x2040
leaq 0x1c7f1(%rip), %rdi     # 0x31541
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
movb 0x2bdae(%rip), %al      # 0x40b10
testb %al, %al
je 0x150aa
movl $0x0, 0x2c(%rsp)
testb $0x1, %bl
jne 0x15056
movslq 0x2bd6e(%rip), %rax     # 0x40af0
testq %rax, %rax
jg 0x14d92
cmpl $0x0, 0x2c(%rsp)
jne 0x15056
movq 0x2bd67(%rip), %rsi     # 0x40b00
subq 0x2bd58(%rip), %rsi     # 0x40af8
movq %rsi, %rcx
subq %rax, %rcx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x14dcf
cmpq $0x10016, %rsi          # imm = 0x10016
jae 0x15097
addq $0x1000, %rsi           # imm = 0x1000
leaq 0x2bd2e(%rip), %rdi     # 0x40af8
callq 0x152b0
movq 0x2bd22(%rip), %rax     # 0x40af8
movslq 0x2bd13(%rip), %rsi     # 0x40af0
movl 0x2bd1d(%rip), %edx     # 0x40b00
subl %eax, %edx
subl %esi, %edx
addq %rax, %rsi
movl 0xc(%rsp), %edi
callq 0x20adc
testl %eax, %eax
js 0x1500d
je 0x15027
addl %eax, 0x2bce9(%rip)     # 0x40af0
movb $0x1, %r13b
testb $0x1, %bl
jne 0x1504d
movslq 0x2bcd6(%rip), %r14     # 0x40af0
movq %r14, %r12
andq $-0x20, %r12
testl %r12d, %r12d
je 0x14f49
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x152b0
leaq 0x247e5(%rip), %rdi     # 0x39634
leaq 0x2bc5a(%rip), %rsi     # 0x40ab0
movl $0x20, %edx
callq 0x16dde
movq 0x2bc91(%rip), %rsi     # 0x40af8
movq 0x60(%rsp), %rdx
sarl $0x5, %r14d
leaq 0x247bd(%rip), %rdi     # 0x39634
movl %r14d, %ecx
movl $0x1, %r8d
callq 0x1fee4
movq 0x60(%rsp), %r14
movq %r15, %rdi
callq 0x1599c
leaq 0x98(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %r12d, 0x5c(%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x5c(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x160ea
movl %eax, %ebp
testl %eax, %eax
js 0x14f51
movq 0x84(%rsp), %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x26ff2(%rip)     # 0x3bed8
cmpq %rax, 0xa0(%rsp)
je 0x14f37
movl $0x1, %r14d
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
movq %r15, %rdi
callq 0x114f6
movl %r14d, %ecx
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
imulq %rsi, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0x14ef8
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
callq 0x162f2
jmp 0x14f5c
xorl %r14d, %r14d
jmp 0x15002
cmpl $-0x5, %ebp
movl $0x0, %eax
cmovel %eax, %ebp
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x14f79
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
movq %r15, %rdi
callq 0x159a8
testl %ebp, %ebp
js 0x14fd1
je 0x14fe8
addl $0x1f, %ebp
andl $0x7fffffe0, %ebp       # imm = 0x7FFFFFE0
movq 0x2bb61(%rip), %rdi     # 0x40af8
leaq (%rdi,%rbp), %rsi
movups -0x20(%rdi,%rbp), %xmm0
movups -0x10(%rdi,%rbp), %xmm1
movaps %xmm0, 0x2bb04(%rip)    # 0x40ab0
movaps %xmm1, 0x2bb0d(%rip)    # 0x40ac0
movq 0x2bb46(%rip), %rdx     # 0x40b00
subq %rsi, %rdx
callq 0x21f0
subl %ebp, 0x2bb28(%rip)     # 0x40af0
incl 0x2c(%rsp)
movb $0x1, %r14b
jmp 0x14feb
xorl %r14d, %r14d
leaq 0x1ce0a(%rip), %rdi     # 0x31de5
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
movb $0x1, %bl
jmp 0x14feb
xorl %r14d, %r14d
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15002
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
testb %r14b, %r14b
jne 0x14e07
jmp 0x1504d
callq 0x2030
movl (%rax), %esi
cmpl $0xb, %esi
jne 0x1503a
leaq 0x1cf49(%rip), %rdi     # 0x31f69
callq 0x2400
jmp 0x15035
leaq 0x1cf21(%rip), %rdi     # 0x31f4f
callq 0x2400
movb $0x1, %bl
xorl %r13d, %r13d
jmp 0x1504d
xorl %r13d, %r13d
leaq 0x1cd81(%rip), %rdi     # 0x31dc5
xorl %eax, %eax
callq 0x2040
movb $0x1, %bl
testb %r13b, %r13b
jne 0x14d72
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1506d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x168fa
testb $0x1, %bl
jne 0x145f4
cmpb $0x0, 0x24dae(%rip)     # 0x39e3a
je 0x1481b
jmp 0x145f4
leaq 0x1cd05(%rip), %rdi     # 0x31da3
xorl %eax, %eax
callq 0x2040
jmp 0x14cff
callq 0x2646
jmp 0x14d6a
leaq 0x1ce3a(%rip), %rdi     # 0x31ef5
callq 0x2400
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x150da
jmp 0x150da
jmp 0x150e1
movq %rax, %rbx
jmp 0x15149
jmp 0x150e1
movq %rax, %rbx
jmp 0x15132
jmp 0x150f1
jmp 0x150ec
jmp 0x150f1
movq %rax, %rbx
jmp 0x1511b
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x15111
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x78(%rsp), %rdi
callq 0x159a8
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15132
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x15149
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x50(%rsp), %rdi
callq 0x159a8
movq %rbx, %rdi
callq 0x24a0
nop