// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
callq 0x20d0
callq 0x2050
leaq 0x4ed7(%rip), %rdi      # 0x96b2
xorl %eax, %eax
callq 0x2030
leaq 0x4ee5(%rip), %rdi      # 0x96ce
xorl %eax, %eax
callq 0x2030
leaq 0x4eea(%rip), %rdi      # 0x96e1
xorl %eax, %eax
callq 0x2030
leaq 0xf(%rsp), %rdi
callq 0x6d93
leaq 0x4eea(%rip), %rdi      # 0x96f9
xorl %eax, %eax
callq 0x2030
xorl %edi, %edi
callq 0x2120
movq %rax, %rdi
callq 0x2110
leaq 0xc08c(%rip), %rax      # 0x108b8
andl $0x0, (%rax)
movl $0xd4, %eax
addq 0x975d(%rip), %rax      # 0xdf98
pushq $0x1
popq %rcx
movabsq $0x2e00000020, %rdx     # imm = 0x2E00000020
cmpq $0x10, %rcx
je 0x4876
xorl %esi, %esi
cmpq $0xb4, %rsi
je 0x486b
movq %rdx, -0x8(%rax,%rsi)
movl $0x20, (%rax,%rsi)
addq $0xc, %rsi
jmp 0x4850
incq %rcx
addq $0xc0, %rax
jmp 0x4848
leaq 0xa3a3(%rip), %r15      # 0xec20
addq $0x8, %r15
leaq 0xa448(%rip), %rax      # 0xecd0
addq $0x8, %rax
pushq $0x2
popq %rbp
pushq $0x1
popq %r14
pushq $0xf
popq %rbx
leaq 0xa4f3(%rip), %r12      # 0xed90
pushq $0x40
popq %r13
cmpq $0x16, %r14
je 0x4a37
movq %rax, 0x10(%rsp)
movq %r15, 0x20(%rsp)
leaq 0xbed4(%rip), %rax      # 0x10790
andl $0x0, (%rax,%r14,4)
leaq 0xbf28(%rip), %rax      # 0x107f0
andl $0x0, (%rax,%r14,4)
movq %r14, %r15
subq $0x1, %r15
jb 0x48e0
movl %r13d, %edi
callq 0x4e19
jmp 0x48d0
leaq 0xbf69(%rip), %rax      # 0x10850
andl $0x0, (%rax,%r14,4)
movl %ebx, %edi
callq 0x4e19
movl %eax, %r15d
movl %ebx, %edi
callq 0x4e19
movslq %r15d, %rcx
movslq %eax, %rdx
imulq $0xc0, %rcx, %rcx
addq %r12, %rcx
imulq $0xc, %rdx, %rdx
cmpl $0x2e, 0x4(%rdx,%rcx)
jne 0x48ec
addq %rdx, %rcx
imulq $0x18, %r14, %rdx
leaq 0xbb6a(%rip), %rsi      # 0x10490
leaq (%rsi,%rdx), %rdi
movq %rdi, 0x18(%rsp)
movl %r15d, (%rsi,%rdx)
movl %eax, 0x4(%rsi,%rdx)
imulq $0x58, %r14, %rdx
addq 0x96ae(%rip), %rdx      # 0xdff0
leaq (%rdx,%r14,4), %rdi
pushq $0x1
popq %r8
cmpq %rbp, %r8
je 0x49de
cmpq %r8, %r14
jne 0x495d
andl $0x0, (%rdi)
jmp 0x49d6
movq %rbp, %rsi
movl %ebx, %ebp
movl %r13d, %ebx
movq %r12, %r13
imulq $0x18, %r8, %r9
movl %r15d, %r11d
leaq 0xbb1a(%rip), %r12      # 0x10490
subl (%r12,%r9), %r11d
imull %r11d, %r11d
movl %eax, %r10d
subl 0x4(%r12,%r9), %r10d
imull %r10d, %r10d
addl %r11d, %r10d
leaq (%rdx,%r8,4), %r11
movl $0x17, (%r11)
pushq $0x1
popq %r12
cmpl $0x16, %r12d
je 0x49b3
movl %r12d, %r9d
imull %r12d, %r9d
cmpl %r9d, %r10d
jb 0x49b9
incl %r12d
jmp 0x499c
pushq $0x17
popq %r12
jmp 0x49bc
movl %r12d, (%r11)
imulq $0x58, %r8, %r9
addq 0x9629(%rip), %r9       # 0xdff0
movl %r12d, (%r9,%r14,4)
movq %r13, %r12
movl %ebx, %r13d
movl %ebp, %ebx
movq %rsi, %rbp
incq %r8
jmp 0x494a
xorl %eax, %eax
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %rdx
cmpq $0x2, %rax
je 0x49fe
andl $0x0, (%r15,%rax,4)
andl $0x0, (%rdx,%rax,4)
incq %rax
jmp 0x49ea
movl %r14d, %eax
orl $0x40, %eax
movl %eax, 0x4(%rcx)
movl $0x3f, (%rcx)
movq 0x18(%rsp), %rdi
andq $0x0, 0x10(%rdi)
movl %r14d, %esi
callq 0x4341
movq 0x10(%rsp), %rax
incq %r14
incq %rbp
addq $0x8, %r15
addq $0x8, %rax
jmp 0x48a1
movaps 0x4b22(%rip), %xmm0     # 0x9560
leaq 0xbccb(%rip), %rax      # 0x10710
movups %xmm0, 0x14(%rax)
movaps 0x4b20(%rip), %xmm0     # 0x9570
movups %xmm0, 0x24(%rax)
movabsq $0x25800000190, %rcx    # imm = 0x25800000190
movq %rcx, 0x34(%rax)
movl $0x384, 0x3c(%rax)      # imm = 0x384
movaps 0x4b10(%rip), %xmm0     # 0x9580
leaq 0xbcd9(%rip), %rax      # 0x10750
movups %xmm0, 0x8(%rax)
movaps 0x4b0e(%rip), %xmm0     # 0x9590
movups %xmm0, 0x18(%rax)
movabsq $0x1f400000190, %rcx    # imm = 0x1F400000190
movq %rcx, 0x28(%rax)
movl $0x258, 0x30(%rax)      # imm = 0x258
movaps 0x4afe(%rip), %xmm0     # 0x95a0
leaq 0xbc37(%rip), %rax      # 0x106e0
movups %xmm0, 0xc(%rax)
movaps 0x4afc(%rip), %xmm0     # 0x95b0
movups %xmm0, 0x1c(%rax)
leaq 0xaed1(%rip), %rax      # 0xf990
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x34(%rax)
xorl %ecx, %ecx
pushq $0x64
popq %rdx
leaq 0xbbcf(%rip), %r14      # 0x106a8
leaq 0xbbd0(%rip), %rsi      # 0x106b0
leaq 0xbbd1(%rip), %rbx      # 0x106b8
leaq 0xbbd2(%rip), %rdi      # 0x106c0
leaq 0xbbdb(%rip), %r8       # 0x106d0
leaq 0xbbcc(%rip), %r9       # 0x106c8
movl $0x57c, %r10d           # imm = 0x57C
xorps %xmm0, %xmm0
movq %rax, %r11
cmpq $0x2, %rcx
je 0x4b6e
movq %rdx, %r15
cmpq $0x5ac, %r15            # imm = 0x5AC
je 0x4b32
andq $0x0, -0x4(%r11,%r15)
movups %xmm0, -0x20(%r11,%r15)
andq $0x0, -0x10(%r11,%r15)
addq $0x34, %r15
jmp 0x4b11
imulq $0x57c, %rcx, %r15      # imm = 0x57C
andl $0x0, (%rdi,%rcx,4)
movl $0x23, 0x48(%rax,%r15)
andl $0x0, (%r8,%rcx,4)
movl $0x1, (%r14,%rcx,4)
andl $0x0, (%r9,%rcx,4)
movl $0x5, (%rsi,%rcx,4)
movl $0x3, (%rbx,%rcx,4)
incq %rcx
addq %r10, %r11
jmp 0x4b08
movl $0x7, (%rsi)
movsd 0x4a44(%rip), %xmm0     # 0x95c0
leaq 0xbb1d(%rip), %r15      # 0x106a0
movsd %xmm0, (%r15)
pushq $0x3
popq %rdi
callq 0x4e19
cmpl $0x3, %eax
je 0x4bbb
cmpl $0x2, %eax
je 0x4bae
cmpl $0x1, %eax
jne 0x4bd7
pushq $0x4
popq %rdi
callq 0x4e19
addl $0x2, %eax
movl %eax, (%rbx)
jmp 0x4bd7
pushq $0x3
popq %rdi
callq 0x4e19
movl %eax, (%r14)
jmp 0x4bd7
pushq $0x4
popq %rdi
callq 0x4e19
addl $0x3, %eax
cvtsi2ss %eax, %xmm0
divss 0x49fe(%rip), %xmm0     # 0x95d0
movss %xmm0, (%r15)
leaq 0xbcca(%rip), %rax      # 0x108a8
andl $0x0, (%rax)
leaq 0xbb9c(%rip), %rax      # 0x10784
pushq $0x1
popq %rcx
movl %ecx, (%rax)
leaq 0xbb94(%rip), %rax      # 0x10788
movl %ecx, (%rax)
callq 0x5edc
pushq $0x21
popq %rdi
pushq $0x14
popq %rsi
callq 0x4dbd
leaq 0x4aef(%rip), %rdi      # 0x96fc
xorl %eax, %eax
callq 0x2030
callq 0x447f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq