// File: lianxings[P]ftp_benchmark/ftp_benchmark.cc
// Function: local2ftp_worker(ftpInfo*, int, bool)
void local2ftp_worker(ftpInfo * pFtp, int id, bool verify) 
{
    string srcPath, dstPath;
    int ioUnit = 256 << 10;
    char *dataBuf = new char[ioUnit];
    char printBuf[1024];
    char sizeStrBuf[128];
    ftplib::accesstype type = ftplib::filewrite;
    ftplib::transfermode mode = ftplib::image;
    FILE *local = NULL;
    ftphandle *nData = NULL;
    char ac[3] = "rb";

    ftplib * ftpClient = new ftplib();
    int ret = connect_and_login_ftp (ftpClient, pFtp, 0);
    if (ret < 0) {
        if (ret == -2)
            fprintf(stderr, "login ftp server %s failed.\n", pFtp->ftpServer);
        --liveWorkThread;
        return;
    }

    while((!tasksQueue.empty()) || (!exitFlag)) {
        task<fileInfo> taskTmp;  
        if (get_task_from_queue(taskTmp) < 0) 
            continue;

        fileInfo srcInfo, dstInfo;
        srcInfo = taskTmp.src;
        dstInfo = taskTmp.dst;
        srcPath = srcInfo.name;
        dstPath = dstInfo.name;
        memset(printBuf, 0, sizeof(printBuf));
        memset(printBuf, 0, sizeof(sizeStrBuf));
        size_to_string(srcInfo.size, sizeStrBuf);
        local = fopen64(srcPath.c_str(), ac);
        if (local == NULL) {
            ++failed;
            errorSize += srcInfo.size;
            sprintf(printBuf, "\nopen source file failed: source: %s, destination: %s, size: %s\n",\
                                                      srcPath.c_str(), dstPath.c_str(), sizeStrBuf);
            fwrite(printBuf, 1, strlen(printBuf), errorFd);
            write(1, printBuf, strlen(printBuf));
            if (failed <= 10) {
                continue;
            } else {
                --liveWorkThread;
                break;
            }
        }
        // get ftp data connection 
        int ret = build_ftp_data_connection(dstPath, type, mode, ftpClient, pFtp, &nData);
        if (ret < 0) {
            ++failed;
            errorSize += srcInfo.size;
            if (ret == -1)
                sprintf(printBuf, "\nget ftp data connection failed: source: %s, destination: %s, size: %s\n",\
                                                                srcPath.c_str(), dstPath.c_str(), sizeStrBuf);
            else
                sprintf(printBuf, "\nre-login ftp server %s failed: source: %s, destination: %s, size: %s\n",\
                                             pFtp->ftpServer , srcPath.c_str(), dstPath.c_str(), sizeStrBuf);
            fwrite(printBuf, 1, strlen(printBuf), errorFd);
            write(2, printBuf, strlen(printBuf));
            if (local != NULL) fclose(local);
            continue;
        }

        Md5Context md5Context;
        if (verify){
            Md5Initialise( &md5Context );
        }


        int readed = 0;
		while ((readed = fread(dataBuf, 1, ioUnit, local)) > 0) {
			if (ftpClient->FtpWrite(dataBuf, readed, nData) < readed) {
                ++failed;
                errorSize += srcInfo.size;
                sprintf(printBuf, "\nftp write failed: source: %s, destination: %s, size: %s\n",\
                                                  srcPath.c_str(), dstPath.c_str(), sizeStrBuf);
                fwrite(printBuf, 1, strlen(printBuf), errorFd);
                write(1, printBuf, strlen(printBuf));
                break;
            }
            if (verify) {
                Md5Update( &md5Context, (const void*)dataBuf, readed);
            }
            finishSize += readed;
        }
        ftpClient->FtpClose(nData);
        char md5str[33] = {'\0'};
        if (readed < 0) {
            ++failed;
            errorSize += srcInfo.size;
            sprintf(printBuf, "\nread source file failed: source: %s, destination: %s, size: %s\n",\
                                                     srcPath.c_str(), dstPath.c_str(), sizeStrBuf);
            fwrite(printBuf, 1, strlen(printBuf), errorFd);
            write(1, printBuf, strlen(printBuf));
        } else {
            ++finished;
            if(verify) {
                MD5_HASH md5;
                char tmp[3] = {'\0'};
                Md5Finalise( &md5Context, &md5);
                memset(md5str, 0, sizeof(md5str));
                for(int j = 0; j < sizeof(md5); j++ ) {
                    sprintf( tmp,"%2.2x", md5.bytes[j]);
                    strcat(md5str, tmp);
                }
            }
        }
        
        fflush(local);
        if (local != NULL) fclose(local);
        
        if (verify) {   // if need to verify, upload a new file just store md5sum
            string newFilePath = dstPath + ".md5";
            ret = build_ftp_data_connection(newFilePath, type, mode, ftpClient, pFtp, &nData);
            if (ret < 0) {
                ++md5Failed;
                if (ret == -1)
                    sprintf(printBuf, "\nget ftp data connection failed: upload md5 file %s\n",\
                                                                          newFilePath.c_str());
                else
                    sprintf(printBuf, "\nre-login ftp server %s failed: upload md5 file %s\n",\
                                                       pFtp->ftpServer , newFilePath.c_str());
                fwrite(printBuf, 1, strlen(printBuf), errorFd);
                write(2, printBuf, strlen(printBuf));
                continue;
            }

            if (ftpClient->FtpWrite(md5str, strlen(md5str), nData) < strlen(md5str)) {
                ++md5Failed;
                sprintf(printBuf, "\nftp upload file %s failed\n", newFilePath.c_str());
                fwrite(printBuf, 1, strlen(printBuf), errorFd);
                write(2, printBuf, strlen(printBuf));
                break;
            }
            ftpClient->FtpClose(nData);
        }

        if (failed > 10) {
            --liveWorkThread;
            break;
        }
    }

    ftpClient->Quit();
    delete []dataBuf;
    delete ftpClient;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4650
leaq -0x50(%rbp), %rdi
callq 0x4650
movl $0x40000, -0x54(%rbp)   # imm = 0x40000
movslq -0x54(%rbp), %rdi
callq 0x4030
movq %rax, -0x710(%rbp)
jmp 0x5074
movq -0x710(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x4, -0x4f4(%rbp)
movl $0x49, -0x4f8(%rbp)
movq $0x0, -0x500(%rbp)
movq $0x0, -0x508(%rbp)
movb $0x0, -0x50a(%rbp)
movw $0x6272, -0x50c(%rbp)   # imm = 0x6272
movl $0x8, %edi
callq 0x44b0
movq %rax, -0x718(%rbp)
jmp 0x50cc
movq -0x718(%rbp), %rdi
callq 0x16370
jmp 0x50da
movq -0x718(%rbp), %rax
movq %rax, -0x518(%rbp)
movq -0x518(%rbp), %rdi
movq -0x8(%rbp), %rsi
xorl %edx, %edx
callq 0x5dd0
movl %eax, -0x71c(%rbp)
jmp 0x5102
movl -0x71c(%rbp), %eax
movl %eax, -0x51c(%rbp)
cmpl $0x0, -0x51c(%rbp)
jge 0x518f
cmpl $-0x2, -0x51c(%rbp)
jne 0x5174
movq 0x20ea1(%rip), %rax     # 0x25fc8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
leaq 0x17cfb(%rip), %rsi     # 0x1ce33
movb $0x0, %al
callq 0x4680
jmp 0x5174
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5db4
movq -0x718(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movl $0x8, %esi
callq 0x44c0
jmp 0x5db4
leaq 0x21475(%rip), %rdi     # 0x265f0
callq 0xd3c0
movl $0x1, -0x520(%rbp)
jmp 0x5d99
jmp 0x5191
leaq 0x21360(%rip), %rdi     # 0x264f8
callq 0xd3f0
movb %al, -0x71d(%rbp)
jmp 0x51a5
movb -0x71d(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x71e(%rbp)
jne 0x51ba
jmp 0x51d4
leaq 0x21427(%rip), %rdi     # 0x265e8
callq 0xd230
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x71e(%rbp)
movb -0x71e(%rbp), %al
testb $0x1, %al
jne 0x51e3
jmp 0x5d33
leaq -0x570(%rbp), %rdi
callq 0xd410
jmp 0x51f1
leaq -0x570(%rbp), %rdi
callq 0x5eb0
movl %eax, -0x724(%rbp)
jmp 0x5205
movl -0x724(%rbp), %eax
cmpl $0x0, %eax
jge 0x5230
movl $0x2, -0x520(%rbp)
jmp 0x5cd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5d22
leaq -0x598(%rbp), %rdi
callq 0xd460
jmp 0x523e
leaq -0x5c0(%rbp), %rdi
callq 0xd460
jmp 0x524c
leaq -0x598(%rbp), %rdi
leaq -0x570(%rbp), %rsi
callq 0xd4d0
jmp 0x5261
leaq -0x548(%rbp), %rsi
leaq -0x5c0(%rbp), %rdi
callq 0xd4d0
jmp 0x5276
leaq -0x30(%rbp), %rdi
leaq -0x598(%rbp), %rsi
callq 0x4050
jmp 0x5288
leaq -0x50(%rbp), %rdi
leaq -0x5c0(%rbp), %rsi
callq 0x4050
jmp 0x529a
leaq -0x470(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4250
xorps %xmm0, %xmm0
movaps %xmm0, -0x740(%rbp)
movaps %xmm0, -0x400(%rbp)
movaps %xmm0, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
movaps %xmm0, -0x430(%rbp)
movaps %xmm0, -0x440(%rbp)
movaps %xmm0, -0x450(%rbp)
movaps %xmm0, -0x460(%rbp)
movaps %xmm0, -0x470(%rbp)
movq -0x578(%rbp), %rdi
leaq -0x4f0(%rbp), %rsi
callq 0x15a90
jmp 0x5304
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, %rdi
leaq -0x50c(%rbp), %rsi
callq 0x4540
movq %rax, -0x748(%rbp)
jmp 0x5325
movq -0x748(%rbp), %rax
movq %rax, -0x500(%rbp)
cmpq $0x0, -0x500(%rbp)
jne 0x5456
leaq 0x212c0(%rip), %rdi     # 0x26608
callq 0xd510
movq -0x578(%rbp), %rsi
leaq 0x212cd(%rip), %rdi     # 0x26628
callq 0xd540
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, -0x758(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq -0x758(%rbp), %rdx
movq %rax, %rcx
leaq 0x16e73(%rip), %rsi     # 0x1c1fd
xorl %eax, %eax
leaq -0x470(%rbp), %rdi
movq %rdi, -0x750(%rbp)
leaq -0x4f0(%rbp), %r8
callq 0x40d0
movq -0x750(%rbp), %rdi
callq 0x41d0
movq -0x750(%rbp), %rdi
movq %rax, %rdx
movq 0x2121d(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x53cf
leaq -0x470(%rbp), %rdi
movq %rdi, -0x760(%rbp)
callq 0x41d0
movq -0x760(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
callq 0x4160
jmp 0x53f8
leaq 0x21209(%rip), %rdi     # 0x26608
callq 0xd2c0
cmpq $0xa, %rax
jg 0x543b
movl $0x2, -0x520(%rbp)
jmp 0x5cbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5d16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5d0a
leaq 0x211ae(%rip), %rdi     # 0x265f0
callq 0xd3c0
movl $0x3, -0x520(%rbp)
jmp 0x5cbc
leaq -0x5e8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x41c0
jmp 0x5468
movl -0x4f4(%rbp), %esi
movl -0x4f8(%rbp), %edx
movq -0x518(%rbp), %rcx
movq -0x8(%rbp), %r8
leaq -0x5e8(%rbp), %rdi
leaq -0x508(%rbp), %r9
callq 0x5fd0
movl %eax, -0x764(%rbp)
jmp 0x549a
leaq -0x5e8(%rbp), %rdi
callq 0x4280
movl -0x764(%rbp), %eax
movl %eax, -0x5c4(%rbp)
cmpl $0x0, -0x5c4(%rbp)
jge 0x5637
leaq 0x21142(%rip), %rdi     # 0x26608
callq 0xd510
movq -0x578(%rbp), %rsi
leaq 0x2114f(%rip), %rdi     # 0x26628
callq 0xd540
cmpl $-0x1, -0x5c4(%rbp)
jne 0x5553
leaq -0x470(%rbp), %rax
movq %rax, -0x778(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, -0x770(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq -0x778(%rbp), %rdi
movq -0x770(%rbp), %rdx
movq %rax, %rcx
leaq -0x4f0(%rbp), %r8
leaq 0x16d11(%rip), %rsi     # 0x1c23e
movb $0x0, %al
callq 0x40d0
jmp 0x55b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x5e8(%rbp), %rdi
callq 0x4280
jmp 0x5d0a
leaq -0x470(%rbp), %rax
movq %rax, -0x790(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x788(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, -0x780(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq -0x790(%rbp), %rdi
movq -0x788(%rbp), %rdx
movq -0x780(%rbp), %rcx
movq %rax, %r8
leaq -0x4f0(%rbp), %r9
leaq 0x16cd8(%rip), %rsi     # 0x1c286
movb $0x0, %al
callq 0x40d0
leaq -0x470(%rbp), %rdi
movq %rdi, -0x798(%rbp)
callq 0x41d0
movq -0x798(%rbp), %rdi
movq %rax, %rdx
movq 0x21007(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x55e5
leaq -0x470(%rbp), %rdi
movq %rdi, -0x7a0(%rbp)
callq 0x41d0
movq -0x7a0(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x4160
jmp 0x560e
cmpq $0x0, -0x500(%rbp)
je 0x5628
movq -0x500(%rbp), %rdi
callq 0x44a0
jmp 0x5626
jmp 0x5628
movl $0x2, -0x520(%rbp)
jmp 0x5cbc
testb $0x1, -0xd(%rbp)
je 0x564d
leaq -0x680(%rbp), %rdi
callq 0x1a1d0
jmp 0x564b
jmp 0x564d
movl $0x0, -0x684(%rbp)
movq -0x60(%rbp), %rdi
movslq -0x54(%rbp), %rdx
movq -0x500(%rbp), %rcx
movl $0x1, %esi
callq 0x46c0
movq %rax, -0x7a8(%rbp)
jmp 0x5679
movq -0x7a8(%rbp), %rax
movl %eax, -0x684(%rbp)
cmpl $0x0, %eax
jle 0x57b7
movq -0x518(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x684(%rbp), %edx
movq -0x508(%rbp), %rcx
callq 0x18940
movl %eax, -0x7ac(%rbp)
jmp 0x56b4
movl -0x7ac(%rbp), %eax
cmpl -0x684(%rbp), %eax
jge 0x577f
leaq 0x20f3b(%rip), %rdi     # 0x26608
callq 0xd510
movq -0x578(%rbp), %rsi
leaq 0x20f48(%rip), %rdi     # 0x26628
callq 0xd540
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, -0x7c0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq -0x7c0(%rbp), %rdx
movq %rax, %rcx
leaq 0x16bbe(%rip), %rsi     # 0x1c2cd
xorl %eax, %eax
leaq -0x470(%rbp), %rdi
movq %rdi, -0x7b8(%rbp)
leaq -0x4f0(%rbp), %r8
callq 0x40d0
movq -0x7b8(%rbp), %rdi
callq 0x41d0
movq -0x7b8(%rbp), %rdi
movq %rax, %rdx
movq 0x20e98(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x5754
leaq -0x470(%rbp), %rdi
movq %rdi, -0x7c8(%rbp)
callq 0x41d0
movq -0x7c8(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
callq 0x4160
jmp 0x577d
jmp 0x57b7
testb $0x1, -0xd(%rbp)
je 0x579f
movq -0x60(%rbp), %rsi
movl -0x684(%rbp), %edx
leaq -0x680(%rbp), %rdi
callq 0x1a220
jmp 0x579d
jmp 0x579f
movslq -0x684(%rbp), %rsi
leaq 0x20e73(%rip), %rdi     # 0x26620
callq 0xd580
jmp 0x5657
movq -0x518(%rbp), %rdi
movq -0x508(%rbp), %rsi
callq 0x18690
jmp 0x57cc
leaq -0x6b0(%rbp), %rdi
xorl %esi, %esi
movl $0x21, %edx
callq 0x4250
cmpl $0x0, -0x684(%rbp)
jge 0x58a8
leaq 0x20e15(%rip), %rdi     # 0x26608
callq 0xd510
movq -0x578(%rbp), %rsi
leaq 0x20e22(%rip), %rdi     # 0x26628
callq 0xd540
leaq -0x30(%rbp), %rdi
callq 0x41b0
movq %rax, -0x7d8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq -0x7d8(%rbp), %rdx
movq %rax, %rcx
leaq 0x16ad2(%rip), %rsi     # 0x1c307
xorl %eax, %eax
leaq -0x470(%rbp), %rdi
movq %rdi, -0x7d0(%rbp)
leaq -0x4f0(%rbp), %r8
callq 0x40d0
movq -0x7d0(%rbp), %rdi
callq 0x41d0
movq -0x7d0(%rbp), %rdi
movq %rax, %rdx
movq 0x20d72(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x587a
leaq -0x470(%rbp), %rdi
movq %rdi, -0x7e0(%rbp)
callq 0x41d0
movq -0x7e0(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
callq 0x4160
jmp 0x58a3
jmp 0x5959
leaq 0x20d51(%rip), %rdi     # 0x26600
callq 0xd510
testb $0x1, -0xd(%rbp)
je 0x5957
movb $0x0, -0x6c2(%rbp)
movw $0x0, -0x6c4(%rbp)
leaq -0x680(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x1b700
jmp 0x58e3
leaq -0x6b0(%rbp), %rdi
xorl %esi, %esi
movl $0x21, %edx
callq 0x4250
movl $0x0, -0x6c8(%rbp)
movslq -0x6c8(%rbp), %rax
cmpq $0x10, %rax
jae 0x5955
leaq -0x6c4(%rbp), %rdi
movslq -0x6c8(%rbp), %rax
movzbl -0x6c0(%rbp,%rax), %edx
leaq 0x16a1e(%rip), %rsi     # 0x1c348
movb $0x0, %al
callq 0x40d0
leaq -0x6b0(%rbp), %rdi
leaq -0x6c4(%rbp), %rsi
callq 0x4830
movl -0x6c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c8(%rbp)
jmp 0x5900
jmp 0x5957
jmp 0x5959
movq -0x500(%rbp), %rdi
callq 0x4580
jmp 0x5967
cmpq $0x0, -0x500(%rbp)
je 0x5981
movq -0x500(%rbp), %rdi
callq 0x44a0
jmp 0x597f
jmp 0x5981
testb $0x1, -0xd(%rbp)
je 0x5c88
leaq 0x169bc(%rip), %rdx     # 0x1c34e
leaq -0x6e8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xd5c0
jmp 0x59a4
leaq -0x708(%rbp), %rdi
leaq -0x6e8(%rbp), %rsi
callq 0x41c0
jmp 0x59b9
movl -0x4f4(%rbp), %esi
movl -0x4f8(%rbp), %edx
movq -0x518(%rbp), %rcx
movq -0x8(%rbp), %r8
leaq -0x708(%rbp), %rdi
leaq -0x508(%rbp), %r9
callq 0x5fd0
movl %eax, -0x7e4(%rbp)
jmp 0x59eb
movl -0x7e4(%rbp), %eax
movl %eax, -0x5c4(%rbp)
leaq -0x708(%rbp), %rdi
callq 0x4280
cmpl $0x0, -0x5c4(%rbp)
jge 0x5b36
leaq 0x20bf9(%rip), %rdi     # 0x26610
callq 0xd510
cmpl $-0x1, -0x5c4(%rbp)
jne 0x5a87
leaq -0x470(%rbp), %rax
movq %rax, -0x7f0(%rbp)
leaq -0x6e8(%rbp), %rdi
callq 0x41b0
movq -0x7f0(%rbp), %rdi
movq %rax, %rdx
leaq 0x16903(%rip), %rsi     # 0x1c353
movb $0x0, %al
callq 0x40d0
jmp 0x5ace
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5c77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x708(%rbp), %rdi
callq 0x4280
jmp 0x5c77
leaq -0x470(%rbp), %rax
movq %rax, -0x800(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x7f8(%rbp)
leaq -0x6e8(%rbp), %rdi
callq 0x41b0
movq -0x800(%rbp), %rdi
movq -0x7f8(%rbp), %rdx
movq %rax, %rcx
leaq 0x168c1(%rip), %rsi     # 0x1c388
movb $0x0, %al
callq 0x40d0
leaq -0x470(%rbp), %rdi
movq %rdi, -0x808(%rbp)
callq 0x41d0
movq -0x808(%rbp), %rdi
movq %rax, %rdx
movq 0x20aee(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x5afe
leaq -0x470(%rbp), %rdi
movq %rdi, -0x810(%rbp)
callq 0x41d0
movq -0x810(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x4160
jmp 0x5b27
movl $0x2, -0x520(%rbp)
jmp 0x5c5d
movq -0x518(%rbp), %rax
movq %rax, -0x828(%rbp)
leaq -0x6b0(%rbp), %rdi
movq %rdi, -0x820(%rbp)
callq 0x41d0
movq -0x828(%rbp), %rdi
movq -0x820(%rbp), %rsi
movl %eax, %edx
movq -0x508(%rbp), %rcx
callq 0x18940
movl %eax, -0x814(%rbp)
jmp 0x5b7b
movl -0x814(%rbp), %eax
cltq
movq %rax, -0x830(%rbp)
leaq -0x6b0(%rbp), %rdi
callq 0x41d0
movq %rax, %rcx
movq -0x830(%rbp), %rax
cmpq %rcx, %rax
jae 0x5c3e
leaq 0x20a60(%rip), %rdi     # 0x26610
callq 0xd510
leaq -0x6e8(%rbp), %rdi
callq 0x41b0
movq %rax, %rdx
leaq 0x167f1(%rip), %rsi     # 0x1c3bc
xorl %eax, %eax
leaq -0x470(%rbp), %rdi
movq %rdi, -0x838(%rbp)
callq 0x40d0
movq -0x838(%rbp), %rdi
callq 0x41d0
movq -0x838(%rbp), %rdi
movq %rax, %rdx
movq 0x209e3(%rip), %rcx     # 0x265e0
movl $0x1, %esi
callq 0x4890
jmp 0x5c09
leaq -0x470(%rbp), %rdi
movq %rdi, -0x840(%rbp)
callq 0x41d0
movq -0x840(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x4160
jmp 0x5c32
movl $0x3, -0x520(%rbp)
jmp 0x5c5d
movq -0x518(%rbp), %rdi
movq -0x508(%rbp), %rsi
callq 0x18690
jmp 0x5c53
movl $0x0, -0x520(%rbp)
leaq -0x6e8(%rbp), %rdi
callq 0x4280
movl -0x520(%rbp), %eax
testl %eax, %eax
jne 0x5cbc
jmp 0x5c75
jmp 0x5c88
leaq -0x6e8(%rbp), %rdi
callq 0x4280
jmp 0x5d0a
leaq 0x20979(%rip), %rdi     # 0x26608
callq 0xd2c0
cmpq $0xa, %rax
jle 0x5cb2
leaq 0x2094f(%rip), %rdi     # 0x265f0
callq 0xd3c0
movl $0x3, -0x520(%rbp)
jmp 0x5cbc
movl $0x0, -0x520(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0xd640
leaq -0x598(%rbp), %rdi
callq 0xd640
leaq -0x570(%rbp), %rdi
callq 0xd660
movl -0x520(%rbp), %eax
movl %eax, -0x844(%rbp)
testl %eax, %eax
je 0x5d05
jmp 0x5cf2
movl -0x844(%rbp), %eax
subl $0x2, %eax
je 0x5191
jmp 0x5d03
jmp 0x5d33
jmp 0x5191
leaq -0x5c0(%rbp), %rdi
callq 0xd640
leaq -0x598(%rbp), %rdi
callq 0xd640
leaq -0x570(%rbp), %rdi
callq 0xd660
jmp 0x5db4
movq -0x518(%rbp), %rdi
callq 0x197d0
jmp 0x5d41
movq -0x60(%rbp), %rax
movq %rax, -0x850(%rbp)
cmpq $0x0, %rax
je 0x5d5e
movq -0x850(%rbp), %rdi
callq 0x4600
movq -0x518(%rbp), %rax
movq %rax, -0x858(%rbp)
cmpq $0x0, %rax
je 0x5d8f
movq -0x858(%rbp), %rdi
callq 0x164c0
movq -0x858(%rbp), %rdi
movl $0x8, %esi
callq 0x44c0
movl $0x0, -0x520(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4280
leaq -0x30(%rbp), %rdi
callq 0x4280
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x4280
leaq -0x30(%rbp), %rdi
callq 0x4280
movq -0x68(%rbp), %rdi
callq 0x4810
nop