// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
movl %edi, %ebx
movl %edi, 0x8(%rsp)
movslq %edi, %r12
leaq (%r12,%r12,2), %rax
leaq 0xc599(%rip), %rcx      # 0xf490
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 0xa08d(%rip), %rcx      # 0xcfa0
movl $0x21, (%rcx,%rax,4)
movl $0x1, %ebp
movl $0x1, %edx
callq 0x2df8
leaq 0xba60(%rip), %rax      # 0xe990
leaq 0x44(%rax), %r14
cmpl %ebx, 0x10(%r14)
jne 0x2f41
cmpl $0x0, 0x14(%r14)
je 0x2f49
incl %ebp
addq $0x34, %r14
jmp 0x2f34
leaq 0xacd0(%rip), %r15      # 0xdc20
cmpl $0x1, 0x4(%r15,%r12,8)
jle 0x35db
movq %rsp, %rsi
movl $0x1, %edi
movl %ebx, %edx
callq 0x2ac4
movl $0x5b0, %ebx            # imm = 0x5B0
addq 0xa039(%rip), %rbx      # 0xcfb0
movl $0x1, %r12d
movl 0x20(%rbx), %eax
cmpl 0x8(%rsp), %eax
jne 0x2fb9
cmpl $0x0, 0x24(%rbx)
jne 0x2fb9
movl (%rsp), %eax
cmpq %rax, %r12
je 0x2fb9
cltq
imulq $0x34, %rax, %rax
leaq 0xb9ef(%rip), %rcx      # 0xe990
leaq (%rcx,%rax), %rsi
addq $0x57c, %rsi            # imm = 0x57C
movl $0x1, %edi
movq %rbx, %rdx
callq 0x2b38
incq %r12
addq $0x34, %rbx
cmpq $0x1b, %r12
jne 0x2f7d
movslq 0x8(%rsp), %rax
movl $0x1, 0x4(%r15,%rax,8)
movl (%rsp), %esi
leaq 0x4(%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 0x2508
callq 0x75db
cmpl $0x0, (%rbx)
je 0x358b
leaq 0x4(%r14), %rax
movq %rax, 0x50(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0x30(%rsp)
leaq 0xc(%r14), %rax
movq %rax, 0x48(%rsp)
movslq 0x10(%rsp), %rax
imulq $0x34, %rax, %rax
leaq 0xb95f(%rip), %rcx      # 0xe990
leaq (%rcx,%rax), %rdx
addq $0x590, %rdx            # imm = 0x590
movq %rdx, 0x40(%rsp)
leaq 0x58c(%rcx,%rax), %rdx
movq %rdx, 0x38(%rsp)
leaq 0x594(%rcx,%rax), %r15
leaq (%rcx,%rax), %r13
addq $0x598, %r13            # imm = 0x598
leaq 0x24(%rsp), %rbp
leaq 0x20(%rsp), %rbx
xorl %r12d, %r12d
leaq 0xc84b(%rip), %rax      # 0xf8c0
cmpl $0x0, 0x60(%rax)
je 0x30a6
movl $0x1, %edi
movl $0x18, %esi
callq 0x4f79
leaq 0x6286(%rip), %rdi      # 0x9317
xorl %eax, %eax
callq 0x2030
leaq 0xc821(%rip), %rax      # 0xf8c0
movl $0x0, 0x60(%rax)
movl $0x1, %eax
movl %eax, 0x20(%rsp)
movl %eax, 0x24(%rsp)
movl $0x1, %edi
movl $0x15, %esi
callq 0x4f79
leaq 0x626d(%rip), %rdi      # 0x9336
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
movl $0x16, %esi
callq 0x4f79
leaq 0x626f(%rip), %rdi      # 0x9355
xorl %eax, %eax
callq 0x2030
movl $0xf, %edi
movl $0x15, %esi
callq 0x4f79
movss 0x4(%rsp), %xmm0
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
movl $0x74, %edx
callq 0x2b73
movss 0x4(%rsp), %xmm0
movq %r14, %rdi
movq %rbp, %rsi
movl $0x73, %edx
callq 0x2b73
movss 0x4(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
movl $0x63, %edx
callq 0x2b73
movss 0x4(%rsp), %xmm0
movq 0x48(%rsp), %rdi
movq %rbp, %rsi
movl $0x62, %edx
callq 0x2b73
movl $0xf, %edi
movl $0x16, %esi
callq 0x4f79
movss 0xc(%rsp), %xmm0
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
movl $0x74, %edx
callq 0x2b73
movss 0xc(%rsp), %xmm0
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
movl $0x73, %edx
callq 0x2b73
movss 0xc(%rsp), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
movl $0x63, %edx
callq 0x2b73
movss 0xc(%rsp), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movl $0x62, %edx
callq 0x2b73
movl 0x24(%rsp), %ecx
testl %ecx, %ecx
setne %dl
andb %r12b, %dl
movl 0x20(%rsp), %eax
cmpb $0x1, %dl
jne 0x31e2
testl %eax, %eax
jne 0x30ed
testl %ecx, %ecx
je 0x3207
movl $0xf, %edi
movl $0x15, %esi
callq 0x4f79
leaq 0x6178(%rip), %rdi      # 0x9374
xorl %eax, %eax
callq 0x2030
movl 0x20(%rsp), %eax
testl %eax, %eax
je 0x3228
movl $0xf, %edi
movl $0x16, %esi
callq 0x4f79
leaq 0x6153(%rip), %rdi      # 0x9374
xorl %eax, %eax
callq 0x2030
movl 0x1c(%rsp), %edi
movl 0x10(%rsp), %esi
leaq 0x4(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x2508
cmpl $0x0, 0x14(%rsp)
je 0x358b
movl 0x8(%rsp), %edx
xorl %edi, %edi
movq %rsp, %rsi
callq 0x2ac4
cmpl $0x0, (%r15)
leaq 0xb728(%rip), %r12      # 0xe990
jg 0x3271
cmpl $0x0, (%r13)
jle 0x32f0
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movq (%r14), %rcx
movq %rcx, 0x10(%r12,%rax)
leaq 0x8(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x22a7
movss 0x4(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movsd 0x5fde(%rip), %xmm2     # 0x9288
ucomisd %xmm0, %xmm2
seta %cl
movl 0x2c(%rsp), %eax
cmpl $0x1e, %eax
setl %dl
testb %dl, %cl
jne 0x32db
movss 0x5fe1(%rip), %xmm2     # 0x92a8
ucomiss %xmm1, %xmm2
jbe 0x3557
cmpl $0x1, 0x28(%rsp)
jne 0x3557
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x18(%r12,%rax)
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movdqu 0x10(%r12,%rax), %xmm0
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddd %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
paddd %xmm1, %xmm0
movd %xmm0, %ecx
testl %ecx, %ecx
movq %r12, %rcx
leaq 0x605a(%rip), %r12      # 0x937b
jle 0x33ac
movl 0x8(%rsp), %edi
leaq 0x60(%rsp), %rsi
leaq 0x5c(%rsp), %rdx
callq 0x7275
movl $0x15, %edi
callq 0x4fd5
movslq %eax, %rcx
movss 0x60(%rsp,%rcx,4), %xmm0
pxor %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jae 0x333a
movslq (%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0xb62b(%rip), %rsi      # 0xe990
movl %eax, 0x20(%rsi,%rcx)
cvtss2sd %xmm0, %xmm0
addsd 0x5f2b(%rip), %xmm0     # 0x92a0
leaq 0xc32c(%rip), %rax      # 0xf6a8
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x24(%rsi,%rcx)
movslq 0x8(%rsp), %rax
leaq (%rax,%rax,2), %rax
leaq 0xc0ef(%rip), %rdx      # 0xf490
movq (%rdx,%rax,8), %rax
movq %rax, 0x8(%rsi,%rcx)
jmp 0x33b6
addq %rcx, %rax
movl $0x0, 0x20(%rax)
movl $0x1, %edi
movl $0x12, %esi
callq 0x4f79
movq %r12, %rdi
xorl %eax, %eax
callq 0x2030
movl $0x3, %edi
movl $0x12, %esi
callq 0x4f79
leaq 0x1b(%rsp), %rdi
callq 0x7153
movzbl 0x1b(%rsp), %eax
leal -0x3f(%rax), %ecx
cmpl $0x18, %ecx
ja 0x3473
leaq 0x5eb0(%rip), %rdx      # 0x92ac
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
callq 0x4048
jmp 0x3486
callq 0x7ba5
jmp 0x3486
movl 0x1c(%rsp), %edi
movl 0x10(%rsp), %esi
jmp 0x3448
movl $0x2, %edi
callq 0x747e
jmp 0x3486
movl 0x8(%rsp), %edi
movl 0x10(%rsp), %r12d
movl %r12d, %esi
callq 0x3602
movl 0x1c(%rsp), %edi
movl %r12d, %esi
leaq 0x5f33(%rip), %r12      # 0x937b
leaq 0x4(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x2508
jmp 0x3486
callq 0x6228
jmp 0x3486
callq 0x4241
jmp 0x3486
callq 0x4329
jmp 0x3486
cmpl $0x20, %eax
je 0x3491
leaq 0x6703(%rip), %rdi      # 0x9b82
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x14(%rsp)
jne 0x33b6
movl (%rsp), %esi
xorl %edi, %edi
callq 0x36f5
movl $0x1, %edi
movl 0x10(%rsp), %esi
callq 0x36f5
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
leaq 0xb4d8(%rip), %r12      # 0xe990
cmpl $0x0, 0x20(%r12,%rax)
je 0x3547
movl $0x1, %edi
movl $0x17, %esi
callq 0x4f79
leaq 0x5ec0(%rip), %rdi      # 0x939a
xorl %eax, %eax
callq 0x2030
movl $0xe, %edi
movl $0x17, %esi
callq 0x4f79
movslq (%rsp), %rax
imulq $0x34, %rax, %rdi
addq %r12, %rdi
callq 0x27b4
movslq (%rsp), %rax
imulq $0x34, %rax, %rax
movdqu (%r14), %xmm0
movdqu 0x10(%r12,%rax), %xmm1
psubd %xmm1, %xmm0
movdqu %xmm0, (%r14)
xorl %edi, %edi
movl 0x1c(%rsp), %r12d
movl %r12d, %esi
callq 0x36f5
movl %r12d, %edi
movl 0x10(%rsp), %esi
leaq 0x4(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x2508
movb $0x1, %r12b
cmpl $0x0, 0x14(%rsp)
jne 0x306e
jmp 0x358b
movsd 0x5d31(%rip), %xmm1     # 0x9290
ucomisd %xmm0, %xmm1
seta %cl
cmpl $0x3c, %eax
setl %al
movsd 0x5d24(%rip), %xmm1     # 0x9298
ucomisd %xmm0, %xmm1
ja 0x32db
andb %al, %cl
je 0x32f0
jmp 0x32db
xorl %edi, %edi
movl 0x1c(%rsp), %esi
callq 0x36f5
movl $0x1, %edi
movl 0x10(%rsp), %esi
callq 0x36f5
movl 0x8(%rsp), %edi
callq 0x43f0
movslq 0x8(%rsp), %rax
leaq (%rax,%rax,2), %rax
leaq 0xbed3(%rip), %rcx      # 0xf490
movl (%rcx,%rax,8), %edi
movl 0x4(%rcx,%rax,8), %esi
callq 0x752b
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5d4, %eax            # imm = 0x5D4
addq 0x99c9(%rip), %rax      # 0xcfb0
movl $0x1, %esi
cmpl %ebx, -0x4(%rax)
jne 0x35fa
cmpl $0x0, (%rax)
je 0x2fd7
incl %esi
addq $0x34, %rax
jmp 0x35ec