// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conqmc.c
// Function: move_bc
void move_bc(struct sttf *task, float slist[nstars + 1])
{
    int best_star, top_score, starnum, score, factors;
    struct stplanet *pplanet, *best_planet;

    if ((task->b > 0) || (task->c > 0)) {
        for (starnum = 1; starnum <= nstars; starnum++) {
            if (slist[starnum] > 0) {
                best_star = starnum;
                starnum = nstars + 1;
            };
        };
        best_planet = nil;
        top_score = -1000;
        for (starnum = 1; starnum <= nstars; starnum++) {
            if ((slist[starnum] > 0) || (starnum == task->dest)) {
                pplanet = stars[starnum].first_planet;
                while (pplanet != nil) {
                    score = eval_bc_col(pplanet);
                    if (starnum == task->dest)
                        score += 250;

                    if (tf_stars[starnum][ENEMY] > 0)
                        score -= 150;

                    if (score > top_score) {
                        top_score = score;
                        best_planet = pplanet;
                        best_star = starnum;
                    };
                    pplanet = pplanet->next;
                };
            };
        };
        if (best_star == task->dest) {  /*stay put */
            if (best_planet != nil) {
                if ((best_planet->team == ENEMY)
                    && (best_planet->conquered)
                    && (best_planet->iu < 20)) {
                    factors =
                        weapons[ENEMY] * ((task->c * c_guns) +
                                          (task->b * b_guns));
                    factors = MIN(factors, 4 * best_planet->inhabitants);
                    blast(best_planet, factors);
                    if ((tf_stars[best_planet->pstar][player] > 0) ||
                        (col_stars[best_planet->pstar][player] > 0))
                        best_planet->psee_capacity = best_planet->capacity;
                } else if ((best_planet->team == ENEMY) && (best_planet->conquered)) {  /*decide whether to split */
                    if ((((task->b > 3) || (task->c > 3)) && (rnd(4) == 4))
                        || (task->b > 8))
                        wander_bc(task, slist);
                };
            };
        } else {                /*move */
            tf_stars[task->dest][ENEMY]--;
            depart(task->dest);
            task->dest = best_star;
            task->eta = (int) ((slist[best_star] - 0.01) / vel[ENEMY]) + 1;
        };
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %r13
cmpl $0x0, 0x1c(%rdi)
jg 0x57d6
cmpl $0x0, 0x18(%r13)
jle 0x5982
movl $0x1, %eax
xorps %xmm0, %xmm0
movss (%r12,%rax,4), %xmm1
ucomiss %xmm0, %xmm1
cmoval %eax, %edx
ja 0x57fa
movq %rax, %rcx
incq %rcx
cmpl $0x15, %eax
movq %rcx, %rax
jb 0x57de
movl $0xfffffc18, %r14d      # imm = 0xFFFFFC18
movl $0x1, %ecx
xorl %ebp, %ebp
leaq 0x8412(%rip), %rsi      # 0xdc20
movq %r12, 0x10(%rsp)
movss (%r12,%rcx,4), %xmm0
ucomiss 0x3858(%rip), %xmm0     # 0x9078
ja 0x582b
movl 0x20(%r13), %eax
cmpq %rax, %rcx
jne 0x588f
leaq (%rcx,%rcx,2), %rax
leaq 0x9c5a(%rip), %rdi      # 0xf490
movq 0x8(%rdi,%rax,8), %r12
testq %r12, %r12
je 0x588f
movl %edx, 0xc(%rsp)
movq %r12, %rdi
movq %rsi, %rbx
movq %rcx, %r15
callq 0x517a
movq %rbx, %rsi
movl 0x20(%r13), %ecx
leal 0xfa(%rax), %edx
cmpq %rcx, %r15
movq %r15, %rcx
cmovnel %eax, %edx
cmpl $0x0, (%rbx,%r15,8)
leal -0x96(%rdx), %eax
cmovlel %edx, %eax
movl 0xc(%rsp), %edx
cmpl %r14d, %eax
cmovgl %ecx, %edx
cmovgl %eax, %r14d
cmovgq %r12, %rbp
movq 0x38(%r12), %r12
jmp 0x583b
incq %rcx
cmpq $0x16, %rcx
movq 0x10(%rsp), %r12
jne 0x5813
movslq 0x20(%r13), %rax
cmpl %eax, %edx
jne 0x5928
testq %rbp, %rbp
je 0x5982
cmpl $0x0, 0xc(%rbp)
jne 0x5982
cmpl $0x0, 0x20(%rbp)
je 0x5982
cmpl $0x13, 0x14(%rbp)
jg 0x5991
leaq 0x9de1(%rip), %rax      # 0xf6b8
movl 0x18(%r13), %ecx
movl 0x1c(%r13), %edx
movq %rsi, %rbx
leal (,%rcx,8), %esi
subl %ecx, %esi
leal (%rdx,%rdx,4), %ecx
leal (%rsi,%rcx,8), %ecx
imull (%rax), %ecx
movl 0x10(%rbp), %esi
shll $0x2, %esi
cmpl %esi, %ecx
cmovll %ecx, %esi
movq %rbp, %rdi
callq 0x3900
movslq 0x30(%rbp), %rax
cmpl $0x0, 0x4(%rbx,%rax,8)
jg 0x5920
leaq 0x83b7(%rip), %rcx      # 0xdcd0
cmpl $0x0, 0x4(%rcx,%rax,8)
jle 0x5982
movl 0x4(%rbp), %eax
movl %eax, 0x8(%rbp)
jmp 0x5982
decl (%rsi,%rax,8)
movslq 0x20(%r13), %rax
leaq 0x839a(%rip), %rcx      # 0xdcd0
movl 0x4(%rcx,%rax,8), %ecx
addl 0x4(%rsi,%rax,8), %ecx
jle 0x594e
leaq 0x9ea9(%rip), %rcx      # 0xf7f0
movl $0x1, (%rcx,%rax,4)
movl %edx, 0x20(%r13)
movslq %edx, %rax
xorps %xmm0, %xmm0
cvtss2sd (%r12,%rax,4), %xmm0
addsd 0x393a(%rip), %xmm0     # 0x92a0
leaq 0x9d3b(%rip), %rax      # 0xf6a8
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x24(%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, 0x1c(%r13)
jg 0x599f
cmpl $0x4, 0x18(%r13)
jl 0x5982
movl $0x4, %edi
callq 0x4fd5
cmpl $0x4, %eax
je 0x59b5
cmpl $0x9, 0x1c(%r13)
jl 0x5982
movq %r13, %rdi
movq %r12, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5046