// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conqin.c
// Function: initconst
void initconst(void)
{
    int i3, i1, i2, x, y, temp;
    tteam team;
    char tt;
    time_t date;

    cbreak();
    noecho();

    printw("\n* Welcome to CONQUEST! *\n\n");
    printw("Amiga version 1.0\n");
    printw("Hit return to continue\n");
    get_char(&tt);

    printw("\33<");

    date = time(NULL);
    srand48(date);

    saved_game = false;

    /*init the board */
    for (i1 = 1; i1 <= bdsize; i1++) {
        for (i2 = 1; i2 <= bdsize; i2++) {
            board[i1][i2].enemy = ' ';
            board[i1][i2].tf = ' ';
            board[i1][i2].star = '.';
        }
    };
    /*init stars */
    for (i1 = 1; i1 <= nstars; i1++) {
        enemy_arrivals[i1] = false;
        en_departures[i1] = false;
        for (i2 = 1; i2 <= i1; i2++)
            i3 = rnd(64);
        player_arrivals[i1] = false;
        do {
            x = rnd(bdsize);
            y = rnd(bdsize);
        }
        while (board[x][y].star != '.');
        stars[i1].x = x;
        stars[i1].y = y;
        for (i2 = 1; i2 <= i1; i2++) {
            if (i1 == i2)
                r2nge[i1][i2] = 0;
            else {
                temp = (((x - stars[i2].x) * (x - stars[i2].x)) +
                        ((y - stars[i2].y) * (y - stars[i2].y)));
                r2nge[i1][i2] = 23;
                for (i3 = 1; i3 < 22; i3++)
                    if (temp < i3 * i3) {
                        r2nge[i1][i2] = i3;
                        break;
                    }
                r2nge[i2][i1] = r2nge[i1][i2];
            }
        }
        for (team = ENEMY; team <= player; team++) {
            tf_stars[i1][team] = 0;
            col_stars[i1][team] = 0;
        };
        board[x][y].star = 'A' + i1 - 1;
        board[x][y].enemy = '?';
        stars[i1].visit[player] = false;
        stars[i1].visit[ENEMY] = false;
        assign_planets(&stars[i1], i1);
    };
    /*initialize research costs */
    ran_req[5] = 0;
    ran_req[6] = 20;
    ran_req[7] = 40;
    ran_req[8] = 70;
    ran_req[9] = 100;
    ran_req[10] = 150;
    ran_req[11] = 200;
    ran_req[12] = 300;
    ran_req[13] = 400;
    ran_req[14] = 600;
    ran_req[15] = 900;
    vel_req[2] = 40;
    vel_req[3] = 60;
    vel_req[4] = 80;
    vel_req[5] = 120;
    vel_req[6] = 150;
    vel_req[7] = 200;
    vel_req[8] = 250;
    vel_req[9] = 300;
    vel_req[10] = 400;
    vel_req[11] = 500;
    vel_req[12] = 600;
    weap_req[3] = 0;
    weap_req[4] = 50;
    weap_req[5] = 70;
    weap_req[6] = 90;
    weap_req[7] = 120;
    weap_req[8] = 150;
    weap_req[9] = 250;
    weap_req[10] = 350;
    /*initialize task forces */
    tf[ENEMY][1].x = 1;
    tf[ENEMY][1].y = 1;
    for (team = ENEMY; team <= player; team++) {
        for (i1 = 1; i1 <= 26; i1++) {
            tf[team][i1].dest = 0;
            tf[team][i1].blasting = false;
            tf[team][i1].withdrew = false;
            tf[team][i1].s = 0;
            tf[team][i1].t = 0;
            tf[team][i1].c = 0;
            tf[team][i1].b = 0;
            tf[team][i1].dest = 0;
            tf[team][i1].eta = 0;
        };
        tf[team][1].t = initunit;
        vel[team] = initvel;
        range[team] = initrange;
        weapons[team] = initweap;
        weap_working[team] = 0;
        vel_working[team] = 0;
        ran_working[team] = 0;
    };
    range[ENEMY] = initrange + 2;
    growth_rate[player] = 0.3;
    growth_rate[ENEMY] = 0.5;

    switch (rnd(3)) {
    case 1:
        weapons[ENEMY] = rnd(4) + 2;
        break;

    case 2:
        vel[ENEMY] = rnd(3);
        break;

    case 3:
        growth_rate[ENEMY] = (float) (rnd(4) + 3) / 10.0;
        break;
    };

    game_over = false;
    turn = 1;
    production_year = 1;
    printmap();
    point(33, 20);
    printw("*Initialization*");
    init_player();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0x20e0
callq 0x2060
leaq 0x4d29(%rip), %rdi      # 0x96f2
xorl %eax, %eax
callq 0x2030
leaq 0x4d37(%rip), %rdi      # 0x970e
xorl %eax, %eax
callq 0x2030
leaq 0x4d3c(%rip), %rdi      # 0x9721
xorl %eax, %eax
callq 0x2030
leaq 0xf(%rsp), %rdi
callq 0x7153
leaq 0x4d3c(%rip), %rdi      # 0x9739
xorl %eax, %eax
callq 0x2030
xorl %edi, %edi
callq 0x2130
movq %rax, %rdi
callq 0x2120
leaq 0xae9e(%rip), %rax      # 0xf8b8
movl $0x0, (%rax)
movl $0xd4, %eax
addq 0x8574(%rip), %rax      # 0xcfa0
movl $0x1, %ecx
movabsq $0x2e00000020, %rdx     # imm = 0x2E00000020
xorl %esi, %esi
movq %rdx, -0x8(%rax,%rsi)
movl $0x20, (%rax,%rsi)
addq $0xc, %rsi
cmpq $0xb4, %rsi
jne 0x4a3d
incq %rcx
addq $0xc0, %rax
cmpq $0x10, %rcx
jne 0x4a3b
movl $0x2, %r14d
movl $0x1, %ebx
xorl %ebp, %ebp
leaq 0x9317(%rip), %r13      # 0xdd90
leaq 0xaa10(%rip), %r12      # 0xf490
xorl %r15d, %r15d
leaq 0xad06(%rip), %rax      # 0xf790
movl %ebp, (%rax,%rbx,4)
leaq 0xad5c(%rip), %rax      # 0xf7f0
movl %ebp, (%rax,%rbx,4)
movq %rbx, %rbp
movl $0x40, %edi
callq 0x4fd5
decq %rbp
jne 0x4a9a
leaq 0xada0(%rip), %rax      # 0xf850
movl $0x0, (%rax,%rbx,4)
movl $0xf, %edi
callq 0x4fd5
movl %eax, %ebp
movl $0xf, %edi
callq 0x4fd5
movslq %ebp, %rdx
movslq %eax, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rdx,2), %rdx
shlq $0x6, %rdx
addq %r13, %rdx
cmpl $0x2e, 0x4(%rdx,%rcx,4)
jne 0x4ab7
leaq (%rdx,%rcx,4), %rcx
movq %rcx, 0x10(%rsp)
leaq (%rbx,%rbx,2), %rdx
leaq (%r12,%rdx,8), %rdi
movl %ebp, (%rdi)
movl %eax, 0x4(%rdi)
imulq $0x58, %rbx, %rdx
addq 0x84e6(%rip), %rdx      # 0xcff0
leaq (%rdx,%rbx,4), %rsi
movl $0x1, %r8d
cmpq %r8, %rbx
jne 0x4b21
movl $0x0, (%rsi)
jmp 0x4b7b
leaq (%r8,%r8,2), %r9
movl %ebp, %r11d
subl (%r12,%r9,8), %r11d
imull %r11d, %r11d
movl %eax, %r10d
subl 0x4(%r12,%r9,8), %r10d
imull %r10d, %r10d
addl %r11d, %r10d
leaq (%rdx,%r8,4), %r11
movl $0x17, (%r11)
movl $0x1, %ecx
movl %ecx, %r9d
imull %ecx, %r9d
cmpl %r9d, %r10d
jb 0x4b69
incl %ecx
cmpl $0x16, %ecx
jne 0x4b4f
movl $0x17, %ecx
jmp 0x4b6c
movl %ecx, (%r11)
imulq $0x58, %r8, %r9
addq 0x8479(%rip), %r9       # 0xcff0
movl %ecx, (%r9,%rbx,4)
incq %r8
cmpq %r14, %r8
jne 0x4b14
xorl %ebp, %ebp
leaq 0x9094(%rip), %rax      # 0xdc20
movq %rbp, 0x8(%rax,%r15,8)
leaq 0x9138(%rip), %rax      # 0xdcd0
movq %rbp, 0x8(%rax,%r15,8)
movl %ebx, %eax
orl $0x40, %eax
movq 0x10(%rsp), %rcx
movl %eax, 0x4(%rcx)
movl $0x3f, (%rcx)
movq %rbp, 0x10(%rdi)
movl %ebx, %esi
callq 0x44e5
incq %rbx
incq %r14
incq %r15
cmpq $0x15, %r15
jne 0x4a83
movaps 0x49cb(%rip), %xmm0     # 0x95a0
leaq 0xab34(%rip), %rax      # 0xf710
movups %xmm0, 0x14(%rax)
movaps 0x49c9(%rip), %xmm0     # 0x95b0
movups %xmm0, 0x24(%rax)
movabsq $0x25800000190, %rcx    # imm = 0x25800000190
movq %rcx, 0x34(%rax)
movl $0x384, 0x3c(%rax)      # imm = 0x384
movaps 0x49b9(%rip), %xmm0     # 0x95c0
leaq 0xab42(%rip), %rax      # 0xf750
movups %xmm0, 0x8(%rax)
movaps 0x49b7(%rip), %xmm0     # 0x95d0
movups %xmm0, 0x18(%rax)
movabsq $0x1f400000190, %rcx    # imm = 0x1F400000190
movq %rcx, 0x28(%rax)
movl $0x258, 0x30(%rax)      # imm = 0x258
movaps 0x49a7(%rip), %xmm0     # 0x95e0
leaq 0xaaa0(%rip), %rax      # 0xf6e0
movups %xmm0, 0xc(%rax)
movaps 0x49a5(%rip), %xmm0     # 0x95f0
movups %xmm0, 0x1c(%rax)
leaq 0x9d3a(%rip), %rax      # 0xe990
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x34(%rax)
movb $0x1, %dl
xorl %ecx, %ecx
xorps %xmm0, %xmm0
leaq 0xaa36(%rip), %r14      # 0xf6a8
leaq 0xaa37(%rip), %rsi      # 0xf6b0
leaq 0xaa38(%rip), %rbx      # 0xf6b8
leaq 0xaa39(%rip), %rdi      # 0xf6c0
leaq 0xaa42(%rip), %r8       # 0xf6d0
leaq 0xaa33(%rip), %r9       # 0xf6c8
xorl %r10d, %r10d
imulq $0x57c, %r10, %r11      # imm = 0x57C
leaq (%r11,%rax), %r15
movl $0x64, %r12d
movq %rcx, -0x4(%r15,%r12)
movups %xmm0, -0x20(%r15,%r12)
movq %rcx, -0x10(%r15,%r12)
addq $0x34, %r12
cmpq $0x5ac, %r12            # imm = 0x5AC
jne 0x4ca9
movl $0x23, 0x48(%rax,%r11)
movl $0x1, (%r14,%r10,4)
movl $0x5, (%rsi,%r10,4)
movl $0x3, (%rbx,%r10,4)
xorl %r11d, %r11d
movl %r11d, (%rdi,%r10,4)
movl %r11d, (%r8,%r10,4)
movl %r11d, (%r9,%r10,4)
movl $0x1, %r10d
testb $0x1, %dl
movl $0x0, %edx
jne 0x4c98
movl $0x7, (%rsi)
movsd 0x48ec(%rip), %xmm0     # 0x9600
leaq 0xa985(%rip), %r15      # 0xf6a0
movsd %xmm0, (%r15)
movl $0x3, %edi
callq 0x4fd5
cmpl $0x3, %eax
je 0x4d59
cmpl $0x2, %eax
je 0x4d4a
cmpl $0x1, %eax
jne 0x4d7a
movl $0x4, %edi
callq 0x4fd5
addl $0x2, %eax
movl %eax, (%rbx)
jmp 0x4d7a
movl $0x3, %edi
callq 0x4fd5
movl %eax, (%r14)
jmp 0x4d7a
movl $0x4, %edi
callq 0x4fd5
addl $0x3, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x489b(%rip), %xmm0     # 0x9610
movss %xmm0, (%r15)
leaq 0xab27(%rip), %rax      # 0xf8a8
movl $0x0, (%rax)
leaq 0xa9f6(%rip), %rax      # 0xf784
movl $0x1, %ecx
movl %ecx, (%rax)
leaq 0xa9ec(%rip), %rax      # 0xf788
movl %ecx, (%rax)
callq 0x6228
movl $0x21, %edi
movl $0x14, %esi
callq 0x4f79
leaq 0x4983(%rip), %rdi      # 0x973c
xorl %eax, %eax
callq 0x2030
callq 0x4617
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq