// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/replication.c
// Function: syncWithMaster
void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
    char tmpfile[256], *err = NULL;
    int dfd = -1, maxtries = 5;
    int sockerr = 0, psync_result;
    socklen_t errlen = sizeof(sockerr);
    UNUSED(el);
    UNUSED(privdata);
    UNUSED(mask);

    /* If this event fired after the user turned the instance into a master
     * with SLAVEOF NO ONE we must just return ASAP. */
    if (server.repl_state == REPL_STATE_NONE) {
        close(fd);
        return;
    }

    /* Check for errors in the socket. */
    if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &sockerr, &errlen) == -1)
        sockerr = errno;
    if (sockerr) {
        serverLog(LL_WARNING,"Error condition on socket for SYNC: %s",
            strerror(sockerr));
        goto error;
    }

    /* Send a PING to check the master is able to reply without errors. */
    if (server.repl_state == REPL_STATE_CONNECTING) {
        serverLog(LL_NOTICE,"Non blocking connect for SYNC fired the event.");
        /* Delete the writable event so that the readable event remains
         * registered and we can wait for the PONG reply. */
        aeDeleteFileEvent(server.el,fd,AE_WRITABLE);
        server.repl_state = REPL_STATE_RECEIVE_PONG;
        /* Send the PING, don't check for errors at all, we have the timeout
         * that will take care about this. */
        err = sendSynchronousCommand(SYNC_CMD_WRITE,fd,"PING",NULL);
        if (err) goto write_error;
        return;
    }

    /* Receive the PONG command. */
    if (server.repl_state == REPL_STATE_RECEIVE_PONG) {
        err = sendSynchronousCommand(SYNC_CMD_READ,fd,NULL);

        /* We accept only two replies as valid, a positive +PONG reply
         * (we just check for "+") or an authentication error.
         * Note that older versions of Redis replied with "operation not
         * permitted" instead of using a proper error code, so we test
         * both. */
        if (err[0] != '+' &&
            strncmp(err,"-NOAUTH",7) != 0 &&
            strncmp(err,"-ERR operation not permitted",28) != 0)
        {
            serverLog(LL_WARNING,"Error reply to PING from master: '%s'",err);
            sdsfree(err);
            goto error;
        } else {
            serverLog(LL_NOTICE,
                "Master replied to PING, replication can continue...");
        }
        sdsfree(err);
        server.repl_state = REPL_STATE_SEND_AUTH;
    }

    /* AUTH with the master if required. */
    if (server.repl_state == REPL_STATE_SEND_AUTH) {
        if (server.masterauth) {
            err = sendSynchronousCommand(SYNC_CMD_WRITE,fd,"AUTH",server.masterauth,NULL);
            if (err) goto write_error;
            server.repl_state = REPL_STATE_RECEIVE_AUTH;
            return;
        } else {
            server.repl_state = REPL_STATE_SEND_PORT;
        }
    }

    /* Receive AUTH reply. */
    if (server.repl_state == REPL_STATE_RECEIVE_AUTH) {
        err = sendSynchronousCommand(SYNC_CMD_READ,fd,NULL);
        if (err[0] == '-') {
            serverLog(LL_WARNING,"Unable to AUTH to MASTER: %s",err);
            sdsfree(err);
            goto error;
        }
        sdsfree(err);
        server.repl_state = REPL_STATE_SEND_PORT;
    }

    /* Set the slave port, so that Master's INFO command can list the
     * slave listening port correctly. */
    if (server.repl_state == REPL_STATE_SEND_PORT) {
        sds port = sdsfromlonglong(server.slave_announce_port ?
            server.slave_announce_port : server.port);
        err = sendSynchronousCommand(SYNC_CMD_WRITE,fd,"REPLCONF",
                "listening-port",port, NULL);
        sdsfree(port);
        if (err) goto write_error;
        sdsfree(err);
        server.repl_state = REPL_STATE_RECEIVE_PORT;
        return;
    }

    /* Receive REPLCONF listening-port reply. */
    if (server.repl_state == REPL_STATE_RECEIVE_PORT) {
        err = sendSynchronousCommand(SYNC_CMD_READ,fd,NULL);
        /* Ignore the error if any, not all the Redis versions support
         * REPLCONF listening-port. */
        if (err[0] == '-') {
            serverLog(LL_NOTICE,"(Non critical) Master does not understand "
                                "REPLCONF listening-port: %s", err);
        }
        sdsfree(err);
        server.repl_state = REPL_STATE_SEND_IP;
    }

    /* Skip REPLCONF ip-address if there is no slave-announce-ip option set. */
    if (server.repl_state == REPL_STATE_SEND_IP &&
        server.slave_announce_ip == NULL)
    {
            server.repl_state = REPL_STATE_SEND_CAPA;
    }

    /* Set the slave ip, so that Master's INFO command can list the
     * slave IP address port correctly in case of port forwarding or NAT. */
    if (server.repl_state == REPL_STATE_SEND_IP) {
        err = sendSynchronousCommand(SYNC_CMD_WRITE,fd,"REPLCONF",
                "ip-address",server.slave_announce_ip, NULL);
        if (err) goto write_error;
        sdsfree(err);
        server.repl_state = REPL_STATE_RECEIVE_IP;
        return;
    }

    /* Receive REPLCONF ip-address reply. */
    if (server.repl_state == REPL_STATE_RECEIVE_IP) {
        err = sendSynchronousCommand(SYNC_CMD_READ,fd,NULL);
        /* Ignore the error if any, not all the Redis versions support
         * REPLCONF listening-port. */
        if (err[0] == '-') {
            serverLog(LL_NOTICE,"(Non critical) Master does not understand "
                                "REPLCONF ip-address: %s", err);
        }
        sdsfree(err);
        server.repl_state = REPL_STATE_SEND_CAPA;
    }

    /* Inform the master of our capabilities. While we currently send
     * just one capability, it is possible to chain new capabilities here
     * in the form of REPLCONF capa X capa Y capa Z ...
     * The master will ignore capabilities it does not understand. */
    if (server.repl_state == REPL_STATE_SEND_CAPA) {
        err = sendSynchronousCommand(SYNC_CMD_WRITE,fd,"REPLCONF",
                "capa","eof",NULL);
        if (err) goto write_error;
        sdsfree(err);
        server.repl_state = REPL_STATE_RECEIVE_CAPA;
        return;
    }

    /* Receive CAPA reply. */
    if (server.repl_state == REPL_STATE_RECEIVE_CAPA) {
        err = sendSynchronousCommand(SYNC_CMD_READ,fd,NULL);
        /* Ignore the error if any, not all the Redis versions support
         * REPLCONF capa. */
        if (err[0] == '-') {
            serverLog(LL_NOTICE,"(Non critical) Master does not understand "
                                  "REPLCONF capa: %s", err);
        }
        sdsfree(err);
        server.repl_state = REPL_STATE_SEND_PSYNC;
    }

    /* Try a partial resynchonization. If we don't have a cached master
     * slaveTryPartialResynchronization() will at least try to use PSYNC
     * to start a full resynchronization so that we get the master run id
     * and the global offset, to try a partial resync at the next
     * reconnection attempt. */
    if (server.repl_state == REPL_STATE_SEND_PSYNC) {
        if (slaveTryPartialResynchronization(fd,0) == PSYNC_WRITE_ERROR) {
            err = sdsnew("Write error sending the PSYNC command.");
            goto write_error;
        }
        server.repl_state = REPL_STATE_RECEIVE_PSYNC;
        return;
    }

    /* If reached this point, we should be in REPL_STATE_RECEIVE_PSYNC. */
    if (server.repl_state != REPL_STATE_RECEIVE_PSYNC) {
        serverLog(LL_WARNING,"syncWithMaster(): state machine error, "
                             "state should be RECEIVE_PSYNC but is %d",
                             server.repl_state);
        goto error;
    }

    psync_result = slaveTryPartialResynchronization(fd,1);
    if (psync_result == PSYNC_WAIT_REPLY) return; /* Try again later... */

    /* Note: if PSYNC does not return WAIT_REPLY, it will take care of
     * uninstalling the read handler from the file descriptor. */

    if (psync_result == PSYNC_CONTINUE) {
        serverLog(LL_NOTICE, "MASTER <-> SLAVE sync: Master accepted a Partial Resynchronization.");
        return;
    }

    /* PSYNC failed or is not supported: we want our slaves to resync with us
     * as well, if we have any (chained replication case). The mater may
     * transfer us an entirely different data set and we have no way to
     * incrementally feed our slaves after that. */
    disconnectSlaves(); /* Force our slaves to resync with us as well. */
    freeReplicationBacklog(); /* Don't allow our chained slaves to PSYNC. */

    /* Fall back to SYNC if needed. Otherwise psync_result == PSYNC_FULLRESYNC
     * and the server.repl_master_runid and repl_master_initial_offset are
     * already populated. */
    if (psync_result == PSYNC_NOT_SUPPORTED) {
        serverLog(LL_NOTICE,"Retrying with SYNC...");
        if (syncWrite(fd,"SYNC\r\n",6,server.repl_syncio_timeout*1000) == -1) {
            serverLog(LL_WARNING,"I/O error writing to MASTER: %s",
                strerror(errno));
            goto error;
        }
    }

    /* Prepare a suitable temp file for bulk transfer */
    while(maxtries--) {
        snprintf(tmpfile,256,
            "temp-%d.%ld.rdb",(int)server.unixtime,(long int)getpid());
        dfd = open(tmpfile,O_CREAT|O_WRONLY|O_EXCL,0644);
        if (dfd != -1) break;
        sleep(1);
    }
    if (dfd == -1) {
        serverLog(LL_WARNING,"Opening the temp file needed for MASTER <-> SLAVE synchronization: %s",strerror(errno));
        goto error;
    }

    /* Setup the non blocking download of the bulk file. */
    if (aeCreateFileEvent(server.el,fd, AE_READABLE,readSyncBulkPayload,NULL)
            == AE_ERR)
    {
        serverLog(LL_WARNING,
            "Can't create readable event for SYNC: %s (fd=%d)",
            strerror(errno),fd);
        goto error;
    }

    server.repl_state = REPL_STATE_TRANSFER;
    server.repl_transfer_size = -1;
    server.repl_transfer_read = 0;
    server.repl_transfer_last_fsync_off = 0;
    server.repl_transfer_fd = dfd;
    server.repl_transfer_lastio = server.unixtime;
    server.repl_transfer_tmpfile = zstrdup(tmpfile);
    return;

error:
    aeDeleteFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE);
    if (dfd != -1) close(dfd);
    close(fd);
    server.repl_transfer_s = -1;
    server.repl_state = REPL_STATE_CONNECT;
    return;

write_error: /* Handle sendSynchronousCommand(SYNC_CMD_WRITE) errors. */
    serverLog(LL_WARNING,"Sending command to master in replication handshake: %s", err);
    sdsfree(err);
    goto error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq $0x0, -0x128(%rbp)
movl $0xffffffff, -0x12c(%rbp) # imm = 0xFFFFFFFF
movl $0x5, -0x130(%rbp)
movl $0x0, -0x134(%rbp)
movl $0x4, -0x13c(%rbp)
leaq 0x1275f5(%rip), %rax    # 0x1781d8
cmpl $0x0, 0x84c(%rax)
jne 0x50bf9
movl -0xc(%rbp), %edi
callq 0x26180
jmp 0x5156a
movl -0xc(%rbp), %edi
movl $0x1, %esi
movl $0x4, %edx
leaq -0x134(%rbp), %rcx
leaq -0x13c(%rbp), %r8
callq 0x26700
cmpl $-0x1, %eax
jne 0x50c2b
callq 0x26880
movl (%rax), %eax
movl %eax, -0x134(%rbp)
cmpl $0x0, -0x134(%rbp)
je 0x50c5a
movl -0x134(%rbp), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xebc99(%rip), %rsi     # 0x13c8e7
movb $0x0, %al
callq 0x2fc60
jmp 0x514ea
leaq 0x127577(%rip), %rax    # 0x1781d8
cmpl $0x2, 0x84c(%rax)
jne 0x50cdb
movl $0x2, %edi
leaq 0xebc98(%rip), %rsi     # 0x13c90e
movb $0x0, %al
callq 0x2fc60
leaq 0x127554(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x2aab0
leaq 0x12753c(%rip), %rax    # 0x1781d8
movl $0x3, 0x84c(%rax)
movl -0xc(%rbp), %esi
movl $0x2, %edi
leaq 0xebc88(%rip), %rdx     # 0x13c93d
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
je 0x50cd6
jmp 0x51542
jmp 0x5156a
leaq 0x1274f6(%rip), %rax    # 0x1781d8
cmpl $0x3, 0x84c(%rax)
jne 0x50dad
movl -0xc(%rbp), %esi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
je 0x50d7d
movq -0x128(%rbp), %rdi
leaq 0xebc1c(%rip), %rsi     # 0x13c942
movl $0x7, %edx
callq 0x26350
cmpl $0x0, %eax
je 0x50d7d
movq -0x128(%rbp), %rdi
leaq 0xebc07(%rip), %rsi     # 0x13c94a
movl $0x1c, %edx
callq 0x26350
cmpl $0x0, %eax
je 0x50d7d
movq -0x128(%rbp), %rdx
movl $0x3, %edi
leaq 0xebc02(%rip), %rsi     # 0x13c967
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
jmp 0x514ea
movl $0x2, %edi
leaq 0xebc04(%rip), %rsi     # 0x13c98d
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x127435(%rip), %rax    # 0x1781d8
movl $0x4, 0x84c(%rax)
leaq 0x127424(%rip), %rax    # 0x1781d8
cmpl $0x4, 0x84c(%rax)
jne 0x50e36
leaq 0x127414(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x820(%rax)
je 0x50e23
movl -0xc(%rbp), %esi
leaq 0x127400(%rip), %rax    # 0x1781d8
movq 0x820(%rax), %rcx
movl $0x2, %edi
leaq 0xebb5a(%rip), %rdx     # 0x13c945
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
je 0x50e0d
jmp 0x51542
leaq 0x1273c4(%rip), %rax    # 0x1781d8
movl $0x5, 0x84c(%rax)
jmp 0x5156a
leaq 0x1273ae(%rip), %rax    # 0x1781d8
movl $0x6, 0x84c(%rax)
jmp 0x50e36
leaq 0x12739b(%rip), %rax    # 0x1781d8
cmpl $0x5, 0x84c(%rax)
jne 0x50eb7
movl -0xc(%rbp), %esi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x50e9a
movq -0x128(%rbp), %rdx
movl $0x3, %edi
leaq 0xebb3f(%rip), %rsi     # 0x13c9c1
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
jmp 0x514ea
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x12732b(%rip), %rax    # 0x1781d8
movl $0x6, 0x84c(%rax)
leaq 0x12731a(%rip), %rax    # 0x1781d8
cmpl $0x6, 0x84c(%rax)
jne 0x50f85
leaq 0x127306(%rip), %rax    # 0x1781d8
cmpl $0x0, 0x898(%rax)
je 0x50ef0
leaq 0x1272f6(%rip), %rax    # 0x1781d8
movl 0x898(%rax), %eax
movl %eax, -0x14c(%rbp)
jmp 0x50f03
leaq 0x1272e1(%rip), %rax    # 0x1781d8
movl 0xa0(%rax), %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
movslq %eax, %rdi
callq 0x393f0
movq %rax, -0x148(%rbp)
movl -0xc(%rbp), %esi
movq -0x148(%rbp), %r8
movl $0x2, %edi
leaq 0xe6c2d(%rip), %rdx     # 0x137b5b
leaq 0xeb189(%rip), %rcx     # 0x13c0be
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x148(%rbp), %rdi
callq 0x38620
cmpq $0x0, -0x128(%rbp)
je 0x50f63
jmp 0x51542
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x127262(%rip), %rax    # 0x1781d8
movl $0x7, 0x84c(%rax)
jmp 0x5156a
leaq 0x12724c(%rip), %rax    # 0x1781d8
cmpl $0x7, 0x84c(%rax)
jne 0x50ff5
movl -0xc(%rbp), %esi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x50fd8
movq -0x128(%rbp), %rdx
movl $0x2, %edi
leaq 0xeba0d(%rip), %rsi     # 0x13c9de
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x1271ed(%rip), %rax    # 0x1781d8
movl $0x8, 0x84c(%rax)
leaq 0x1271dc(%rip), %rax    # 0x1781d8
cmpl $0x8, 0x84c(%rax)
jne 0x51027
leaq 0x1271cc(%rip), %rax    # 0x1781d8
cmpq $0x0, 0x8a0(%rax)
jne 0x51027
leaq 0x1271bb(%rip), %rax    # 0x1781d8
movl $0xa, 0x84c(%rax)
leaq 0x1271aa(%rip), %rax    # 0x1781d8
cmpl $0x8, 0x84c(%rax)
jne 0x5109f
movl -0xc(%rbp), %esi
leaq 0x127197(%rip), %rax    # 0x1781d8
movq 0x8a0(%rax), %r8
movl $0x2, %edi
leaq 0xe6b07(%rip), %rdx     # 0x137b5b
leaq 0xeb072(%rip), %rcx     # 0x13c0cd
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
je 0x5107d
jmp 0x51542
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x127148(%rip), %rax    # 0x1781d8
movl $0x9, 0x84c(%rax)
jmp 0x5156a
leaq 0x127132(%rip), %rax    # 0x1781d8
cmpl $0x9, 0x84c(%rax)
jne 0x5110f
movl -0xc(%rbp), %esi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x510f2
movq -0x128(%rbp), %rdx
movl $0x2, %edi
leaq 0xeb939(%rip), %rsi     # 0x13ca24
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x1270d3(%rip), %rax    # 0x1781d8
movl $0xa, 0x84c(%rax)
leaq 0x1270c2(%rip), %rax    # 0x1781d8
cmpl $0xa, 0x84c(%rax)
jne 0x51180
movl -0xc(%rbp), %esi
movl $0x2, %edi
leaq 0xe6a2d(%rip), %rdx     # 0x137b5b
leaq 0xeafe9(%rip), %rcx     # 0x13c11e
leaq 0xe66d9(%rip), %r8      # 0x137815
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
je 0x5115e
jmp 0x51542
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x127067(%rip), %rax    # 0x1781d8
movl $0xb, 0x84c(%rax)
jmp 0x5156a
leaq 0x127051(%rip), %rax    # 0x1781d8
cmpl $0xb, 0x84c(%rax)
jne 0x511f0
movl -0xc(%rbp), %esi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x502c0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x511d3
movq -0x128(%rbp), %rdx
movl $0x2, %edi
leaq 0xeb89a(%rip), %rsi     # 0x13ca66
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
leaq 0x126ff2(%rip), %rax    # 0x1781d8
movl $0xc, 0x84c(%rax)
leaq 0x126fe1(%rip), %rax    # 0x1781d8
cmpl $0xc, 0x84c(%rax)
jne 0x5123d
movl -0xc(%rbp), %edi
xorl %esi, %esi
callq 0x50580
cmpl $0x0, %eax
jne 0x51227
leaq 0xeb88c(%rip), %rdi     # 0x13caa2
callq 0x38510
movq %rax, -0x128(%rbp)
jmp 0x51542
leaq 0x126faa(%rip), %rax    # 0x1781d8
movl $0xd, 0x84c(%rax)
jmp 0x5156a
leaq 0x126f94(%rip), %rax    # 0x1781d8
cmpl $0xd, 0x84c(%rax)
je 0x51272
leaq 0x126f84(%rip), %rax    # 0x1781d8
movl 0x84c(%rax), %edx
movl $0x3, %edi
leaq 0xeb863(%rip), %rsi     # 0x13cac9
movb $0x0, %al
callq 0x2fc60
jmp 0x514ea
movl -0xc(%rbp), %edi
movl $0x1, %esi
callq 0x50580
movl %eax, -0x138(%rbp)
cmpl $0x1, -0x138(%rbp)
jne 0x51293
jmp 0x5156a
cmpl $0x2, -0x138(%rbp)
jne 0x512b4
movl $0x2, %edi
leaq 0xeb870(%rip), %rsi     # 0x13cb18
movb $0x0, %al
callq 0x2fc60
jmp 0x5156a
callq 0x43e50
callq 0x4d9a0
cmpl $0x4, -0x138(%rbp)
jne 0x51331
movl $0x2, %edi
leaq 0xeb889(%rip), %rsi     # 0x13cb5c
movb $0x0, %al
callq 0x2fc60
movl -0xc(%rbp), %edi
leaq 0x126ef4(%rip), %rax    # 0x1781d8
imull $0x3e8, 0x848(%rax), %eax # imm = 0x3E8
movslq %eax, %rcx
leaq 0xeb87a(%rip), %rsi     # 0x13cb72
movl $0x6, %edx
callq 0x7bae0
cmpq $-0x1, %rax
jne 0x5132f
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xeb856(%rip), %rsi     # 0x13cb79
movb $0x0, %al
callq 0x2fc60
jmp 0x514ea
jmp 0x51331
jmp 0x51333
movl -0x130(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x130(%rbp)
cmpl $0x0, %eax
je 0x513cf
leaq -0x120(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq 0x126e76(%rip), %rax    # 0x1781d8
movq 0x978(%rax), %rax
movl %eax, -0x150(%rbp)
callq 0x26420
movq -0x158(%rbp), %rdi
movl -0x150(%rbp), %ecx
movslq %eax, %r8
movl $0x100, %esi            # imm = 0x100
leaq 0xeb809(%rip), %rdx     # 0x13cb99
movb $0x0, %al
callq 0x26120
leaq -0x120(%rbp), %rdi
movl $0xc1, %esi
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0x266a0
movl %eax, -0x12c(%rbp)
cmpl $-0x1, -0x12c(%rbp)
je 0x513c0
jmp 0x513cf
movl $0x1, %edi
callq 0x26600
jmp 0x51333
cmpl $-0x1, -0x12c(%rbp)
jne 0x513ff
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xeb7b6(%rip), %rsi     # 0x13cba9
movb $0x0, %al
callq 0x2fc60
jmp 0x514ea
leaq 0x126dd2(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movl -0xc(%rbp), %esi
movl $0x1, %edx
leaq -0x1969(%rip), %rcx     # 0x4fab0
xorl %eax, %eax
movl %eax, %r8d
callq 0x2a8f0
cmpl $-0x1, %eax
jne 0x51452
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl -0xc(%rbp), %ecx
movl $0x3, %edi
leaq 0xeb7a9(%rip), %rsi     # 0x13cbef
movb $0x0, %al
callq 0x2fc60
jmp 0x514ea
leaq 0x126d7f(%rip), %rax    # 0x1781d8
movl $0xe, 0x84c(%rax)
leaq 0x126d6e(%rip), %rax    # 0x1781d8
movq $-0x1, 0x850(%rax)
leaq 0x126d5c(%rip), %rax    # 0x1781d8
movq $0x0, 0x858(%rax)
leaq 0x126d4a(%rip), %rax    # 0x1781d8
movq $0x0, 0x860(%rax)
movl -0x12c(%rbp), %ecx
leaq 0x126d32(%rip), %rax    # 0x1781d8
movl %ecx, 0x86c(%rax)
leaq 0x126d25(%rip), %rax    # 0x1781d8
movq 0x978(%rax), %rcx
leaq 0x126d17(%rip), %rax    # 0x1781d8
movq %rcx, 0x878(%rax)
leaq -0x120(%rbp), %rdi
callq 0x3b040
movq %rax, %rcx
leaq 0x126cfa(%rip), %rax    # 0x1781d8
movq %rcx, 0x870(%rax)
jmp 0x5156a
leaq 0x126ce7(%rip), %rax    # 0x1781d8
movq 0x40(%rax), %rdi
movl -0xc(%rbp), %esi
movl $0x3, %edx
callq 0x2aab0
cmpl $-0x1, -0x12c(%rbp)
je 0x51516
movl -0x12c(%rbp), %edi
callq 0x26180
movl -0xc(%rbp), %edi
callq 0x26180
leaq 0x126cb3(%rip), %rax    # 0x1781d8
movl $0xffffffff, 0x868(%rax) # imm = 0xFFFFFFFF
leaq 0x126ca2(%rip), %rax    # 0x1781d8
movl $0x1, 0x84c(%rax)
jmp 0x5156a
movq -0x128(%rbp), %rdx
movl $0x3, %edi
leaq 0xeb6cb(%rip), %rsi     # 0x13cc20
movb $0x0, %al
callq 0x2fc60
movq -0x128(%rbp), %rdi
callq 0x38620
jmp 0x514ea
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)