// File: /workspace/github_c_makefile_star2_O2/beejjorgensen[P]conquest/conqve.c
// Function: inv_player
void inv_player(int x, int y, struct stplanet *planet)
{
    boolean printtf;
    char iline[81];
    char key;
    int cost, amount, ind, new_tf, balance;
    int trash1, trash2;

    get_tf(player, &new_tf, planet->pstar);
    tf_stars[planet->pstar][player]++;
    printtf = false;
    balance = planet->iu;
    cle3r_left();
    point(1, 19);
    addch(planet->pstar + 'A' - 1);

    printw("%d:%2d                         ", planet->number,
           planet->psee_capacity);
    point(x_cursor + 5, y_cursor);
    x_cursor = x_cursor - 5;
    printw("(%2d,/%3d)", planet->inhabitants, planet->iu);
    if (planet->conquered)
        printw("Con");
    else
        printw("   ");
    if (planet->mb != 0)
        printw("%2dmb", planet->mb);
    else
        printw("    ");
    if (planet->amb != 0)
        printw("%2damb", planet->amb);
    point(x_cursor, y_cursor + 1);

    do {
        point(1, 18);
        printw("%3d?                          ", balance);
        point(5, 18);
        get_line(iline, &ind, false);
        do {
            get_token(iline, &ind, &amount, &key);
            switch (key) {
            case 'A':
                cost = amount * amb_cost;
                if (planet->inhabitants == 0) {
                    cost = 0;
                    error_message();
                    printw("  !abandoned planet");
                } else if (planet->conquered) {
                    cost = 0;
                    error_message();
                    printw(" !No amb  on conquered colony ");
                } else if (cost <= balance) {
                    planet->amb = planet->amb + amount;
                };
                break;
            case 'B':
                cost = amount * b_cost;
                if (cost <= balance) {
                    tf[player][new_tf].b = tf[player][new_tf].b + amount;
                    printtf = true;
                };
                break;
            case 'C':
                cost = amount * c_cost;
                if (cost <= balance) {
                    tf[player][new_tf].c = tf[player][new_tf].c + amount;
                    printtf = true;
                };
                break;
            case 'H':
                help(4);
                cost = 0;
                break;
            case 'M':
                cost = amount * mb_cost;
                if (planet->inhabitants == 0) {
                    cost = 0;
                    error_message();
                    printw("  !abandoned planet");
                } else if (planet->conquered) {
                    cost = 0;
                    error_message();
                    printw(" !No Mb  on conquered colony  ");
                } else if (cost <= balance) {
                    planet->mb = planet->mb + amount;
                };
                break;
            case 'S':
                cost = amount * s_cost;
                if (cost <= balance) {
                    tf[player][new_tf].s = tf[player][new_tf].s + amount;
                    printtf = true;
                };
                break;
            case 'T':
                cost = amount;
                if (cost <= balance) {
                    if (cost > planet->inhabitants) {
                        error_message();
                        printw(" ! Not enough people for ( trans");
                        cost = 0;
                    } else if (planet->conquered) {
                        cost = 0;
                        error_message();
                        printw("!No transports on conqered col");
                    } else {
                        tf[player][new_tf].t =
                            tf[player][new_tf].t + amount;
                        planet->inhabitants = planet->inhabitants - amount;
                        trash1 = planet->iu - amount;
                        trash2 = planet->inhabitants * iu_ratio;
                        planet->iu = MIN(trash1, trash2);
                        printtf = true;
                        if (planet->inhabitants == 0) {
                            col_stars[planet->pstar][player]--;
                            if (col_stars[planet->pstar][player] == 0) {
                                board[x][y].enemy = ' ';
                                update_board(x, y, left);
                            };
                            planet->team = none;
                            planet->amb = 0;
                            planet->mb = 0;
                            planet->iu = 0;
                        };
                    };
                };
                break;
            case 'I':
                cost = i_cost * amount;
                if ((amount + planet->iu) >
                    (planet->inhabitants * iu_ratio)
                    ) {
                    cost = 0;
                    error_message();
                    printw(" !Can't support that many iu's");
                } else if (cost <= balance) {
                    planet->iu = planet->iu + amount;
                };
                break;
            case 'R':
            case 'V':
            case 'W':
                cost = amount;
                if (cost <= balance) {
                    point(1, 21);
                    research(player, key, amount);
                };
                pr2nt_res(key);
                break;
            case ' ':
                cost = 0;
                break;
            case '>':
                cost = 0;
                point(1, 18);
                printw(">?     ");
                point(3, 18);
                get_char(&key);
                switch (key) {
                case 'M':
                    printmap();
                    break;
                case 'S':
                    starsum();
                    break;
                case 'C':
                    print_col();
                    break;
                case 'R':
                    ressum();
                    break;
                default:
                    error_message();
                    printw(" !Only M,S,C,R allowed      ");
                };              /*switch ( > */
                break;
            default:
                error_message();
                printw(" !Illegal field %c", key);
            };                  /*switch ( */
            if (cost > balance) {
                error_message();
                printw(" !can't affort %3d%c", amount, key);
            } else
                balance = balance - cost;
        }
        while (key != ' ');
        cle3r_left();
        point(1, 19);
        addch(planet->pstar + 'A' - 1);

        printw("%d:%2d                         ", planet->number,
               planet->psee_capacity);
        point(x_cursor + 5, y_cursor);
        x_cursor = x_cursor - 5;
        printw("(%2d,/%3d)", planet->inhabitants, planet->iu);
        if (planet->conquered)
            printw("Con");
        else
            printw("   ");
        if (planet->mb != 0)
            printw("%2dmb", planet->mb);
        else
            printw("    ");
        if (planet->amb != 0)
            printw("%2damb", planet->amb);
        point(x_cursor, y_cursor + 1);

        if (printtf) {
            point(1, 20);
            pr3nt_tf(new_tf);
        };
    }
    while (balance > 0);
    zero_tf(player, new_tf);
    on_board(x, y);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r14
movl %esi, 0x20(%rsp)
movl %edi, 0x1c(%rsp)
movl 0x30(%rdx), %edx
pushq $0x1
popq %rbx
leaq 0x18(%rsp), %rsi
movl %ebx, %edi
callq 0x2990
movslq 0x30(%r14), %rax
leaq 0x6ae9(%rip), %rcx      # 0xec20
incl 0x4(%rcx,%rax,8)
movl 0x14(%r14), %r12d
callq 0x6f4d
pushq $0x13
popq %rsi
movl %ebx, %edi
callq 0x4dbd
movq 0x5e93(%rip), %rax      # 0xdfe8
movq (%rax), %rdi
movl 0x30(%r14), %esi
addl $0x40, %esi
callq 0x2090
movl (%r14), %esi
movl 0x8(%r14), %edx
leaq 0x1357(%rip), %rdi      # 0x94c9
xorl %eax, %eax
callq 0x2030
leaq 0x8730(%rip), %rbx      # 0x108b0
movl (%rbx), %edi
addl $0x5, %edi
leaq 0x8728(%rip), %rax      # 0x108b4
movl (%rax), %esi
callq 0x4dbd
addl $-0x5, (%rbx)
movl 0x10(%r14), %esi
movl 0x14(%r14), %edx
leaq 0x135a(%rip), %rdi      # 0x94ff
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x20(%r14)
leaq 0x142d(%rip), %rax      # 0x95e5
leaq 0x134b(%rip), %rdi      # 0x950a
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2030
movl 0x18(%r14), %esi
testl %esi, %esi
je 0x81e2
leaq 0x1335(%rip), %rdi      # 0x950e
xorl %eax, %eax
callq 0x2030
jmp 0x81f0
leaq 0x13fb(%rip), %rdi      # 0x95e4
xorl %eax, %eax
callq 0x2030
movl 0x1c(%r14), %esi
testl %esi, %esi
je 0x8206
leaq 0x1315(%rip), %rdi      # 0x9514
xorl %eax, %eax
callq 0x2030
leaq 0x86a3(%rip), %rax      # 0x108b0
movl (%rax), %edi
leaq 0x869e(%rip), %rax      # 0x108b4
movl (%rax), %esi
incl %esi
callq 0x4dbd
movslq 0x1c(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
imulq $0xc0, %rax, %rax
addq 0x5d5d(%rip), %rax      # 0xdf98
addq %rcx, %rax
movq %rax, 0x28(%rsp)
leaq 0xf(%rsp), %r15
leaq 0x1de1(%rip), %r13      # 0xa030
movl $0x0, 0x14(%rsp)
pushq $0x1
popq %rdi
pushq $0x12
popq %rbp
movl %ebp, %esi
callq 0x4dbd
leaq 0x13dc(%rip), %rdi      # 0x9647
movl %r12d, %esi
xorl %eax, %eax
callq 0x2030
pushq $0x5
popq %rdi
movl %ebp, %esi
callq 0x4dbd
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
leaq 0x24(%rsp), %rsi
xorl %edx, %edx
callq 0x6dae
movq %rbp, %rdi
leaq 0x24(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r15, %rcx
callq 0x6fc3
movb 0xf(%rsp), %al
movzbl %al, %ecx
leal -0x3e(%rcx), %edx
cmpl $0x19, %edx
ja 0x82fd
movslq (%r13,%rdx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movl 0x10(%rsp), %ebx
cmpl %r12d, %ebx
jg 0x82f0
pushq $0x1
popq %rbp
movl %ebp, %edi
pushq $0x15
popq %rsi
callq 0x4dbd
movsbl 0xf(%rsp), %esi
movl 0x10(%rsp), %edx
movl %ebp, %edi
leaq 0x30(%rsp), %rbp
callq 0x77c6
movb 0xf(%rsp), %al
movsbl %al, %edi
callq 0x7618
jmp 0x8552
cmpl $0x20, %ecx
je 0x8350
callq 0x6fb8
movsbl 0xf(%rsp), %esi
leaq 0x1379(%rip), %rdi      # 0x968c
xorl %eax, %eax
callq 0x2030
jmp 0x8552
cmpl $0x0, 0x10(%r14)
je 0x84be
cmpl $0x0, 0x20(%r14)
je 0x84f7
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1d88(%rip), %rdi      # 0xa0cb
jmp 0x854b
pushq $0x4
popq %rdi
callq 0x706a
xorl %ebx, %ebx
jmp 0x8552
movl 0x10(%rsp), %eax
movl %eax, %ebx
shll $0x4, %ebx
cmpl %r12d, %ebx
jg 0x8552
movslq 0x18(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x7617(%rip), %rdx      # 0xf990
addl %eax, 0x594(%rdx,%rcx)
jmp 0x848b
movl 0x10(%rsp), %ebx
cmpl %r12d, %ebx
jg 0x8552
movl 0x10(%r14), %eax
movl %eax, %ecx
subl %ebx, %ecx
jge 0x84dc
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1d3c(%rip), %rdi      # 0xa0ea
jmp 0x854b
movl 0x10(%rsp), %eax
imull $0x46, %eax, %ebx
cmpl %r12d, %ebx
jg 0x8552
movslq 0x18(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x75bd(%rip), %rdx      # 0xf990
addl %eax, 0x598(%rdx,%rcx)
jmp 0x848b
pushq $0x1
popq %rdi
pushq $0x12
popq %rbx
movl %ebx, %esi
callq 0x4dbd
leaq 0x1d56(%rip), %rdi      # 0xa149
xorl %eax, %eax
callq 0x2030
pushq $0x3
popq %rdi
movl %ebx, %esi
callq 0x4dbd
movq %r15, %rdi
callq 0x6d93
movzbl 0xf(%rsp), %eax
cmpl $0x43, %eax
je 0x8533
cmpl $0x53, %eax
je 0x851f
cmpl $0x52, %eax
je 0x8529
cmpl $0x4d, %eax
jne 0x853d
callq 0x5edc
jmp 0x8350
cmpl $0x0, 0x10(%r14)
je 0x84be
cmpl $0x0, 0x20(%r14)
je 0x850d
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1c4d(%rip), %rdi      # 0xa0ac
jmp 0x854b
movl 0x10(%rsp), %eax
imull $0x6, %eax, %ebx
cmpl %r12d, %ebx
jg 0x8552
movslq 0x18(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x750c(%rip), %rdx      # 0xf990
addl %eax, 0x58c(%rdx,%rcx)
pushq $0x1
popq %rax
movl %eax, 0x14(%rsp)
jmp 0x8552
movl 0x10(%rsp), %ecx
movl 0x14(%r14), %eax
addl %ecx, %eax
movl 0x10(%r14), %edx
addl %edx, %edx
cmpl %edx, %eax
jle 0x84ce
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1c71(%rip), %rdi      # 0xa12a
jmp 0x854b
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1bcc(%rip), %rdi      # 0xa098
jmp 0x854b
leal (%rcx,%rcx,2), %ebx
cmpl %r12d, %ebx
jg 0x8552
movl %eax, 0x14(%r14)
jmp 0x8552
cmpl $0x0, 0x20(%r14)
je 0x858a
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1c16(%rip), %rdi      # 0xa10b
jmp 0x854b
movl 0x10(%rsp), %eax
leal (,%rax,8), %ebx
cmpl %r12d, %ebx
jg 0x8552
addl %eax, 0x18(%r14)
jmp 0x8552
movl 0x10(%rsp), %eax
imull $0x23, %eax, %ebx
cmpl %r12d, %ebx
jg 0x8552
addl %eax, 0x1c(%r14)
jmp 0x8552
callq 0x40b4
jmp 0x8350
callq 0x7716
jmp 0x8350
callq 0x3eb4
jmp 0x8350
callq 0x6fb8
xorl %ebx, %ebx
leaq 0x1c06(%rip), %rdi      # 0xa151
xorl %eax, %eax
callq 0x2030
movl %r12d, %eax
subl %ebx, %eax
jge 0x8577
callq 0x6fb8
movl 0x10(%rsp), %esi
movsbl 0xf(%rsp), %edx
leaq 0x1c00(%rip), %rdi      # 0xa16e
xorl %eax, %eax
callq 0x2030
jmp 0x857a
movl %eax, %r12d
cmpb $0x20, 0xf(%rsp)
jne 0x8293
jmp 0x860a
movslq 0x18(%rsp), %rdx
imulq $0x34, %rdx, %rdx
leaq 0x73f6(%rip), %rsi      # 0xf990
addl %ebx, 0x590(%rsi,%rdx)
movl 0x14(%r14), %edx
subl %ebx, %edx
addl %ecx, %ecx
cmpl %ecx, %edx
cmovll %edx, %ecx
subl %ebx, %eax
movl %eax, 0x10(%r14)
movl %ecx, 0x14(%r14)
jne 0x848b
movslq 0x30(%r14), %rax
leaq 0x6707(%rip), %rcx      # 0xecd0
decl 0x4(%rcx,%rax,8)
movslq 0x30(%r14), %rax
cmpl $0x0, 0x4(%rcx,%rax,8)
jne 0x85f3
movq 0x28(%rsp), %rax
movl $0x20, (%rax)
movl 0x1c(%rsp), %edi
movl 0x20(%rsp), %esi
pushq $0x1
popq %rdx
callq 0x2ca4
movl $0x2, 0xc(%r14)
andl $0x0, 0x1c(%r14)
andq $0x0, 0x14(%r14)
jmp 0x848b
callq 0x6f4d
pushq $0x1
popq %rdi
pushq $0x13
popq %rsi
callq 0x4dbd
movq 0x59c7(%rip), %rax      # 0xdfe8
movq (%rax), %rdi
movl 0x30(%r14), %esi
addl $0x40, %esi
callq 0x2090
movl (%r14), %esi
movl 0x8(%r14), %edx
leaq 0xe8b(%rip), %rdi       # 0x94c9
xorl %eax, %eax
callq 0x2030
leaq 0x8264(%rip), %rbp      # 0x108b0
movl (%rbp), %edi
addl $0x5, %edi
leaq 0x825b(%rip), %rax      # 0x108b4
movl (%rax), %esi
callq 0x4dbd
addl $-0x5, (%rbp)
movl 0x10(%r14), %esi
movl 0x14(%r14), %edx
leaq 0xe8c(%rip), %rdi       # 0x94ff
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x20(%r14)
leaq 0xe84(%rip), %rdi       # 0x950a
leaq 0xf58(%rip), %rax       # 0x95e5
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2030
movl 0x18(%r14), %esi
testl %esi, %esi
je 0x86b0
leaq 0xe67(%rip), %rdi       # 0x950e
xorl %eax, %eax
callq 0x2030
jmp 0x86be
leaq 0xf2d(%rip), %rdi       # 0x95e4
xorl %eax, %eax
callq 0x2030
movl 0x1c(%r14), %esi
testl %esi, %esi
je 0x86d4
leaq 0xe47(%rip), %rdi       # 0x9514
xorl %eax, %eax
callq 0x2030
leaq 0x81d5(%rip), %rax      # 0x108b0
movl (%rax), %edi
leaq 0x81d0(%rip), %rax      # 0x108b4
movl (%rax), %esi
incl %esi
callq 0x4dbd
cmpl $0x0, 0x14(%rsp)
je 0x8708
pushq $0x1
popq %rdi
pushq $0x14
popq %rsi
callq 0x4dbd
movl 0x18(%rsp), %edi
callq 0x71d7
testl %r12d, %r12d
jg 0x8257
movl 0x18(%rsp), %esi
pushq $0x1
popq %rdi
callq 0x35b4
movl 0x1c(%rsp), %edi
movl 0x20(%rsp), %esi
callq 0x7107
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq