// File: /workspace/github_c_makefile_star2_O2/beejjorgensen[P]conquest/conq1.c
// Function: EN2MY_attack
void EN2MY_attack(int starnum)
{
    int attack_factors, def_factors;
    float odds, best_score;
    struct stplanet *pplanet, *best_planet;
    int en_tf, i;
    boolean first[8];
    for (i = 1; i <= 7; i++)
        first[i] = true;
    en_tf = 1;
    while ((tf[ENEMY][en_tf].dest != starnum) ||
           (tf[ENEMY][en_tf].eta != 0))
        en_tf = en_tf + 1;
    do {
        attack_factors = tf[ENEMY][en_tf].c + 6 * tf[ENEMY][en_tf].b;
        best_planet = nil;
        best_score = 1000;
        pplanet = stars[starnum].first_planet;
        while (pplanet != nil) {
            if (pplanet->team == player) {
                def_factors = pplanet->esee_def;
                odds = (float) def_factors / attack_factors;
                if (pplanet->capacity > 30)
                    odds = (odds - 2) * pplanet->capacity;
                else
                    odds = (odds - 1.5) * pplanet->capacity;
                if (odds < best_score) {
                    best_score = odds;
                    best_planet = pplanet;
                };
            };
            pplanet = pplanet->next;
        };
        if (best_score < 0) {
            cle3r_left();
            point(1, 19);
            printw("Enemy attacks: %c%d", starnum + 'A' - 1,
                   best_planet->number);
            point(50, 1);
            pr5nt_star(starnum);
            clear_field();
            pause();
            fire_salvo(ENEMY, &tf[ENEMY][en_tf], 0, best_planet,
                       first[best_planet->number]);
            first[best_planet->number] = false;
            zero_tf(ENEMY, en_tf);
            best_planet->esee_def = best_planet->mb + 6 * best_planet->amb;
            pause();
        };
    }
    while (best_score < 0 && any_bc(ENEMY, starnum));
    revolt(starnum);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
pushq $0x1
popq %rax
cmpq $0x8, %rax
je 0x280c
movl $0x1, 0x10(%rsp,%rax,4)
incq %rax
jmp 0x27f9
leaq 0xd17d(%rip), %r14      # 0xf990
addq $0x34, %r14
pushq $0x1
popq %rbp
cmpl %ebx, 0x20(%r14)
jne 0x2827
cmpl $0x0, 0x24(%r14)
je 0x282f
incl %ebp
addq $0x34, %r14
jmp 0x281a
movslq %ebx, %r15
imulq $0x18, %r15, %rax
leaq 0xdc53(%rip), %rcx      # 0x10490
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
addl $0x40, %r15d
movss 0x67d7(%rip), %xmm4     # 0x902c
movsd 0x67c3(%rip), %xmm5     # 0x9020
pushq $0x1
popq %r12
imull $0x6, 0x1c(%r14), %eax
addl 0x18(%r14), %eax
cvtsi2ss %eax, %xmm0
movss 0x67b2(%rip), %xmm1     # 0x9028
movq 0x8(%rsp), %rax
xorl %r13d, %r13d
movq (%rax), %rax
testq %rax, %rax
je 0x28d0
cmpl $0x1, 0xc(%rax)
jne 0x28ca
cvtsi2ssl 0x2c(%rax), %xmm3
divss %xmm0, %xmm3
movl 0x4(%rax), %ecx
cmpl $0x1f, %ecx
jl 0x28ab
addss %xmm4, %xmm3
cvtsi2ss %ecx, %xmm2
mulss %xmm3, %xmm2
jmp 0x28bf
cvtss2sd %xmm3, %xmm2
cvtsi2sd %ecx, %xmm3
addsd %xmm5, %xmm2
mulsd %xmm2, %xmm3
cvtsd2ss %xmm3, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x28ca
movaps %xmm2, %xmm1
movq %rax, %r13
addq $0x38, %rax
jmp 0x287e
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x297a
callq 0x6f4d
movl %r12d, %edi
pushq $0x13
popq %rsi
callq 0x4dbd
movl (%r13), %edx
leaq 0x6860(%rip), %rdi      # 0x9157
movl %r15d, %esi
xorl %eax, %eax
callq 0x2030
pushq $0x32
popq %rdi
movl %r12d, %esi
callq 0x4dbd
movl %ebx, %edi
callq 0x72df
callq 0x6eef
callq 0x71b1
movslq (%r13), %rax
movl 0x10(%rsp,%rax,4), %r8d
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x383d
movslq (%r13), %rax
andl $0x0, 0x10(%rsp,%rax,4)
xorl %edi, %edi
movl %ebp, %esi
callq 0x35b4
imull $0x6, 0x1c(%r13), %eax
addl 0x18(%r13), %eax
movl %eax, 0x2c(%r13)
callq 0x71b1
xorl %edi, %edi
movl %ebx, %esi
callq 0x222c
movsd 0x66b6(%rip), %xmm5     # 0x9020
movss 0x66ba(%rip), %xmm4     # 0x902c
testl %eax, %eax
jne 0x2861
movl %ebx, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4248
nop