// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x14(%rsp), %rsi
movl $0x1, %edi
callq 0x2a18
movslq 0x30(%r14), %rax
leaq 0x5519(%rip), %rcx      # 0xdc30
incl 0x4(%rcx,%rax,8)
movl 0x14(%r14), %r15d
callq 0x7377
movl $0x1, %edi
movl $0x13, %esi
callq 0x4f69
movq 0x48ae(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movl 0x30(%r14), %esi
addl $0x40, %esi
callq 0x20a0
movl (%r14), %esi
movl 0x8(%r14), %edx
leaq 0xd72(%rip), %rdi       # 0x94c9
xorl %eax, %eax
callq 0x2030
leaq 0x715b(%rip), %rbx      # 0xf8c0
movl (%rbx), %edi
addl $0x5, %edi
leaq 0x7153(%rip), %rax      # 0xf8c4
movl (%rax), %esi
callq 0x4f69
addl $-0x5, (%rbx)
movl 0x10(%r14), %esi
movl 0x14(%r14), %edx
leaq 0xd75(%rip), %rdi       # 0x94ff
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x20(%r14)
leaq 0xe38(%rip), %rax       # 0x95d5
leaq 0xd66(%rip), %rdi       # 0x950a
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2030
movl 0x18(%r14), %esi
testl %esi, %esi
je 0x87c7
leaq 0xd50(%rip), %rdi       # 0x950e
xorl %eax, %eax
callq 0x2030
jmp 0x87d5
leaq 0xe06(%rip), %rdi       # 0x95d4
xorl %eax, %eax
callq 0x2030
movl 0x1c(%r14), %esi
testl %esi, %esi
je 0x87eb
leaq 0xd30(%rip), %rdi       # 0x9514
xorl %eax, %eax
callq 0x2030
leaq 0x70ce(%rip), %rax      # 0xf8c0
movl (%rax), %edi
leaq 0x70c9(%rip), %rax      # 0xf8c4
movl (%rax), %esi
incl %esi
callq 0x4f69
movslq 0x1c(%rsp), %rax
movslq 0x20(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x6, %rax
addq 0x4787(%rip), %rax      # 0xcfa8
leaq (%rax,%rcx,4), %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %rbx
leaq 0xf(%rsp), %r12
leaq 0x17e5(%rip), %rbp      # 0xa020
movl $0x0, 0x18(%rsp)
movl $0x1, %edi
movl $0x12, %esi
callq 0x4f69
leaq 0xdde(%rip), %rdi       # 0x9637
movl %r15d, %esi
xorl %eax, %eax
callq 0x2030
movl $0x5, %edi
movl $0x12, %esi
callq 0x4f69
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
xorl %edx, %edx
callq 0x71a2
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r12, %rcx
callq 0x73f2
movzbl 0xf(%rsp), %eax
leal -0x3e(%rax), %ecx
cmpl $0x19, %ecx
ja 0x88e8
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
movl 0x10(%rsp), %r13d
cmpl %r15d, %r13d
jg 0x88d9
movl $0x1, %edi
movl $0x15, %esi
callq 0x4f69
movsbl 0xf(%rsp), %esi
movl 0x10(%rsp), %edx
movl $0x1, %edi
callq 0x7cc9
movsbl 0xf(%rsp), %edi
callq 0x7b04
jmp 0x8b4c
cmpl $0x20, %eax
je 0x893e
callq 0x73e3
movsbl 0xf(%rsp), %esi
leaq 0xd7e(%rip), %rdi       # 0x967c
xorl %eax, %eax
callq 0x2030
jmp 0x8b4c
cmpl $0x0, 0x10(%r14)
je 0x8ab8
cmpl $0x0, 0x20(%r14)
je 0x8b0c
callq 0x73e3
xorl %r13d, %r13d
leaq 0x178c(%rip), %rdi      # 0xa0bb
jmp 0x8b45
movl $0x4, %edi
callq 0x74d3
xorl %r13d, %r13d
jmp 0x8b4c
movl 0x10(%rsp), %eax
movl %eax, %r13d
shll $0x4, %r13d
cmpl %r15d, %r13d
jg 0x8b4c
movslq 0x14(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x6036(%rip), %rdx      # 0xe9a0
addl %eax, 0x594(%rdx,%rcx)
jmp 0x8a83
movl 0x10(%rsp), %r13d
cmpl %r15d, %r13d
jg 0x8b4c
movl 0x10(%r14), %eax
movl %eax, %ecx
subl %r13d, %ecx
jge 0x8af0
callq 0x73e3
xorl %r13d, %r13d
leaq 0x1738(%rip), %rdi      # 0xa0da
jmp 0x8b45
movl 0x10(%rsp), %eax
imull $0x46, %eax, %r13d
cmpl %r15d, %r13d
jg 0x8b4c
movslq 0x14(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x5fd8(%rip), %rdx      # 0xe9a0
addl %eax, 0x598(%rdx,%rcx)
jmp 0x8a83
movl $0x1, %edi
movl $0x12, %esi
callq 0x4f69
leaq 0x174f(%rip), %rdi      # 0xa139
xorl %eax, %eax
callq 0x2030
movl $0x3, %edi
movl $0x12, %esi
callq 0x4f69
movq %r12, %rdi
callq 0x7187
movzbl 0xf(%rsp), %eax
cmpl $0x51, %eax
jg 0x8ac9
cmpl $0x43, %eax
je 0x8b85
cmpl $0x4d, %eax
jne 0x8b36
callq 0x61f4
jmp 0x893e
cmpl $0x0, 0x10(%r14)
je 0x8ab8
cmpl $0x0, 0x20(%r14)
je 0x8b23
callq 0x73e3
xorl %r13d, %r13d
leaq 0x1649(%rip), %rdi      # 0xa09c
jmp 0x8b45
movl 0x10(%rsp), %eax
leal (%rax,%rax), %ecx
leal (%rcx,%rcx,2), %r13d
cmpl %r15d, %r13d
jg 0x8b4c
movslq 0x14(%rsp), %rcx
imulq $0x34, %rcx, %rcx
leaq 0x5f24(%rip), %rdx      # 0xe9a0
addl %eax, 0x58c(%rdx,%rcx)
movl $0x1, 0x18(%rsp)
jmp 0x8b4c
movl 0x10(%rsp), %ecx
movl 0x14(%r14), %eax
addl %ecx, %eax
movl 0x10(%r14), %edx
addl %edx, %edx
cmpl %edx, %eax
jle 0x8ae1
callq 0x73e3
xorl %r13d, %r13d
leaq 0x1667(%rip), %rdi      # 0xa11a
jmp 0x8b45
callq 0x73e3
xorl %r13d, %r13d
leaq 0x15c1(%rip), %rdi      # 0xa088
jmp 0x8b45
cmpl $0x52, %eax
je 0x8b8f
cmpl $0x53, %eax
jne 0x8b36
callq 0x41f9
jmp 0x893e
leal (%rcx,%rcx,2), %r13d
cmpl %r15d, %r13d
jg 0x8b4c
movl %eax, 0x14(%r14)
jmp 0x8b4c
cmpl $0x0, 0x20(%r14)
je 0x8b99
callq 0x73e3
xorl %r13d, %r13d
leaq 0x15f1(%rip), %rdi      # 0xa0fb
jmp 0x8b45
movl 0x10(%rsp), %eax
leal (,%rax,8), %r13d
cmpl %r15d, %r13d
jg 0x8b4c
addl %eax, 0x18(%r14)
jmp 0x8b4c
movl 0x10(%rsp), %eax
imull $0x23, %eax, %r13d
cmpl %r15d, %r13d
jg 0x8b4c
addl %eax, 0x1c(%r14)
jmp 0x8b4c
callq 0x73e3
xorl %r13d, %r13d
leaq 0x15fc(%rip), %rdi      # 0xa141
xorl %eax, %eax
callq 0x2030
movl %r15d, %eax
subl %r13d, %eax
jge 0x8b72
callq 0x73e3
movl 0x10(%rsp), %esi
movsbl 0xf(%rsp), %edx
leaq 0x15f5(%rip), %rdi      # 0xa15e
xorl %eax, %eax
callq 0x2030
jmp 0x8b75
movl %eax, %r15d
cmpb $0x20, 0xf(%rsp)
jne 0x8881
jmp 0x8c2c
callq 0x4000
jmp 0x893e
callq 0x7c11
jmp 0x893e
movslq 0x14(%rsp), %rdx
imulq $0x34, %rdx, %rdx
leaq 0x5df7(%rip), %rsi      # 0xe9a0
addl %r13d, 0x590(%rsi,%rdx)
movl 0x14(%r14), %edx
subl %r13d, %edx
addl %ecx, %ecx
cmpl %ecx, %edx
cmovll %edx, %ecx
movl $0x1, 0x18(%rsp)
subl %r13d, %eax
movl %eax, 0x10(%r14)
movl %ecx, 0x14(%r14)
jne 0x8b4c
movslq 0x30(%r14), %rax
leaq 0x50fd(%rip), %rcx      # 0xdce0
decl 0x4(%rcx,%rax,8)
movslq 0x30(%r14), %rax
cmpl $0x0, 0x4(%rcx,%rax,8)
jne 0x8c0f
movq 0x28(%rsp), %rax
movl $0x20, (%rax)
movl 0x1c(%rsp), %edi
movl 0x20(%rsp), %esi
movl $0x1, %edx
callq 0x2d64
movl $0x2, 0xc(%r14)
movl $0x0, 0x1c(%r14)
movq $0x0, 0x14(%r14)
jmp 0x8b4c
callq 0x7377
movl $0x1, %edi
movl $0x13, %esi
callq 0x4f69
movq 0x43a1(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movl 0x30(%r14), %esi
addl $0x40, %esi
callq 0x20a0
movl (%r14), %esi
movl 0x8(%r14), %edx
leaq 0x865(%rip), %rdi       # 0x94c9
xorl %eax, %eax
callq 0x2030
leaq 0x6c4e(%rip), %rbx      # 0xf8c0
movl (%rbx), %edi
addl $0x5, %edi
leaq 0x6c46(%rip), %rax      # 0xf8c4
movl (%rax), %esi
callq 0x4f69
addl $-0x5, (%rbx)
movl 0x10(%r14), %esi
movl 0x14(%r14), %edx
leaq 0x868(%rip), %rdi       # 0x94ff
xorl %eax, %eax
callq 0x2030
cmpl $0x0, 0x20(%r14)
leaq 0x860(%rip), %rdi       # 0x950a
leaq 0x924(%rip), %rax       # 0x95d5
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x2030
movl 0x18(%r14), %esi
testl %esi, %esi
je 0x8cd4
leaq 0x843(%rip), %rdi       # 0x950e
xorl %eax, %eax
callq 0x2030
jmp 0x8ce2
leaq 0x8f9(%rip), %rdi       # 0x95d4
xorl %eax, %eax
callq 0x2030
movl 0x1c(%r14), %esi
testl %esi, %esi
leaq 0x30(%rsp), %rbx
je 0x8cfd
leaq 0x81e(%rip), %rdi       # 0x9514
xorl %eax, %eax
callq 0x2030
leaq 0x6bbc(%rip), %rax      # 0xf8c0
movl (%rax), %edi
leaq 0x6bb7(%rip), %rax      # 0xf8c4
movl (%rax), %esi
incl %esi
callq 0x4f69
cmpl $0x0, 0x18(%rsp)
je 0x8d35
movl $0x1, %edi
movl $0x14, %esi
callq 0x4f69
movl 0x14(%rsp), %edi
callq 0x7683
testl %r15d, %r15d
jg 0x8843
movl 0x14(%rsp), %esi
movl $0x1, %edi
callq 0x3695
movl 0x1c(%rsp), %edi
movl 0x20(%rsp), %esi
callq 0x7580
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq