// File: /workspace/github_c_makefile_star2_O1/beejjorgensen[P]conquest/conq4.c
// Function: tf_battle
void tf_battle(int starnum)
{
    int ennum, plnum;
    float enodds, plodds;
    boolean battle;
    int count, new_tf, i;
    char ch;
    boolean pla_loss, ene_loss;
    int size;
    tteam team;
    int dstar;
    float slist[nstars + 1];
    boolean fin, first;
    board[stars[starnum].x][stars[starnum].y].enemy = '!';
    update_board(stars[starnum].x, stars[starnum].y, left);
    ennum = 1;
    while ((tf[ENEMY][ennum].dest != starnum)
           || (tf[ENEMY][ennum].eta != 0)
        )
        ennum = ennum + 1;
    plnum = 1;
    if (tf_stars[starnum][player] > 1) {
        get_tf(player, &new_tf, starnum);
        for (i = 1; i <= 26; i++) {
            if ((tf[player][i].dest == starnum) && (tf[player][i].eta == 0)
                && (i != new_tf))
                joinsilent(player, &tf[player][new_tf], &tf[player][i]);
        };
        tf_stars[starnum][player] = 1;
        plnum = new_tf;
    } else {
        while ((tf[player][plnum].dest != starnum)
               || (tf[player][plnum].eta != 0)
            )
            plnum = plnum + 1;
    };
    display_forces(ennum, plnum, &enodds, &plodds, &battle);
    pause();
    first = true;
    while (battle) {
        if (left_line[24]) {
            point(1, 24);
            printw(blank_line);
            left_line[24] = false;
        };
        pla_loss = true;
        ene_loss = true;
        point(1, 21);
        printw(" Enemy losses:                ");
        point(1, 22);
        printw("Player losses:                ");
        do {
            point(15, 21);
            lose(&tf[ENEMY][ennum].t, &ene_loss, 't', enodds);
            lose(&tf[ENEMY][ennum].s, &ene_loss, 's', enodds);
            lose(&tf[ENEMY][ennum].c, &ene_loss, 'c', enodds);
            lose(&tf[ENEMY][ennum].b, &ene_loss, 'b', enodds);
            point(15, 22);
            lose(&tf[player][plnum].t, &pla_loss, 't', plodds);
            lose(&tf[player][plnum].s, &pla_loss, 's', plodds);
            lose(&tf[player][plnum].c, &pla_loss, 'c', plodds);
            lose(&tf[player][plnum].b, &pla_loss, 'b', plodds);
        }
        while (!first && ene_loss && pla_loss);
        if (ene_loss) {
            point(15, 21);
            printw("(none)");
        };
        if (pla_loss) {
            point(15, 22);
            printw("(none)");
        };
        first = false;
        display_forces(ennum, plnum, &enodds, &plodds, &battle);
        if (battle) {
            /*withdraw the bad guys */
            get_tf(ENEMY, &new_tf, starnum);
            if ((tf[player][plnum].c > 0) || (tf[player][plnum].b > 0)
                ) {
                tf[ENEMY][new_tf].t = tf[ENEMY][ennum].t;
                tf[ENEMY][new_tf].s = tf[ENEMY][ennum].s;
                best_plan(&starnum, &size, &team);
                if (((enodds < 0.7) && (size < 30)) || ((enodds < 0.50)
                                                        && (team ==
                                                            player))
                    || ((enodds < 0.30) && (size < 60))
                    || (enodds < 0.20)) {
                    tf[ENEMY][new_tf].c = tf[ENEMY][ennum].c;
                    tf[ENEMY][new_tf].b = tf[ENEMY][ennum].b;
                };
            };
            if ((tf[ENEMY][new_tf].t + tf[ENEMY][new_tf].s +
                 tf[ENEMY][new_tf].c + tf[ENEMY][new_tf].b) > 0) {
                get_stars(starnum, slist, &count);
                do {
                    dstar = rnd(nstars);
                }
                while (slist[dstar] <= 0);
                tf[ENEMY][new_tf].dest = dstar;
                tf[ENEMY][new_tf].eta =
                    (int) ((slist[dstar] - 0.01) / vel[ENEMY]) + 1;
                tf[ENEMY][new_tf].xf = stars[starnum].x;
                tf[ENEMY][new_tf].yf = stars[starnum].y;
            } else
                tf[ENEMY][new_tf].dest = 0;

            fin = false;
            do {
                point(1, 18);
                printw("B?                            ");
                point(3, 18);
                get_char(&ch);
                switch (ch) {
                case 'M':
                    printmap();
                    break;
                case 'H':
                    help(2);
                    break;
                case 'S':
                    starsum();
                    break;
                case 'T':
                    tfsum();
                    break;
                case 'C':
                    print_col();
                    break;
                case '?':
                    break;
                case 'R':
                    ressum();
                    break;
                case 'O':
                    display_forces(ennum, plnum, &enodds, &plodds,
                                   &battle);
                    break;
                case 'W':
                    withdraw(starnum, plnum);
                    display_forces(ennum, plnum, &enodds, &plodds,
                                   &battle);
                    break;
                case ' ':
                case 'G':
                    fin = true;
                    break;
                default:
                    printw("!illegal command");
                };              /*switch ( */
            }
            while (!fin && battle);
            zero_tf(ENEMY, new_tf);
            zero_tf(player, plnum);
            if (tf[ENEMY][new_tf].dest != 0) {
                point(1, 23);
                printw("en withdraws");
                point(14, 23);
                disp_tf(&tf[ENEMY][new_tf]);
                tf[ENEMY][ennum].t =
                    tf[ENEMY][ennum].t - tf[ENEMY][new_tf].t;
                tf[ENEMY][ennum].s =
                    tf[ENEMY][ennum].s - tf[ENEMY][new_tf].s;
                tf[ENEMY][ennum].c =
                    tf[ENEMY][ennum].c - tf[ENEMY][new_tf].c;
                tf[ENEMY][ennum].b =
                    tf[ENEMY][ennum].b - tf[ENEMY][new_tf].b;
                zero_tf(ENEMY, ennum);
                display_forces(ennum, plnum, &enodds, &plodds, &battle);
            };
        };
    };
    zero_tf(ENEMY, ennum);
    zero_tf(player, plnum);
    revolt(starnum);
    on_board(stars[starnum].x, stars[starnum].y);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %edi, 0x4(%rsp)
movslq %edi, %rax
leaq (%rax,%rax,2), %rax
leaq 0xc63f(%rip), %rcx      # 0xf4a0
movslq (%rcx,%rax,8), %rdi
movslq 0x4(%rcx,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rax
leaq (%rdi,%rdi,2), %rcx
shlq $0x6, %rcx
addq 0xa12b(%rip), %rcx      # 0xcfa8
movl $0x21, (%rcx,%rax,4)
movl $0x1, %ebp
movl $0x1, %edx
callq 0x2d64
movslq 0x4(%rsp), %rdx
leaq 0xbb01(%rip), %r13      # 0xe9a0
leaq 0x44(%r13), %r14
cmpl %edx, 0x10(%r14)
jne 0x2eb0
cmpl $0x0, 0x14(%r14)
je 0x2eb8
incl %ebp
addq $0x34, %r14
jmp 0x2ea3
leaq 0xad71(%rip), %r15      # 0xdc30
cmpl $0x1, 0x4(%r15,%rdx,8)
jle 0x357b
movq %rsp, %rsi
movl $0x1, %edi
callq 0x2a18
movl $0x5b0, %ebx            # imm = 0x5B0
addq 0xa0d4(%rip), %rbx      # 0xcfb8
movl $0x1, %r12d
movl 0x20(%rbx), %eax
cmpl 0x4(%rsp), %eax
jne 0x2f1f
cmpl $0x0, 0x24(%rbx)
jne 0x2f1f
movl (%rsp), %eax
cmpq %rax, %r12
je 0x2f1f
cltq
imulq $0x34, %rax, %rax
leaq (%rax,%r13), %rsi
addq $0x57c, %rsi            # imm = 0x57C
movl $0x1, %edi
movq %rbx, %rdx
callq 0x2a93
incq %r12
addq $0x34, %rbx
cmpq $0x1b, %r12
jne 0x2eea
movslq 0x4(%rsp), %rax
movl $0x1, 0x4(%r15,%rax,8)
movl (%rsp), %esi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %rbx
movl %ebp, 0x1c(%rsp)
movl %ebp, %edi
movl %esi, 0x10(%rsp)
movq %rbx, %r8
callq 0x24fd
callq 0x763e
cmpl $0x0, (%rbx)
je 0x352b
leaq 0x4(%r14), %rax
movq %rax, 0x50(%rsp)
leaq 0x8(%r14), %r15
leaq 0xc(%r14), %rax
movq %rax, 0x38(%rsp)
movslq 0x10(%rsp), %rax
imulq $0x34, %rax, %rax
leaq 0xba0e(%rip), %rcx      # 0xe9a0
leaq (%rcx,%rax), %rdx
addq $0x590, %rdx            # imm = 0x590
movq %rdx, 0x60(%rsp)
leaq 0x58c(%rcx,%rax), %rdx
movq %rdx, 0x58(%rsp)
leaq 0x594(%rcx,%rax), %rdx
movq %rdx, 0x40(%rsp)
leaq 0x598(%rcx,%rax), %rax
movq %rax, 0x30(%rsp)
leaq 0xc900(%rip), %rbx      # 0xf8d0
leaq 0x24(%rsp), %rbp
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq %r14, 0x48(%rsp)
cmpl $0x0, 0x60(%rbx)
je 0x300c
movl $0x1, %edi
movl $0x18, %esi
callq 0x4f69
leaq 0x62d1(%rip), %rdi      # 0x92cf
xorl %eax, %eax
callq 0x2030
movl $0x0, 0x60(%rbx)
movl $0x1, %eax
movl %eax, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movl $0x1, %edi
movl $0x15, %esi
callq 0x4f69
leaq 0x62bf(%rip), %rdi      # 0x92ee
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
movl $0x16, %esi
callq 0x4f69
leaq 0x62c1(%rip), %rdi      # 0x930d
xorl %eax, %eax
callq 0x2030
movl $0xf, %edi
movl $0x15, %esi
callq 0x4f69
movss 0x8(%rsp), %xmm0
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
movl $0x74, %edx
callq 0x2ad3
movss 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbp, %rsi
movl $0x73, %edx
callq 0x2ad3
movss 0x8(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movl $0x63, %edx
callq 0x2ad3
movss 0x8(%rsp), %xmm0
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
movl $0x62, %edx
callq 0x2ad3
movl $0xf, %edi
movl $0x16, %esi
callq 0x4f69
movss 0xc(%rsp), %xmm0
movq 0x60(%rsp), %rdi
movq %r12, %rsi
movl $0x74, %edx
callq 0x2ad3
movss 0xc(%rsp), %xmm0
movq 0x58(%rsp), %rdi
movq %r12, %rsi
movl $0x73, %edx
callq 0x2ad3
movss 0xc(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movq %r12, %rsi
movl $0x63, %edx
callq 0x2ad3
movss 0xc(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movl $0x62, %edx
callq 0x2ad3
movl 0x24(%rsp), %eax
testl %eax, %eax
setne %cl
andb %r13b, %cl
cmpb $0x1, %cl
jne 0x3149
cmpl $0x0, 0x20(%rsp)
jne 0x3053
testl %eax, %eax
leaq 0x61e1(%rip), %rbx      # 0x9333
je 0x3171
movl $0xf, %edi
movl $0x15, %esi
callq 0x4f69
leaq 0x61c2(%rip), %rdi      # 0x932c
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x20(%rsp)
leaq 0xb823(%rip), %r13      # 0xe9a0
je 0x319c
movl $0xf, %edi
movl $0x16, %esi
callq 0x4f69
leaq 0x6197(%rip), %rdi      # 0x932c
xorl %eax, %eax
callq 0x2030
movl 0x1c(%rsp), %edi
movl 0x10(%rsp), %esi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x24fd
cmpl $0x0, 0x14(%rsp)
je 0x34e0
movl 0x4(%rsp), %edx
xorl %edi, %edi
movq %rsp, %rsi
callq 0x2a18
movq 0x40(%rsp), %rax
cmpl $0x0, (%rax)
jg 0x31e9
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x3278
movl 0x4(%r14), %eax
movslq (%rsp), %rcx
imulq $0x34, %rcx, %rcx
movl %eax, 0x14(%r13,%rcx)
movl (%r14), %eax
movl %eax, 0x10(%r13,%rcx)
leaq 0x4(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x22b6
movss 0x8(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movsd 0x6015(%rip), %xmm2     # 0x9240
ucomisd %xmm0, %xmm2
seta %cl
movl 0x2c(%rsp), %eax
cmpl $0x1e, %eax
setl %dl
testb %dl, %cl
jne 0x325c
movss 0x6018(%rip), %xmm2     # 0x9260
ucomiss %xmm1, %xmm2
jbe 0x34f7
cmpl $0x1, 0x28(%rsp)
jne 0x34f7
movl (%r15), %eax
movslq (%rsp), %rcx
imulq $0x34, %rcx, %rcx
movl %eax, 0x18(%r13,%rcx)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1c(%r13,%rcx)
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movl 0x10(%r13,%rax), %ecx
addl 0x14(%r13,%rax), %ecx
addl 0x18(%r13,%rax), %ecx
addl 0x1c(%r13,%rax), %ecx
jle 0x3322
movl 0x4(%rsp), %edi
leaq 0x70(%rsp), %rsi
leaq 0x6c(%rsp), %rdx
callq 0x72ca
movl $0x15, %edi
callq 0x4fc5
movslq %eax, %rcx
movss 0x70(%rsp,%rcx,4), %xmm0
xorpd %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jae 0x32ad
movslq (%rsp), %rcx
imulq $0x34, %rcx, %rcx
movl %eax, 0x20(%r13,%rcx)
cvtss2sd %xmm0, %xmm0
leaq 0xc3d7(%rip), %rax      # 0xf6b8
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
addsd 0x5f68(%rip), %xmm0     # 0x9258
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x24(%r13,%rcx)
movslq 0x4(%rsp), %rax
leaq (%rax,%rax,2), %rax
leaq 0xc191(%rip), %rsi      # 0xf4a0
movl (%rsi,%rax,8), %edx
movl %edx, 0x8(%r13,%rcx)
movl 0x4(%rsi,%rax,8), %eax
movl %eax, 0xc(%r13,%rcx)
jmp 0x332c
addq %r13, %rax
movl $0x0, 0x20(%rax)
xorl %r13d, %r13d
movl $0x1, %edi
movl $0x12, %esi
callq 0x4f69
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2030
movl $0x3, %edi
movl $0x12, %esi
callq 0x4f69
leaq 0x1b(%rsp), %rdi
callq 0x7187
movzbl 0x1b(%rsp), %eax
leal -0x3f(%rax), %ecx
cmpl $0x18, %ecx
ja 0x3388
leaq 0x5eef(%rip), %rdx      # 0x9264
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
callq 0x4000
jmp 0x340c
cmpl $0x20, %eax
jne 0x3395
movl $0x1, %r13d
jmp 0x340c
leaq 0x6796(%rip), %rdi      # 0x9b32
xorl %eax, %eax
callq 0x2030
jmp 0x340c
callq 0x61f4
jmp 0x340c
movl 0x4(%rsp), %edi
movl 0x10(%rsp), %ebx
movl %ebx, %esi
callq 0x35a2
movl 0x1c(%rsp), %edi
movl %ebx, %esi
leaq 0x5f6b(%rip), %rbx      # 0x9333
movq 0x48(%rsp), %r14
jmp 0x33d7
movl 0x1c(%rsp), %edi
movl 0x10(%rsp), %esi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x24fd
jmp 0x340c
movl $0x2, %edi
callq 0x74d3
jmp 0x340c
callq 0x7c11
jmp 0x340c
callq 0x41f9
jmp 0x340c
callq 0x42e1
testl %r13d, %r13d
jne 0x341c
cmpl $0x0, 0x14(%rsp)
jne 0x332f
movl (%rsp), %esi
xorl %edi, %edi
callq 0x3695
movl $0x1, %edi
movl 0x10(%rsp), %esi
callq 0x3695
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
leaq 0xb55d(%rip), %r13      # 0xe9a0
cmpl $0x0, 0x20(%r13,%rax)
je 0x34e0
movl $0x1, %edi
movl $0x17, %esi
callq 0x4f69
leaq 0x5eed(%rip), %rdi      # 0x9352
xorl %eax, %eax
callq 0x2030
movl $0xe, %edi
movl $0x17, %esi
callq 0x4f69
movslq (%rsp), %rax
imulq $0x34, %rax, %rdi
addq %r13, %rdi
callq 0x27a9
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movl 0x14(%r13,%rax), %ecx
subl %ecx, 0x4(%r14)
movl 0x10(%r13,%rax), %ecx
subl %ecx, (%r14)
movl 0x18(%r13,%rax), %ecx
subl %ecx, 0x8(%r14)
movl 0x1c(%r13,%rax), %eax
subl %eax, 0xc(%r14)
xorl %edi, %edi
movl 0x1c(%rsp), %r13d
movl %r13d, %esi
callq 0x3695
movl %r13d, %edi
movl 0x10(%rsp), %esi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x24fd
movb $0x1, %r13b
cmpl $0x0, 0x14(%rsp)
leaq 0xc3e1(%rip), %rbx      # 0xf8d0
jne 0x2fe2
jmp 0x352b
movsd 0x5d49(%rip), %xmm1     # 0x9248
ucomisd %xmm0, %xmm1
seta %cl
cmpl $0x3c, %eax
setl %al
movsd 0x5d3c(%rip), %xmm1     # 0x9250
ucomisd %xmm0, %xmm1
ja 0x325c
andb %al, %cl
je 0x3278
jmp 0x325c
xorl %edi, %edi
movl 0x1c(%rsp), %esi
callq 0x3695
movl $0x1, %edi
movl 0x10(%rsp), %esi
callq 0x3695
movl 0x4(%rsp), %edi
callq 0x43a8
movslq 0x4(%rsp), %rax
leaq (%rax,%rax,2), %rax
leaq 0xbf43(%rip), %rcx      # 0xf4a0
movl (%rcx,%rax,8), %edi
movl 0x4(%rcx,%rax,8), %esi
callq 0x7580
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5d4, %eax            # imm = 0x5D4
addq 0x9a31(%rip), %rax      # 0xcfb8
movl $0x1, %esi
cmpl %edx, -0x4(%rax)
jne 0x359a
cmpl $0x0, (%rax)
je 0x2f3d
incl %esi
addq $0x34, %rax
jmp 0x358c