// File: /workspace/github_c_makefile_star2_O1/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 0x4cfe(%rip), %rdi      # 0x96a2
xorl %eax, %eax
callq 0x2030
leaq 0x4d0c(%rip), %rdi      # 0x96be
xorl %eax, %eax
callq 0x2030
leaq 0x4d11(%rip), %rdi      # 0x96d1
xorl %eax, %eax
callq 0x2030
leaq 0xf(%rsp), %rdi
callq 0x7187
leaq 0x4d11(%rip), %rdi      # 0x96e9
xorl %eax, %eax
callq 0x2030
xorl %edi, %edi
callq 0x2130
movq %rax, %rdi
callq 0x2120
leaq 0xaed3(%rip), %rax      # 0xf8c8
movl $0x0, (%rax)
movl $0xd4, %eax
addq 0x85a1(%rip), %rax      # 0xcfa8
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 0x4a18
incq %rcx
addq $0xc0, %rax
cmpq $0x10, %rcx
jne 0x4a16
movl $0x2, %r14d
movl $0x1, %ebx
xorl %ebp, %ebp
leaq 0x934c(%rip), %r13      # 0xdda0
leaq 0xaa45(%rip), %r12      # 0xf4a0
leaq 0x8a3e(%rip), %r15      # 0xd4a0
movq $0x0, 0x10(%rsp)
leaq 0xad2e(%rip), %rax      # 0xf7a0
movl %ebp, (%rax,%rbx,4)
leaq 0xad84(%rip), %rax      # 0xf800
movl %ebp, (%rax,%rbx,4)
movq %rbx, %rbp
movl $0x40, %edi
callq 0x4fc5
decq %rbp
jne 0x4a82
leaq 0xadc8(%rip), %rax      # 0xf860
movl $0x0, (%rax,%rbx,4)
movl $0xf, %edi
callq 0x4fc5
movl %eax, %ebp
movl $0xf, %edi
callq 0x4fc5
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 0x4a9f
leaq (%rdx,%rcx,4), %rcx
leaq (%rbx,%rbx,2), %rdx
leaq (%r12,%rdx,8), %rdi
movl %ebp, (%rdi)
movl %eax, 0x4(%rdi)
movl $0x1, %edx
imulq $0x58, %rbx, %rsi
cmpq %rdx, %rbx
jne 0x4afe
leaq (%rsi,%r15), %r8
movl $0x0, (%r8,%rdx,4)
jmp 0x4b59
leaq (%rdx,%rdx,2), %r9
movl %ebp, %r10d
subl (%r12,%r9,8), %r10d
imull %r10d, %r10d
movl %eax, %r8d
subl 0x4(%r12,%r9,8), %r8d
imull %r8d, %r8d
addl %r10d, %r8d
leaq (%rsi,%r15), %r9
leaq (%r9,%rdx,4), %r9
movl $0x17, (%r9)
movl $0x1, %r10d
movl %r10d, %r11d
imull %r10d, %r11d
cmpl %r11d, %r8d
jb 0x4b48
incl %r10d
cmpl $0x16, %r10d
jne 0x4b31
jmp 0x4b4b
movl %r10d, (%r9)
movl (%r9), %r8d
imulq $0x58, %rdx, %r9
addq %r15, %r9
movl %r8d, (%r9,%rbx,4)
incq %rdx
cmpq %r14, %rdx
jne 0x4aeb
xorl %ebp, %ebp
leaq 0x90c6(%rip), %rax      # 0xdc30
movq 0x10(%rsp), %r13
movq %rbp, 0x8(%rax,%r13,8)
leaq 0x9165(%rip), %rax      # 0xdce0
movq %rbp, 0x8(%rax,%r13,8)
movl %ebx, %eax
orl $0x40, %eax
movl %eax, 0x4(%rcx)
movl $0x3f, (%rcx)
movq %rbp, 0x10(%rdi)
movl %ebx, %esi
callq 0x44b9
incq %rbx
incq %r14
incq %r13
movq %r13, 0x10(%rsp)
cmpq $0x15, %r13
leaq 0x91ee(%rip), %r13      # 0xdda0
jne 0x4a6b
movaps 0x49a1(%rip), %xmm0     # 0x9560
leaq 0xab5a(%rip), %rax      # 0xf720
movups %xmm0, 0x14(%rax)
movaps 0x499f(%rip), %xmm0     # 0x9570
movups %xmm0, 0x24(%rax)
movabsq $0x25800000190, %rcx    # imm = 0x25800000190
movq %rcx, 0x34(%rax)
movl $0x384, 0x3c(%rax)      # imm = 0x384
movaps 0x498f(%rip), %xmm0     # 0x9580
leaq 0xab68(%rip), %rax      # 0xf760
movups %xmm0, 0x8(%rax)
movaps 0x498d(%rip), %xmm0     # 0x9590
movups %xmm0, 0x18(%rax)
movabsq $0x1f400000190, %rcx    # imm = 0x1F400000190
movq %rcx, 0x28(%rax)
movl $0x258, 0x30(%rax)      # imm = 0x258
movaps 0x497d(%rip), %xmm0     # 0x95a0
leaq 0xaac6(%rip), %rax      # 0xf6f0
movups %xmm0, 0xc(%rax)
movaps 0x497b(%rip), %xmm0     # 0x95b0
movups %xmm0, 0x1c(%rax)
leaq 0x9d60(%rip), %rax      # 0xe9a0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x34(%rax)
xorl %ecx, %ecx
xorps %xmm0, %xmm0
leaq 0xaa5e(%rip), %r14      # 0xf6b8
leaq 0xaa5f(%rip), %rdx      # 0xf6c0
leaq 0xaa60(%rip), %rbx      # 0xf6c8
leaq 0xaa61(%rip), %rsi      # 0xf6d0
leaq 0xaa6a(%rip), %rdi      # 0xf6e0
leaq 0xaa5b(%rip), %r8       # 0xf6d8
movl $0x57c, %r9d            # imm = 0x57C
movq %rax, %r10
xorl %r11d, %r11d
movl $0x64, %r15d
movq %rcx, -0x4(%r10,%r15)
movups %xmm0, -0x20(%r10,%r15)
movq %rcx, -0x10(%r10,%r15)
addq $0x34, %r15
cmpq $0x5ac, %r15            # imm = 0x5AC
jne 0x4c8f
imulq $0x57c, %r11, %r15      # imm = 0x57C
movl $0x23, 0x48(%rax,%r15)
movl $0x1, (%r14,%r11,4)
movl $0x5, (%rdx,%r11,4)
movl $0x3, (%rbx,%r11,4)
movl %ecx, (%rsi,%r11,4)
movl %ecx, (%rdi,%r11,4)
movl %ecx, (%r8,%r11,4)
leaq 0x1(%r11), %r15
addq %r9, %r10
testq %r11, %r11
movq %r15, %r11
je 0x4c89
movl $0x7, (%rdx)
leaq 0xa9b4(%rip), %r15      # 0xf6b0
movabsq $0x3e99999a3f000000, %rax # imm = 0x3E99999A3F000000
movq %rax, (%r15)
movl $0x3, %edi
callq 0x4fc5
cmpl $0x3, %eax
je 0x4d42
cmpl $0x2, %eax
je 0x4d33
cmpl $0x1, %eax
jne 0x4d63
movl $0x4, %edi
callq 0x4fc5
addl $0x2, %eax
movl %eax, (%rbx)
jmp 0x4d63
movl $0x3, %edi
callq 0x4fc5
movl %eax, (%r14)
jmp 0x4d63
movl $0x4, %edi
callq 0x4fc5
addl $0x3, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x4862(%rip), %xmm0     # 0x95c0
movss %xmm0, (%r15)
leaq 0xab4e(%rip), %rax      # 0xf8b8
movl $0x0, (%rax)
leaq 0xaa1d(%rip), %rax      # 0xf794
movl $0x1, %ecx
movl %ecx, (%rax)
leaq 0xaa13(%rip), %rax      # 0xf798
movl %ecx, (%rax)
callq 0x61f4
movl $0x21, %edi
movl $0x14, %esi
callq 0x4f69
leaq 0x494a(%rip), %rdi      # 0x96ec
xorl %eax, %eax
callq 0x2030
callq 0x45eb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq