// File: /workspace/github_cpp_makefile_star2_O3/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 0x13fc5
movq %rsi, %rbx
movl %edi, %r13d
movl $0x1, %r14d
leaq 0x1dceb(%rip), %r15     # 0x31c47
leaq 0x1dceb(%rip), %r12     # 0x31c4e
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 0x13fac
movq %rbp, %rdi
leaq 0x1dcc5(%rip), %rsi     # 0x31c56
callq 0x2390
testl %eax, %eax
je 0x13fac
cmpb $0x2d, (%rbp)
jne 0x13fbd
cmpb $0x63, 0x1(%rbp)
jne 0x13fbd
cmpb $0x0, 0x2(%rbp)
jne 0x13fbd
movq 0x8(%rbx,%r14,8), %rsi
leaq 0x25c5c(%rip), %rdi     # 0x39c14
callq 0x2260
incq %r14
cmpq %r14, %r13
jne 0x13f63
leaq 0x26bec(%rip), %rdi     # 0x3abb8
callq 0x2250
movq 0x26be0(%rip), %rax     # 0x3abb8
movq %rax, 0x27fc1(%rip)     # 0x3bfa0
leaq 0x1dc76(%rip), %rdi     # 0x31c5c
callq 0x2210
callq 0x33b2
movb $0x0, 0x25e43(%rip)     # 0x39e3a
cmpb $0x0, 0x25e32(%rip)     # 0x39e30
je 0x141a9
leaq 0x1cfe8(%rip), %rdi     # 0x30ff3
leaq 0x1c92d(%rip), %rsi     # 0x3093f
callq 0x22e0
testq %rax, %rax
je 0x14040
movq %rax, %rbx
leaq 0x2b90a(%rip), %rdi     # 0x3f930
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x1cfb9(%rip), %rdi     # 0x31000
leaq 0x1c8f1(%rip), %rsi     # 0x3093f
callq 0x22e0
testq %rax, %rax
je 0x1407c
movq %rax, %rbx
leaq 0x2ae1e(%rip), %rdi     # 0x3ee80
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x1dbdd(%rip), %rdi     # 0x31c60
leaq 0x1c8b5(%rip), %rsi     # 0x3093f
callq 0x22e0
testq %rax, %rax
je 0x140b8
movq %rax, %rbx
leaq 0x2c342(%rip), %rdi     # 0x403e0
movl $0x4, %esi
movl $0x62, %edx
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x26af9(%rip), %rdi     # 0x3abb8
callq 0x2250
leaq 0x1cf0b(%rip), %rsi     # 0x30fd6
leaq 0x1cf0b(%rip), %rdx     # 0x30fdd
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0x1c854(%rip), %rsi     # 0x3093f
movq %rbx, %rdi
callq 0x22e0
testq %rax, %rax
je 0x1411c
movq %rax, %rbx
leaq 0x2c46e(%rip), %rdi     # 0x40570
movl $0x4, %esi
movl $0xc9, %edx
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
movq 0x26a85(%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 0x2c754(%rip), %rbx     # 0x408a0
leaq 0x1ce91(%rip), %rsi     # 0x30fe4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0x1c7db(%rip), %rsi     # 0x3093f
movq %rbx, %rdi
callq 0x22e0
testq %rax, %rax
je 0x14195
movq %rax, %rbx
leaq 0x27e45(%rip), %rdi     # 0x3bfc0
movl $0x4, %esi
movl $0xba0, %edx            # imm = 0xBA0
movq %rax, %rcx
callq 0x23e0
movq %rbx, %rdi
callq 0x2290
leaq 0x256cc(%rip), %rdi     # 0x39868
callq 0x24b54
movb 0x25c93(%rip), %cl      # 0x39e3a
jmp 0x141ab
xorl %ecx, %ecx
movl 0x2c8ef(%rip), %eax     # 0x40aa0
cmpl $0xa, %eax
setl %dl
testb %cl, %cl
sete %sil
andb %dl, %sil
cmpb $0x64, %cl
setae %cl
orb %sil, %cl
cmpb $0x1, %cl
jne 0x14fd2
leaq 0x78(%rsp), %r12
movabsq $-0x1111111111111111, %rbx # imm = 0xEEEEEEEEEEEEEEEF
movb $0x0, 0x25c52(%rip)     # 0x39e3a
incl %eax
movl %eax, 0x2c8b0(%rip)     # 0x40aa0
movslq 0x269cd(%rip), %rbp     # 0x3abc4
imulq $-0x77777777, %rbp, %r15 # imm = 0x88888889
shrq $0x20, %r15
addl %ebp, %r15d
movl %r15d, %eax
shrl $0x1f, %eax
sarl $0x5, %r15d
addl %eax, %r15d
imull $0x3c, %r15d, %eax
subl %eax, %ebp
movslq 0x269a1(%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 0x26960(%rip), %rdi     # 0x3aba8
callq 0x20f0
movq %rax, %rdi
leaq 0x1e1ea(%rip), %rsi     # 0x32441
callq 0x2430
leaq 0x25d5d(%rip), %rdi     # 0x39fc0
leaq 0x1da03(%rip), %rsi     # 0x31c6d
movq %rax, %rdx
leaq 0x1da05(%rip), %rcx     # 0x31c79
xorl %eax, %eax
callq 0x2050
callq 0x2cfc
leaq 0x1d9fe(%rip), %rdi     # 0x31c85
leaq 0x1d9eb(%rip), %rsi     # 0x31c79
xorl %eax, %eax
callq 0x2040
leaq 0x1da03(%rip), %rdi     # 0x31c9f
movl %r13d, %esi
movl %r14d, %edx
movl %r15d, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2040
cmpb $0x0, 0x25b80(%rip)     # 0x39e36
jne 0x142c5
cmpb $0x1, 0x25b70(%rip)     # 0x39e2f
jne 0x143dd
movl 0x268f4(%rip), %r8d     # 0x3abc0
movl 0x268f1(%rip), %r9d     # 0x3abc4
movl 0x27c07(%rip), %eax     # 0x3bee0
movss 0x2c65f(%rip), %xmm2    # 0x40940
movl 0x2c0fc(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x250d5(%rip), %r15     # 0x393c8
movq %r15, %rdi
leaq 0x250e3(%rip), %r13     # 0x393e0
movq %r13, %rsi
leaq 0x2c625(%rip), %rdx     # 0x4092c
leaq 0x2c64a(%rip), %rcx     # 0x40958
movss 0x1c1be(%rip), %xmm0    # 0x304d4
movss 0x1c0da(%rip), %xmm1    # 0x303f8
pushq %r10
pushq %rax
leaq 0x255d0(%rip), %r14     # 0x398f8
pushq %r14
callq 0x2117c
addq $0x20, %rsp
movd 0x24ff5(%rip), %xmm0    # 0x39330
movss 0x2c5fd(%rip), %xmm1    # 0x40940
movl 0x26876(%rip), %r8d     # 0x3abc0
leaq 0x25517(%rip), %rdi     # 0x39868
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
leaq 0x2c20f(%rip), %r9      # 0x40570
callq 0x26b59
cmpb $0x0, 0x25ace(%rip)     # 0x39e3b
je 0x143e6
movl 0x2684a(%rip), %r8d     # 0x3abc0
movl 0x26847(%rip), %r9d     # 0x3abc4
movl 0x27b5d(%rip), %eax     # 0x3bee0
movss 0x2c5b5(%rip), %xmm2    # 0x40940
movl 0x2c052(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x2502b(%rip), %rdi     # 0x393c8
leaq 0x2503c(%rip), %rsi     # 0x393e0
leaq 0x2c581(%rip), %rdx     # 0x4092c
leaq 0x2c5a6(%rip), %rcx     # 0x40958
movd 0x1c11a(%rip), %xmm0    # 0x304d4
movss 0x1c0b2(%rip), %xmm1    # 0x30474
pushq %r10
pushq %rax
leaq 0x2552c(%rip), %rax     # 0x398f8
pushq %rax
callq 0x2117c
addq $0x20, %rsp
jmp 0x143dd
callq 0x7e04
cmpb $0x0, 0x25a57(%rip)     # 0x39e3b
jne 0x143d8
callq 0x7e04
movl 0x25617(%rip), %edx     # 0x39a08
leaq 0x1d8c2(%rip), %rdi     # 0x31cba
leaq 0x254f9(%rip), %r14     # 0x398f8
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movl 0x255f9(%rip), %esi     # 0x39a08
movq %r14, %rdi
callq 0x20617
movl %eax, 0xc(%rsp)
testl %eax, %eax
js 0x146d0
leaq 0x1dae6(%rip), %rdi     # 0x31f10
callq 0x2400
movb $0x0, 0x2c63e(%rip)     # 0x40a74
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x2c66e(%rip)    # 0x40ab0
movdqa %xmm0, 0x2c676(%rip)    # 0x40ac0
movdqa %xmm0, 0x2c67e(%rip)    # 0x40ad0
movdqa %xmm0, 0x2c686(%rip)    # 0x40ae0
leaq 0x256b3(%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), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
leaq 0x2518b(%rip), %r14     # 0x39634
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x100, %edx            # imm = 0x100
callq 0x16c18
leaq 0x24f66(%rip), %r13     # 0x39428
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x100, %edx            # imm = 0x100
callq 0x16c18
movq %r14, %rdi
movq %r15, %rsi
callq 0x1b26c
movq %r13, %rdi
movq %r15, %rsi
callq 0x16c96
leaq 0x50(%rsp), %rdi
callq 0x15898
cmpb $0x0, 0x2593f(%rip)     # 0x39e3a
je 0x14715
leaq 0x1d88b(%rip), %rdi     # 0x31d93
xorl %eax, %eax
callq 0x2040
leaq 0x50(%rsp), %rdi
callq 0x158a4
movl 0x2c581(%rip), %esi     # 0x40aa0
leaq 0x1d7b0(%rip), %rdi     # 0x31cd6
xorl %eax, %eax
callq 0x2040
movl 0xc(%rsp), %edi
callq 0x2090a
movb 0x258fe(%rip), %al      # 0x39e3a
testb %al, %al
jne 0x14550
movl $0x1, %edi
callq 0x21b0
movb 0x258ea(%rip), %al      # 0x39e3a
movzbl %al, %esi
leaq 0x1d791(%rip), %rdi     # 0x31ceb
xorl %eax, %eax
callq 0x2040
cmpb $0x1, 0x258c8(%rip)     # 0x39e30
jne 0x146e6
leaq 0x1ca7e(%rip), %rdi     # 0x30ff3
leaq 0x1c247(%rip), %rsi     # 0x307c3
callq 0x22e0
testq %rax, %rax
je 0x145aa
movq %rax, %r14
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x2b396(%rip), %rdi     # 0x3f930
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x1ca4f(%rip), %rdi     # 0x31000
leaq 0x1c20b(%rip), %rsi     # 0x307c3
callq 0x22e0
testq %rax, %rax
je 0x145e6
movq %rax, %r14
movl $0x4, %esi
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x2a8aa(%rip), %rdi     # 0x3ee80
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x1d673(%rip), %rdi     # 0x31c60
leaq 0x1c1cf(%rip), %rsi     # 0x307c3
callq 0x22e0
testq %rax, %rax
je 0x14622
movq %rax, %r14
movl $0x4, %esi
movl $0x62, %edx
leaq 0x2bdce(%rip), %rdi     # 0x403e0
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x2658f(%rip), %rdi     # 0x3abb8
callq 0x2250
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x1c996(%rip), %rsi     # 0x30fd6
leaq 0x1c996(%rip), %rdx     # 0x30fdd
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
leaq 0x1c16b(%rip), %rsi     # 0x307c3
callq 0x22e0
testq %rax, %rax
je 0x14686
movq %rax, %r14
movl $0x4, %esi
movl $0xc9, %edx
leaq 0x2befa(%rip), %rdi     # 0x40570
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x2c213(%rip), %rdi     # 0x408a0
leaq 0x1c12f(%rip), %rsi     # 0x307c3
callq 0x22e0
testq %rax, %rax
je 0x146c2
movq %rax, %r14
movl $0x4, %esi
movl $0xba0, %edx            # imm = 0xBA0
leaq 0x2790e(%rip), %rdi     # 0x3bfc0
movq %rax, %rcx
callq 0x2510
movq %r14, %rdi
callq 0x2290
leaq 0x2519f(%rip), %rdi     # 0x39868
callq 0x24a71
jmp 0x146e6
leaq 0x1d850(%rip), %rdi     # 0x31f27
callq 0x2400
movl $0x1, %edi
callq 0x21b0
movl 0x2c3b4(%rip), %eax     # 0x40aa0
cmpl $0xa, %eax
setl %cl
movb 0x25742(%rip), %dl      # 0x39e3a
testb %dl, %dl
sete %sil
andb %cl, %sil
cmpb $0x64, %dl
setae %cl
orb %sil, %cl
jne 0x141e1
jmp 0x14fd2
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x8(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
cmpb $0x1, 0x2c33e(%rip)     # 0x40a74
jne 0x1493e
movl 0x2647e(%rip), %ebp     # 0x3abc0
cmpb $0x1, 0x256dc(%rip)     # 0x39e25
jne 0x14757
leaq 0x1d7e7(%rip), %rdi     # 0x31f39
callq 0x2400
cmpb $0x0, 0x256d8(%rip)     # 0x39e36
jne 0x14769
cmpb $0x1, 0x256c8(%rip)     # 0x39e2f
jne 0x147a4
movd 0x24bbf(%rip), %xmm0    # 0x39330
movss 0x2c1c7(%rip), %xmm1    # 0x40940
leaq 0x250e8(%rip), %rdi     # 0x39868
leaq 0x24c41(%rip), %rsi     # 0x393c8
leaq 0x24c52(%rip), %rdx     # 0x393e0
leaq 0x25163(%rip), %rcx     # 0x398f8
movl %ebp, %r8d
leaq 0x2bdd1(%rip), %r9      # 0x40570
callq 0x26b59
cmpb $0x1, 0x2567a(%rip)     # 0x39e25
jne 0x147b9
leaq 0x1d788(%rip), %rdi     # 0x31f3c
callq 0x2400
cmpb $0x1, 0x2566c(%rip)     # 0x39e2c
movss 0x1bc30(%rip), %xmm1    # 0x303f8
jne 0x147f3
movq 0x24c27(%rip), %rax     # 0x393f8
movss 0x1bc1f(%rip), %xmm1    # 0x303f8
cmpq %rax, 0x24c20(%rip)     # 0x39400
je 0x147f3
movslq 0x263ff(%rip), %rcx     # 0x3abe8
imulq $0x70, %rcx, %rcx
movss 0x68(%rax,%rcx), %xmm1
movss 0x24b35(%rip), %xmm0    # 0x39330
ucomiss 0x1bc06(%rip), %xmm0    # 0x30408
jb 0x1485b
movl 0x263b5(%rip), %r8d     # 0x3abc0
movl 0x263b2(%rip), %r9d     # 0x3abc4
movl 0x276c8(%rip), %eax     # 0x3bee0
movss 0x2c120(%rip), %xmm2    # 0x40940
movl 0x2bbbd(%rip), %r10d    # 0x403e4
subq $0x8, %rsp
leaq 0x24b96(%rip), %rdi     # 0x393c8
leaq 0x24ba7(%rip), %rsi     # 0x393e0
leaq 0x2c0ec(%rip), %rdx     # 0x4092c
leaq 0x2c111(%rip), %rcx     # 0x40958
pushq %r10
pushq %rax
leaq 0x250a7(%rip), %rax     # 0x398f8
pushq %rax
callq 0x2117c
addq $0x20, %rsp
cmpb $0x1, 0x255c3(%rip)     # 0x39e25
jne 0x14870
leaq 0x1d6d4(%rip), %rdi     # 0x31f3f
callq 0x2400
movq 0x250a9(%rip), %rax     # 0x39920
bswapq %rax
movabsq $0x302e302e302e3001, %rcx # imm = 0x302E302E302E3001
cmpq %rcx, %rax
jb 0x1488e
callq 0x5a7d
movb 0x25591(%rip), %al      # 0x39e25
cmpb $0x1, %al
jne 0x148aa
leaq 0x1d6a3(%rip), %rdi     # 0x31f42
callq 0x2400
movb 0x2557b(%rip), %al      # 0x39e25
cmpl $0x0, 0x18(%rsp)
sete %cl
cmpl $0x0, 0x255c3(%rip)     # 0x39e7c
setns %dl
andb %cl, %dl
andb 0x2c(%rsp), %dl
cmpb $0x1, %dl
jne 0x148e7
testb $0x1, %al
je 0x148d7
leaq 0x1d674(%rip), %rdi     # 0x31f46
callq 0x2400
leaq 0x10(%rsp), %rdi
callq 0xe9cb
movb 0x2553e(%rip), %al      # 0x39e25
testb $0x1, %al
je 0x148fd
leaq 0x1d658(%rip), %rdi     # 0x31f4a
callq 0x2400
movb 0x25528(%rip), %al      # 0x39e25
movl 0x18(%rsp), %ecx
testl %ecx, %ecx
sete %dl
movl %edx, 0x2c(%rsp)
testb $0x1, %al
je 0x1491e
leaq 0x1d638(%rip), %rdi     # 0x31f4d
callq 0x2400
movl 0x18(%rsp), %ecx
testl %ecx, %ecx
jne 0x14927
callq 0x7e04
cmpb $0x1, 0x254f7(%rip)     # 0x39e25
jne 0x1493e
leaq 0x1d3dc(%rip), %rdi     # 0x31d13
xorl %eax, %eax
callq 0x2040
movl 0x18(%rsp), %esi
testl %esi, %esi
jne 0x1495c
leaq 0x10(%rsp), %rdi
callq 0xfcfc
movl 0x18(%rsp), %esi
testl %esi, %esi
je 0x14c3f
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
addl $0x1f, %esi
andl $-0x20, %esi
leaq 0x30(%rsp), %rdi
callq 0x151b2
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 0x24a79(%rip), %rdi     # 0x39428
leaq 0x2c11a(%rip), %rsi     # 0x40ad0
movl $0x20, %edx
callq 0x16c7e
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
subq %rdx, %rcx
shrq $0x5, %rcx
leaq 0x24a50(%rip), %rdi     # 0x39428
movq %rdx, %rsi
movl $0x1, %r8d
callq 0x1b194
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movups -0x20(%rax), %xmm0
movups -0x10(%rax), %xmm1
movl %eax, %edx
subl %esi, %edx
movaps %xmm0, 0x2c0cd(%rip)    # 0x40ad0
movaps %xmm1, 0x2c0d6(%rip)    # 0x40ae0
movl 0xc(%rsp), %edi
callq 0x20921
movl %eax, %ebp
testl %eax, %eax
js 0x14c0b
movl $0x1, %edi
callq 0x21b0
leaq 0x1d308(%rip), %rdi     # 0x31d36
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
cmpb $0x1, 0x253e4(%rip)     # 0x39e25
jne 0x14a56
leaq 0x1d2f1(%rip), %rdi     # 0x31d3b
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
movq 0x26153(%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, %rax    # imm = 0x15180
movq %r8, %rcx
subq %rax, %rcx
movslq %ecx, %rax
imulq $-0x6e5d4c3b, %rax, %rcx # imm = 0x91A2B3C5
shrq $0x20, %rcx
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
sarl $0xb, %eax
addl %ecx, %eax
movslq %eax, %r9
movq %r8, %rax
movabsq $0x48d159e26af37c05, %rcx # imm = 0x48D159E26AF37C05
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0xa, %rdx
addl %eax, %edx
imull $0xe10, %edx, %eax      # imm = 0xE10
movl %r8d, %ecx
subl %eax, %ecx
movswl %cx, %eax
imull $0xffff8889, %eax, %eax # imm = 0xFFFF8889
shrl $0x10, %eax
addl %ecx, %eax
movzwl %ax, %eax
movswl %ax, %ecx
shrl $0xf, %eax
sarl $0x5, %ecx
addl %eax, %ecx
movswq %cx, %rcx
movq %r8, %rax
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
imulq %rdx
addq %r8, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x5, %rdx
addq %rax, %rdx
imulq $0x3c, %rdx, %rax
subq %rax, %r8
leaq 0x1d225(%rip), %rdi     # 0x31d41
leaq 0x1d156(%rip), %rsi     # 0x31c79
movq %r9, %rdx
xorl %eax, %eax
callq 0x2040
cvtss2sd 0x2be2b(%rip), %xmm0    # 0x40960
movss 0x2536b(%rip), %xmm4    # 0x39ea8
movss 0x2bdf3(%rip), %xmm1    # 0x40938
mulss %xmm4, %xmm1
movss 0x1b88f(%rip), %xmm5    # 0x303e0
divss %xmm5, %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x2be07(%rip), %xmm2    # 0x40968
mulss %xmm4, %xmm2
divss %xmm5, %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x2bdc7(%rip), %xmm3    # 0x4093c
mulss %xmm4, %xmm3
divss %xmm5, %xmm3
cvtss2sd %xmm3, %xmm3
mulss 0x2bdd3(%rip), %xmm4    # 0x4095c
divss %xmm5, %xmm4
cvtss2sd %xmm4, %xmm4
leaq 0x1d1bb(%rip), %rdi     # 0x31d53
movb $0x5, %al
callq 0x2040
movq 0x26012(%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 0x14cae
cmpb $0x1, 0x25258(%rip)     # 0x39e30
jne 0x14cae
movl 0x2bca0(%rip), %eax     # 0x40884
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x1b6b4(%rip), %xmm0    # 0x302a8
movq 0x247e5(%rip), %rax     # 0x393e0
cmpq %rax, 0x247e6(%rip)     # 0x393e8
je 0x14c6b
movss 0x1c(%rax), %xmm1
jmp 0x14c6e
callq 0x2030
movl (%rax), %edx
leaq 0x1d0fd(%rip), %rdi     # 0x31d16
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
movb $0x1, %al
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x14c3f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x16798
testb $0x1, 0x8(%rsp)
jne 0x14501
cmpb $0x0, 0x251da(%rip)     # 0x39e3a
je 0x14725
jmp 0x14501
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm0
movl 0x2bc18(%rip), %eax     # 0x40890
cvtss2sd %xmm0, %xmm0
mulss 0x25224(%rip), %xmm1    # 0x39ea8
divss 0x1b754(%rip), %xmm1    # 0x303e0
cvtss2sd %xmm1, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
divsd 0x1b608(%rip), %xmm2    # 0x302a8
leaq 0x1d0d3(%rip), %rdi     # 0x31d7a
movb $0x3, %al
callq 0x2040
leaq 0x1c890(%rip), %rdi     # 0x31545
movl $0x1b, %esi
xorl %eax, %eax
callq 0x2040
movb 0x2be49(%rip), %al      # 0x40b10
testb %al, %al
je 0x14fc8
xorl %r13d, %r13d
movl 0x2be18(%rip), %ebp     # 0x40af0
movq 0x2be21(%rip), %rdx     # 0x40b00
movq 0x2be12(%rip), %rax     # 0x40af8
subq %rax, %rdx
movslq %ebp, %rsi
movq %rdx, %rcx
subq %rsi, %rcx
cmpq $0xfff, %rcx            # imm = 0xFFF
ja 0x14d38
cmpq $0x10016, %rdx          # imm = 0x10016
jae 0x14f9f
addq $0x1000, %rdx           # imm = 0x1000
leaq 0x2bde2(%rip), %rdi     # 0x40af8
movq %rdx, %rsi
callq 0x151b2
movq 0x2bdd3(%rip), %rax     # 0x40af8
movl 0x2bdc5(%rip), %ebp     # 0x40af0
movq 0x2bdce(%rip), %rdx     # 0x40b00
movslq %ebp, %rsi
subq %rax, %rdx
addq %rax, %rsi
subl %ebp, %edx
movl 0xc(%rsp), %edi
callq 0x2096d
testl %eax, %eax
js 0x14f71
je 0x14f8e
addl %eax, 0x2bd96(%rip)     # 0x40af0
testb $0x1, 0x8(%rsp)
jne 0x14c28
movslq 0x2bd84(%rip), %rbp     # 0x40af0
movq %rbp, %r15
andq $-0x20, %r15
testl %r15d, %r15d
je 0x14f59
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x151b2
leaq 0x24893(%rip), %rdi     # 0x39634
leaq 0x2bd08(%rip), %rsi     # 0x40ab0
movl $0x20, %edx
callq 0x16c7e
movq 0x2bd3f(%rip), %rsi     # 0x40af8
movq 0x60(%rsp), %rdx
sarl $0x5, %ebp
leaq 0x2486c(%rip), %rdi     # 0x39634
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x1fd86
movq 0x60(%rsp), %r14
movq %r12, %rdi
callq 0x15898
leaq 0x98(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %r15d, 0x5c(%rsp)
movq %r12, %rdi
movq %r14, %rsi
leaq 0x5c(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x15f94
movl %eax, %ebp
testl %eax, %eax
js 0x14e8b
movq 0x84(%rsp), %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x270a6(%rip)     # 0x3bed8
cmpq %rax, 0xa0(%rsp)
je 0x14e79
movl $0x1, %r14d
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
movq %r12, %rdi
callq 0x11438
movl %r14d, %ecx
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
imulq %rbx, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0x14e44
movq %r12, %rdi
leaq 0x98(%rsp), %rsi
callq 0x16190
jmp 0x14e96
cmpl $-0x5, %ebp
movl $0x0, %eax
cmovel %eax, %ebp
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x14eb3
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
movq %r12, %rdi
callq 0x158a4
testl %ebp, %ebp
js 0x14f0a
je 0x14f25
addl $0x1f, %ebp
andl $0x7fffffe0, %ebp       # imm = 0x7FFFFFE0
movq 0x2bc27(%rip), %rdi     # 0x40af8
leaq (%rdi,%rbp), %rsi
movups -0x20(%rdi,%rbp), %xmm0
movups -0x10(%rdi,%rbp), %xmm1
movaps %xmm0, 0x2bbca(%rip)    # 0x40ab0
movaps %xmm1, 0x2bbd3(%rip)    # 0x40ac0
movq 0x2bc0c(%rip), %rdx     # 0x40b00
subq %rsi, %rdx
callq 0x21f0
subl %ebp, 0x2bbee(%rip)     # 0x40af0
incl %r13d
movb $0x1, %r14b
jmp 0x14f28
xorl %r14d, %r14d
leaq 0x1ced2(%rip), %rdi     # 0x31de6
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
movb $0x1, %al
movl %eax, 0x8(%rsp)
jmp 0x14f28
xorl %r14d, %r14d
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x14f3f
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
testb %r14b, %r14b
jne 0x14d5a
testb $0x1, 0x8(%rsp)
jne 0x14c28
movl 0x2bb97(%rip), %ebp     # 0x40af0
testl %ebp, %ebp
setg %al
testl %r13d, %r13d
sete %cl
orb %al, %cl
jne 0x14cd8
jmp 0x14c28
callq 0x2030
movl (%rax), %esi
cmpl $0xb, %esi
jne 0x14fb5
leaq 0x1cfe6(%rip), %rdi     # 0x31f6a
callq 0x2400
jmp 0x14c28
leaq 0x1cfbb(%rip), %rdi     # 0x31f50
callq 0x2400
jmp 0x14c22
leaq 0x1cdfe(%rip), %rdi     # 0x31da4
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2040
jmp 0x14c22
leaq 0x1ce0a(%rip), %rdi     # 0x31dc6
xorl %eax, %eax
callq 0x2040
jmp 0x14c22
callq 0x2646
jmp 0x14ccf
leaq 0x1cf1d(%rip), %rdi     # 0x31ef6
callq 0x2400
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14ff6
jmp 0x14ff6
movq %rax, %rbx
jmp 0x15067
jmp 0x14fff
jmp 0x14fff
movq %rax, %rbx
jmp 0x15050
jmp 0x1500f
jmp 0x1500f
jmp 0x1500a
movq %rax, %rbx
jmp 0x15039
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1502f
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x78(%rsp), %rdi
callq 0x158a4
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15050
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x15067
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x22b0
leaq 0x50(%rsp), %rdi
callq 0x158a4
movq %rbx, %rdi
callq 0x24a0
nop