// File: /workspace/github_c_makefile_star2_O2/beejjorgensen[P]conquest/conqsubs.c
// Function: research
void research(int team, char field, int amt)
{
    switch (field) {
    case 'W':
        if (weapons[team] < 10) {
            weap_working[team] = weap_working[team] + amt;
            amt = 0;
            if (weap_working[team] >= weap_req[weapons[team] + 1]) {
                amt = weap_working[team]
                    - weap_req[weapons[team] + 1];
                weapons[team] = weapons[team] + 1;
                if (team == ENEMY) {
                    new_research();
                    field = en_research;
                };
                weap_working[team] = 0;
                research(team, field, amt);
            };
        };
        break;
    case 'R':
        if (range[team] < bdsize) {
            ran_working[team] = ran_working[team] + amt;
            amt = 0;
            if (ran_working[team] >= ran_req[range[team] + 1]) {
                amt = ran_working[team]
                    - ran_req[range[team] + 1];
                range[team] = range[team] + 1;
                if (team == ENEMY) {
                    new_research();
                    field = en_research;
                };
                ran_working[team] = 0;
                research(team, field, amt);
            };
        };
        break;
    case 'V':
        if (vel[team] < max_vel) {
            vel_working[team] = vel_working[team] + amt;
            amt = 0;
            if (vel_working[team] >= vel_req[vel[team] + 1]) {
                amt = vel_working[team] - vel_req[vel[team] + 1];
                vel[team] = vel[team] + 1;
                if (team == ENEMY) {
                    new_research();
                    field = en_research;
                };
                vel_working[team] = 0;
                research(team, field, amt);
            };
        };
        break;
    default:
        printw("error!!!! in research field %c\n", field);
    };                          /*switch ( */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movslq %edi, %r9
leaq (,%r9,4), %r14
leaq 0x8ee8(%rip), %r13      # 0x106d0
addq %r14, %r13
leaq 0x8ed6(%rip), %rdi      # 0x106c8
addq %r14, %rdi
addq 0x67c4(%rip), %r14      # 0xdfc0
leaq 0x8ead(%rip), %rbp      # 0x106b0
leaq 0x8e9e(%rip), %r15      # 0x106a8
leaq 0x8ea7(%rip), %r11      # 0x106b8
movq %r9, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
cmpb $0x52, %sil
je 0x7895
movzbl %sil, %eax
cmpl $0x56, %eax
je 0x7867
cmpl $0x57, %eax
jne 0x78fd
movslq (%r11,%r9,4), %rax
cmpq $0x9, %rax
jg 0x78ee
addl (%r14), %ebx
movl %ebx, (%r14)
leaq 0x8e92(%rip), %rsi      # 0x106e0
subl 0x4(%rsi,%rax,4), %ebx
jl 0x78ee
incq %rax
movl %eax, (%r11,%r9,4)
movb $0x57, %sil
movq %r14, %r12
jmp 0x78bf
movslq (%r15,%r9,4), %rax
cmpq $0xb, %rax
jg 0x78ee
addl (%r13), %ebx
movl %ebx, (%r13)
leaq 0x8ed0(%rip), %rsi      # 0x10750
subl 0x4(%rsi,%rax,4), %ebx
jl 0x78ee
incq %rax
movl %eax, (%r15,%r9,4)
movb $0x56, %sil
movq %r13, %r12
jmp 0x78bf
movslq (%rbp,%r9,4), %rax
cmpq $0xe, %rax
jg 0x78ee
addl (%rdi), %ebx
movl %ebx, (%rdi)
leaq 0x8e65(%rip), %rsi      # 0x10710
subl 0x4(%rsi,%rax,4), %ebx
jl 0x78ee
incq %rax
movl %eax, (%rbp,%r9,4)
movb $0x52, %sil
movq %rdi, %r12
testl %r9d, %r9d
jne 0x78e4
callq 0x2ad4
leaq 0x8de8(%rip), %r11      # 0x106b8
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %rdi
leaq 0x749f(%rip), %rax      # 0xed80
movb (%rax), %sil
andl $0x0, (%r12)
jmp 0x781b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %sil, %esi
leaq 0x25ed(%rip), %rdi      # 0x9ef5
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
nopl (%rax)