// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: zunionInterGenericCommand
void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
    int i, j;
    long setnum;
    int aggregate = REDIS_AGGR_SUM;
    zsetopsrc *src;
    zsetopval zval;
    robj *tmp;
    unsigned int maxelelen = 0;
    robj *dstobj;
    zset *dstzset;
    zskiplistNode *znode;
    int touched = 0;

    /* expect setnum input keys to be given */
    // 取出要处理的有序集合的个数 setnum
    if ((getLongFromObjectOrReply(c, c->argv[2], &setnum, NULL) != REDIS_OK))
        return;

    if (setnum < 1) {
        addReplyError(c,
            "at least 1 input key is needed for ZUNIONSTORE/ZINTERSTORE");
        return;
    }

    /* test if the expected number of keys would overflow */
    // setnum 参数和传入的 key 数量不相同，出错
    if (setnum > c->argc-3) {
        addReply(c,shared.syntaxerr);
        return;
    }

    /* read keys to be used for input */
    // 为每个输入 key 创建一个迭代器
    src = zcalloc(sizeof(zsetopsrc) * setnum);
    for (i = 0, j = 3; i < setnum; i++, j++) {

        // 取出 key 对象
        robj *obj = lookupKeyWrite(c->db,c->argv[j]);

        // 创建迭代器
        if (obj != NULL) {
            if (obj->type != REDIS_ZSET && obj->type != REDIS_SET) {
                zfree(src);
                addReply(c,shared.wrongtypeerr);
                return;
            }

            src[i].subject = obj;
            src[i].type = obj->type;
            src[i].encoding = obj->encoding;

        // 不存在的对象设为 NULL
        } else {
            src[i].subject = NULL;
        }

        /* Default all weights to 1. */
        // 默认权重为 1.0
        src[i].weight = 1.0;
    }

    /* parse optional extra arguments */
    // 分析并读入可选参数
    if (j < c->argc) {
        int remaining = c->argc - j;

        while (remaining) {
            if (remaining >= (setnum + 1) && !strcasecmp(c->argv[j]->ptr,"weights")) {
                j++; remaining--;
                // 权重参数
                for (i = 0; i < setnum; i++, j++, remaining--) {
                    if (getDoubleFromObjectOrReply(c,c->argv[j],&src[i].weight,
                            "weight value is not a float") != REDIS_OK)
                    {
                        zfree(src);
                        return;
                    }
                }

            } else if (remaining >= 2 && !strcasecmp(c->argv[j]->ptr,"aggregate")) {
                j++; remaining--;
                // 聚合方式
                if (!strcasecmp(c->argv[j]->ptr,"sum")) {
                    aggregate = REDIS_AGGR_SUM;
                } else if (!strcasecmp(c->argv[j]->ptr,"min")) {
                    aggregate = REDIS_AGGR_MIN;
                } else if (!strcasecmp(c->argv[j]->ptr,"max")) {
                    aggregate = REDIS_AGGR_MAX;
                } else {
                    zfree(src);
                    addReply(c,shared.syntaxerr);
                    return;
                }
                j++; remaining--;

            } else {
                zfree(src);
                addReply(c,shared.syntaxerr);
                return;
            }
        }
    }

    /* sort sets from the smallest to largest, this will improve our
     * algorithm's performance */
    // 对所有集合进行排序，以减少算法的常数项
    qsort(src,setnum,sizeof(zsetopsrc),zuiCompareByCardinality);

    // 创建结果集对象
    dstobj = createZsetObject();
    dstzset = dstobj->ptr;
    memset(&zval, 0, sizeof(zval));

    // ZINTERSTORE 命令
    if (op == REDIS_OP_INTER) {

        /* Skip everything if the smallest input is empty. */
        // 只处理非空集合
        if (zuiLength(&src[0]) > 0) {

            /* Precondition: as src[0] is non-empty and the inputs are ordered
             * by size, all src[i > 0] are non-empty too. */
            // 遍历基数最小的 src[0] 集合
            zuiInitIterator(&src[0]);
            while (zuiNext(&src[0],&zval)) {
                double score, value;

                // 计算加权分值
                score = src[0].weight * zval.score;
                if (isnan(score)) score = 0;

                // 将 src[0] 集合中的元素和其他集合中的元素做加权聚合计算
                for (j = 1; j < setnum; j++) {
                    /* It is not safe to access the zset we are
                     * iterating, so explicitly check for equal object. */
                    // 如果当前迭代到的 src[j] 的对象和 src[0] 的对象一样，
                    // 那么 src[0] 出现的元素必然也出现在 src[j]
                    // 那么我们可以直接计算聚合值，
                    // 不必进行 zuiFind 去确保元素是否出现
                    // 这种情况在某个 key 输入了两次，
                    // 并且这个 key 是所有输入集合中基数最小的集合时会出现
                    if (src[j].subject == src[0].subject) {
                        value = zval.score*src[j].weight;
                        zunionInterAggregate(&score,value,aggregate);

                    // 如果能在其他集合找到当前迭代到的元素的话
                    // 那么进行聚合计算
                    } else if (zuiFind(&src[j],&zval,&value)) {
                        value *= src[j].weight;
                        zunionInterAggregate(&score,value,aggregate);

                    // 如果当前元素没出现在某个集合，那么跳出 for 循环
                    // 处理下个元素
                    } else {
                        break;
                    }
                }

                /* Only continue when present in every input. */
                // 只在交集元素出现时，才执行以下代码
                if (j == setnum) {
                    // 取出值对象
                    tmp = zuiObjectFromValue(&zval);
                    // 加入到有序集合中
                    znode = zslInsert(dstzset->zsl,score,tmp);
                    incrRefCount(tmp); /* added to skiplist */
                    // 加入到字典中
                    dictAdd(dstzset->dict,tmp,&znode->score);
                    incrRefCount(tmp); /* added to dictionary */

                    // 更新字符串对象的最大长度
                    if (sdsEncodedObject(tmp)) {
                        if (sdslen(tmp->ptr) > maxelelen)
                            maxelelen = sdslen(tmp->ptr);
                    }
                }
            }
            zuiClearIterator(&src[0]);
        }

    // ZUNIONSTORE
    } else if (op == REDIS_OP_UNION) {

        // 遍历所有输入集合
        for (i = 0; i < setnum; i++) {

            // 跳过空集合
            if (zuiLength(&src[i]) == 0)
                continue;

            // 遍历所有集合元素
            zuiInitIterator(&src[i]);
            while (zuiNext(&src[i],&zval)) {
                double score, value;

                /* Skip an element that when already processed */
                // 跳过已处理元素
                if (dictFind(dstzset->dict,zuiObjectFromValue(&zval)) != NULL)
                    continue;

                /* Initialize score */
                // 初始化分值
                score = src[i].weight * zval.score;
                // 溢出时设为 0
                if (isnan(score)) score = 0;

                /* We need to check only next sets to see if this element
                 * exists, since we process every element just one time so
                 * it can't exist in a previous set (otherwise it would be
                 * already processed). */
                for (j = (i+1); j < setnum; j++) {
                    /* It is not safe to access the zset we are
                     * iterating, so explicitly check for equal object. */
                    // 当前元素的集合和被迭代集合一样
                    // 所以同一个元素必然出现在 src[j] 和 src[i]
                    // 程序直接计算它们的聚合值
                    // 而不必使用 zuiFind 来检查元素是否存在
                    if(src[j].subject == src[i].subject) {
                        value = zval.score*src[j].weight;
                        zunionInterAggregate(&score,value,aggregate);

                    // 检查成员是否存在
                    } else if (zuiFind(&src[j],&zval,&value)) {
                        value *= src[j].weight;
                        zunionInterAggregate(&score,value,aggregate);
                    }
                }

                // 取出成员
                tmp = zuiObjectFromValue(&zval);
                // 插入并集元素到跳跃表
                znode = zslInsert(dstzset->zsl,score,tmp);
                incrRefCount(zval.ele); /* added to skiplist */
                // 添加元素到字典
                dictAdd(dstzset->dict,tmp,&znode->score);
                incrRefCount(zval.ele); /* added to dictionary */

                // 更新字符串最大长度
                if (sdsEncodedObject(tmp)) {
                    if (sdslen(tmp->ptr) > maxelelen)
                        maxelelen = sdslen(tmp->ptr);
                }
            }
            zuiClearIterator(&src[i]);
        }
    } else {
        redisPanic("Unknown operator");
    }

    // 删除已存在的 dstkey ，等待后面用新对象代替它
    if (dbDelete(c->db,dstkey)) {
        signalModifiedKey(c->db,dstkey);
        touched = 1;
        server.dirty++;
    }

    // 如果结果集合的长度不为 0 
    if (dstzset->zsl->length) {
        /* Convert to ziplist when in limits. */
        // 看是否需要对结果集合进行编码转换
        if (dstzset->zsl->length <= server.zset_max_ziplist_entries &&
            maxelelen <= server.zset_max_ziplist_value)
                zsetConvert(dstobj,REDIS_ENCODING_ZIPLIST);

        // 将结果集合关联到数据库
        dbAdd(c->db,dstkey,dstobj);

        // 回复结果集合的长度
        addReplyLongLong(c,zsetLength(dstobj));

        if (!touched) signalModifiedKey(c->db,dstkey);

        notifyKeyspaceEvent(REDIS_NOTIFY_ZSET,
            (op == REDIS_OP_UNION) ? "zunionstore" : "zinterstore",
            dstkey,c->db->id);

        server.dirty++;

    // 结果集为空
    } else {

        decrRefCount(dstobj);

        addReply(c,shared.czero);

        if (touched)
            notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",dstkey,c->db->id);
    }

    zfree(src);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %rbp
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x313b2
testl %eax, %eax
jne 0x40a1e
movq 0x18(%rsp), %rax
testq %rax, %rax
jle 0x40215
movslq 0x30(%rbp), %rcx
addq $-0x3, %rcx
cmpq %rcx, %rax
jle 0x40229
leaq 0x8a5ff(%rip), %rax     # 0xca800
movq 0x80(%rax), %rsi
movq %rbp, %rdi
callq 0x2d97c
jmp 0x40a1e
leaq 0x5928e(%rip), %rsi     # 0x994aa
movq %rbp, %rdi
callq 0x2dc63
jmp 0x40a1e
movl %r14d, 0x4c(%rsp)
movq %rbx, 0x78(%rsp)
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
callq 0x29a07
movq 0x18(%rsp), %r12
testq %r12, %r12
movq %rax, 0x10(%rsp)
jle 0x402c6
movl $0x3, %r13d
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
movq %rax, %r14
movq 0x8(%rbp), %rdi
movq 0x38(%rbp), %rax
movq (%rax,%r13,8), %rsi
callq 0x31724
testq %rax, %rax
je 0x402a0
movl (%rax), %ecx
andl $0xe, %ecx
cmpl $0x2, %ecx
jne 0x406d4
movq %rax, (%r14)
movl (%rax), %ecx
andl $0xf, %ecx
movl %ecx, 0x8(%r14)
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
movl %eax, 0xc(%r14)
jmp 0x402a7
movq $0x0, (%r14)
movq %rbx, 0x10(%r14)
leaq 0x1(%r13), %r15
movq 0x18(%rsp), %r12
addq $0x30, %r14
addq $-0x2, %r13
cmpq %r13, %r12
movq %r15, %r13
jg 0x40262
jmp 0x402cc
movl $0x3, %r15d
movl 0x30(%rbp), %r13d
subl %r15d, %r13d
setle %al
sete %cl
orb %al, %cl
movl $0x1, %ebx
movq %rbp, 0x40(%rsp)
je 0x40597
leaq -0x165(%rip), %rcx      # 0x4018d
movl $0x30, %edx
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x1f820
callq 0x30946
movq %rax, %r15
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, 0x90(%rsp)
movapd %xmm0, 0xa0(%rsp)
movapd %xmm0, 0xb0(%rsp)
movapd %xmm0, 0xc0(%rsp)
movl 0x4c(%rsp), %eax
cmpl $0x2, %eax
movq %r15, 0x70(%rsp)
je 0x406ee
testl %eax, %eax
jne 0x40a30
cmpq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rax
jle 0x408c4
leaq 0x30(%rax), %rcx
movq %rcx, 0x68(%rsp)
xorl %ecx, %ecx
movl $0x1, %edx
movq %rdx, 0x60(%rsp)
leaq 0x80(%rsp), %r13
leaq 0x20(%rsp), %r12
movl $0x0, 0xc(%rsp)
movq %rcx, 0x58(%rsp)
leaq (%rcx,%rcx,2), %rbp
shlq $0x4, %rbp
addq %rax, %rbp
movq %rbp, %rdi
callq 0x3fc50
testl %eax, %eax
je 0x4056f
movq %rbp, %rdi
callq 0x3faa6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3fd00
testl %eax, %eax
je 0x40567
movq 0x58(%rsp), %rax
incq %rax
movq %rax, 0x50(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %r14
movq %r13, %rdi
callq 0x3ff71
movq %r14, %rdi
movq %rax, %rsi
callq 0x226ac
testq %rax, %rax
jne 0x40554
movsd 0x10(%rbp), %xmm0
mulsd 0xc8(%rsp), %xmm0
movapd %xmm0, %xmm1
cmpordsd %xmm0, %xmm1
andpd %xmm0, %xmm1
movq 0x50(%rsp), %rax
cmpq %rax, 0x18(%rsp)
jle 0x404d4
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %r15
movq (%r14), %rax
cmpq (%rbp), %rax
je 0x40492
movapd %xmm1, 0x30(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4002e
testl %eax, %eax
je 0x404bc
movsd 0x10(%r14), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x2, %ebx
movapd 0x30(%rsp), %xmm1
je 0x404ac
cmpl $0x1, %ebx
jne 0x404b2
addsd %xmm0, %xmm1
ucomisd %xmm1, %xmm1
jnp 0x404c2
xorpd %xmm1, %xmm1
jmp 0x404c2
movsd 0xc8(%rsp), %xmm0
mulsd 0x10(%r14), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x2, %ebx
jne 0x4047d
minsd %xmm1, %xmm0
jmp 0x404b6
maxsd %xmm1, %xmm0
movapd %xmm0, %xmm1
jmp 0x404c2
movapd 0x30(%rsp), %xmm1
incq %r15
addq $0x30, %r14
cmpq %r15, 0x18(%rsp)
jg 0x4043f
movapd %xmm1, 0x30(%rsp)
movq %r13, %rdi
callq 0x3ff71
movq %rax, %r14
movq 0x28(%rsp), %r12
movq 0x8(%r12), %rdi
movapd 0x30(%rsp), %xmm0
movq %rax, %rsi
callq 0x3d10a
movq %rax, %r15
movq 0xa8(%rsp), %rdi
callq 0x306f3
movq (%r12), %rdi
addq $0x8, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x2249c
movq 0xa8(%rsp), %rdi
callq 0x306f3
movl (%r14), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x4054f
movq 0x8(%r14), %rax
movslq -0x8(%rax), %rax
movl 0xc(%rsp), %edx
movl %edx, %ecx
cmpq %rcx, %rax
cmovbel %edx, %eax
movl %eax, 0xc(%rsp)
leaq 0x20(%rsp), %r12
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3fd00
testl %eax, %eax
jne 0x403e6
movq %rbp, %rdi
callq 0x3fbcc
movq 0x58(%rsp), %rcx
incq %rcx
incq 0x60(%rsp)
addq $0x30, 0x68(%rsp)
cmpq %rcx, 0x18(%rsp)
movq 0x10(%rsp), %rax
jg 0x4039e
jmp 0x408ed
movq 0x10(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x30(%rsp)
movslq %r13d, %rax
movslq %r15d, %r14
cmpq %rax, %r12
jge 0x405d0
movq 0x38(%rbp), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rdi
leaq 0x58f22(%rip), %rsi     # 0x994e5
callq 0x1f2e0
testl %eax, %eax
je 0x40651
cmpl $0x2, %r13d
jl 0x408ce
movq 0x38(%rbp), %rbx
movq (%rbx,%r14,8), %rax
movq 0x8(%rax), %rdi
leaq 0x58f1c(%rip), %rsi     # 0x99509
callq 0x1f2e0
testl %eax, %eax
jne 0x408ce
movq 0x8(%rbx,%r14,8), %rax
movq 0x8(%rax), %r14
movq %r14, %rdi
leaq 0x5957d(%rip), %rsi     # 0x99b8a
callq 0x1f2e0
testl %eax, %eax
je 0x4064a
movq %r14, %rdi
leaq 0x58ef3(%rip), %rsi     # 0x99513
callq 0x1f2e0
testl %eax, %eax
je 0x406b9
movq %r14, %rdi
leaq 0x636af(%rip), %rsi     # 0xa3ce6
callq 0x1f2e0
movl $0x3, %ebx
testl %eax, %eax
je 0x406be
jmp 0x408ce
movl $0x1, %ebx
jmp 0x406be
decl %r13d
incl %r15d
testq %r12, %r12
jle 0x406c6
movl %r13d, 0x28(%rsp)
movslq %r15d, %r13
shlq $0x3, %r13
movq 0x30(%rsp), %r14
xorl %ebp, %ebp
movq 0x40(%rsp), %rdi
movq 0x38(%rdi), %rax
addq %r13, %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdx
leaq 0x58e64(%rip), %rcx     # 0x994ed
callq 0x310bf
testl %eax, %eax
jne 0x40a14
incq %rbp
movq 0x18(%rsp), %r12
addq $0x30, %r14
cmpq %rbp, %r12
jg 0x4066f
addl %ebp, %r15d
movl 0x28(%rsp), %r13d
subl %ebp, %r13d
movq 0x40(%rsp), %rbp
jmp 0x406c6
movl $0x2, %ebx
addl $0x2, %r15d
addl $-0x2, %r13d
testl %r13d, %r13d
jne 0x405a5
jmp 0x402eb
movq 0x10(%rsp), %rdi
callq 0x29af7
leaq 0x8a11b(%rip), %rax     # 0xca800
movq 0x70(%rax), %rsi
jmp 0x40208
movq %r14, %rdi
callq 0x3fc50
testl %eax, %eax
jle 0x408c4
movq %r14, %rdi
callq 0x3faa6
leaq 0x80(%rsp), %rsi
movq %r14, %rdi
callq 0x3fd00
testl %eax, %eax
je 0x408dd
movq %r14, %rax
addq $0x30, %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0xc(%rsp)
leaq 0x80(%rsp), %r12
leaq 0x20(%rsp), %r13
movq %r14, %rdi
movq 0x28(%rsp), %r15
movsd 0x10(%rdi), %xmm0
mulsd 0xc8(%rsp), %xmm0
movapd %xmm0, %xmm1
cmpordsd %xmm0, %xmm1
andpd %xmm0, %xmm1
movq 0x18(%rsp), %rax
movl $0x1, %r14d
cmpq $0x2, %rax
jl 0x40839
movq 0x50(%rsp), %rbp
movq (%rbp), %rax
cmpq (%rdi), %rax
je 0x407d7
movapd %xmm1, 0x30(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4002e
testl %eax, %eax
je 0x40829
movsd 0x10(%rbp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x2, %ebx
movapd 0x30(%rsp), %xmm1
je 0x407fb
cmpl $0x1, %ebx
movq 0x10(%rsp), %rdi
jne 0x407f5
addsd %xmm0, %xmm1
ucomisd %xmm1, %xmm1
jnp 0x40812
xorpd %xmm1, %xmm1
jmp 0x40812
movsd 0xc8(%rsp), %xmm0
mulsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x2, %ebx
je 0x4080a
cmpl $0x1, %ebx
je 0x407c7
maxsd %xmm1, %xmm0
jmp 0x4080e
minsd %xmm1, %xmm0
movapd %xmm0, %xmm1
movq 0x10(%rsp), %rdi
jmp 0x40812
minsd %xmm1, %xmm0
movapd %xmm0, %xmm1
incq %r14
movq 0x18(%rsp), %rax
addq $0x30, %rbp
cmpq %r14, %rax
jg 0x4077c
jmp 0x40839
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rdi
movapd 0x30(%rsp), %xmm1
cmpq %r14, %rax
jne 0x408ad
movq %r12, %rdi
movapd %xmm1, 0x30(%rsp)
callq 0x3ff71
movq %rax, %r14
movq 0x8(%r15), %rdi
movapd 0x30(%rsp), %xmm0
movq %rax, %rsi
callq 0x3d10a
movq %rax, %rbp
movq %r14, %rdi
callq 0x306f3
movq (%r15), %rdi
addq $0x8, %rbp
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2249c
movq %r14, %rdi
callq 0x306f3
movl (%r14), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x408a8
movq 0x8(%r14), %rax
movslq -0x8(%rax), %rax
movl 0xc(%rsp), %edx
movl %edx, %ecx
cmpq %rcx, %rax
cmovbel %edx, %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x3fd00
movq 0x10(%rsp), %rdi
testl %eax, %eax
jne 0x40747
jmp 0x408e8
movl $0x0, 0xc(%rsp)
jmp 0x408ed
movq 0x10(%rsp), %rdi
callq 0x29af7
jmp 0x401fa
movl $0x0, 0xc(%rsp)
movq %r14, %rdi
callq 0x3fbcc
movq 0x40(%rsp), %rbx
movq 0x8(%rbx), %rdi
movq 0x78(%rsp), %r15
movq %r15, %rsi
callq 0x31a36
movl %eax, %ebp
testl %eax, %eax
je 0x40923
movq 0x8(%rbx), %rdi
movq %r15, %rsi
callq 0x319b8
leaq 0x8968c(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
movl 0x4c(%rsp), %r12d
movq 0x70(%rsp), %r13
je 0x409d5
leaq 0x8965e(%rip), %rbx     # 0xc9fa8
cmpq 0x780(%rbx), %rax
ja 0x4096d
movl 0xc(%rsp), %eax
cmpq %rax, 0x788(%rbx)
jb 0x4096d
movq %r13, %rdi
movl $0x5, %esi
callq 0x3eb2c
movq 0x40(%rsp), %r14
movq 0x8(%r14), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x317f0
movq %r13, %rdi
callq 0x3eadd
movl %eax, %esi
movq %r14, %rdi
callq 0x2e133
testl %ebp, %ebp
jne 0x409a3
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0x319b8
testl %r12d, %r12d
leaq 0x53a67(%rip), %rax     # 0x94414
leaq 0x53a6c(%rip), %rsi     # 0x94420
cmoveq %rax, %rsi
movq 0x8(%r14), %rax
movl 0x30(%rax), %ecx
movl $0x80, %edi
movq %r15, %rdx
callq 0x60371
incq 0x560(%rbx)
jmp 0x40a14
movq %r13, %rdi
callq 0x30b0c
leaq 0x89e1c(%rip), %rax     # 0xca800
movq 0x20(%rax), %rsi
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d97c
testl %ebp, %ebp
je 0x40a14
movq 0x8(%rbx), %rax
movl 0x30(%rax), %ecx
leaq 0x53ad6(%rip), %rsi     # 0x944dd
movl $0x4, %edi
movq %r15, %rdx
callq 0x60371
movq 0x10(%rsp), %rdi
callq 0x29af7
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58ae0(%rip), %rdi     # 0x99517
leaq 0x587c1(%rip), %rsi     # 0x991ff
movl $0xb66, %edx            # imm = 0xB66
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0