// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
cmpl $0x0, 0x1c(%rdi)
jg 0x5544
cmpl $0x0, 0x18(%rbx)
jle 0x56c8
pushq $0x1
popq %rcx
xorpd %xmm0, %xmm0
pushq $0x17
popq %rax
movl %ecx, %ecx
cmpl $0x16, %ecx
jae 0x556b
movss (%r12,%rcx,4), %xmm1
incq %rcx
ucomiss %xmm0, %xmm1
jbe 0x5550
decl %ecx
movl %ecx, %ebp
movl %eax, %ecx
jmp 0x554e
movl $0xfffffc18, %r14d      # imm = 0xFFFFFC18
pushq $0x1
popq %r13
xorl %r15d, %r15d
movq %r12, (%rsp)
cmpq $0x16, %r13
je 0x5606
movss (%r12,%r13,4), %xmm0
ucomiss 0x3a9d(%rip), %xmm0     # 0x9030
ja 0x559d
movl 0x20(%rbx), %eax
cmpq %rax, %r13
jne 0x55fe
imulq $0x18, %r13, %rax
leaq 0xaee8(%rip), %rcx      # 0x10490
leaq (%rcx,%rax), %r12
addq $0x8, %r12
movq (%r12), %r12
testq %r12, %r12
je 0x55fa
movq %r12, %rdi
callq 0x4f92
movl 0x20(%rbx), %ecx
leal 0xfa(%rax), %edx
cmpq %rcx, %r13
cmovnel %eax, %edx
leaq 0x9649(%rip), %rax      # 0xec20
cmpl $0x0, (%rax,%r13,8)
leal -0x96(%rdx), %eax
cmovlel %edx, %eax
cmpl %r14d, %eax
cmovgl %r13d, %ebp
cmovgl %eax, %r14d
cmovgq %r12, %r15
addq $0x38, %r12
jmp 0x55b0
movq (%rsp), %r12
incq %r13
jmp 0x557c
movslq 0x20(%rbx), %rax
cmpl %eax, %ebp
jne 0x568a
testq %r15, %r15
je 0x56c8
cmpl $0x0, 0xc(%r15)
jne 0x56c8
cmpl $0x0, 0x20(%r15)
je 0x56c8
cmpl $0x13, 0x14(%r15)
jg 0x56d7
leaq 0xb079(%rip), %rax      # 0x106b8
imull $0x7, 0x18(%rbx), %ecx
imull $0x28, 0x1c(%rbx), %edx
addl %ecx, %edx
imull (%rax), %edx
movl 0x10(%r15), %esi
shll $0x2, %esi
cmpl %esi, %edx
cmovll %edx, %esi
movq %r15, %rdi
callq 0x37b8
movslq 0x30(%r15), %rax
leaq 0x95b5(%rip), %rcx      # 0xec20
cmpl $0x0, 0x4(%rcx,%rax,8)
jg 0x5680
leaq 0x9657(%rip), %rcx      # 0xecd0
cmpl $0x0, 0x4(%rcx,%rax,8)
jle 0x56c8
movl 0x4(%r15), %eax
movl %eax, 0x8(%r15)
jmp 0x56c8
leaq 0x958f(%rip), %rcx      # 0xec20
decl (%rcx,%rax,8)
movl 0x20(%rbx), %edi
callq 0x4e5c
movl %ebp, 0x20(%rbx)
movslq %ebp, %rax
cvtss2sd (%r12,%rax,4), %xmm0
addsd 0x3ba8(%rip), %xmm0     # 0x9258
leaq 0xaff1(%rip), %rax      # 0x106a8
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x24(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, 0x1c(%rbx)
jg 0x56e3
cmpl $0x4, 0x18(%rbx)
jl 0x56c8
pushq $0x4
popq %rdi
callq 0x4e19
cmpl $0x4, %eax
je 0x56f6
cmpl $0x9, 0x1c(%rbx)
jl 0x56c8
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4e86