// File: boczeratul[P]StarCraftGA/SCTools.cpp
// Function: oneSecInSC
void oneSecInSC()
{
    ++SCGameTime;
    
    int tmp;
    printf("\n================= Time %d ================\n",SCGameTime);

    printf("%d ongoing actions:\n",numOfActions);
    int i;
    for (i = numOfActions - 1; i >= 0; i--)
    {
        Actions[i][1]--;
        if (Actions[i][1] == 0)
        {
            numOfActions--;
            printf("%s: Done!\n", SCActionString[Actions[i][0]]);
            finishAction(Actions[i][0]);
        }
        else
        {
            printf("%s: %d seconds remained\n", SCActionString[Actions[i][0]], Actions[i][1]);
        }
    }

    getResources();
    showInformation();

    if (SCWaitTime == 0)
    {
        printf("New action: ");
        scanf(" %d",&tmp);
        while (tmp >= 0)
        {
            printf("    ==> %s\n", SCActionString[tmp]);
            if (isValidAction(tmp))
            {
                //printf("Valid action!\n");
                performAction(tmp);

                int insert = numOfActions;
                for (i = 0; i < numOfActions; i++)
                    if (SCActionTime[tmp] > Actions[i][1])
                    {
                        insert = i;
                        break;
                    }

                for (i = numOfActions; i > insert; i--)
                {
                    Actions[i][0] = Actions[i-1][0];
                    Actions[i][1] = Actions[i-1][1];
                }

                Actions[insert][0] = tmp;
                Actions[insert][1] = SCActionTime[tmp];

                numOfActions++;
            }
            else
                printf("Invalid action!\n");
            
            printf("New action: ");
            scanf(" %d",&tmp);
        }
            SCWaitTime = -1 * tmp;
    }
    SCWaitTime--;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl 0x7756(%rip), %eax      # 0xf7e4
addl $0x1, %eax
movl %eax, 0x774d(%rip)      # 0xf7e4
movl 0x7747(%rip), %esi      # 0xf7e4
leaq 0x375f(%rip), %rdi      # 0xb803
movb $0x0, %al
callq 0x1040
movl 0xf85f(%rip), %esi      # 0x17910
leaq 0x3778(%rip), %rdi      # 0xb830
movb $0x0, %al
callq 0x1040
movl 0xf84b(%rip), %eax      # 0x17910
subl $0x1, %eax
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x8197
movslq -0x8(%rbp), %rcx
leaq 0xf840(%rip), %rax      # 0x17920
movl 0x4(%rax,%rcx,8), %edx
addl $-0x1, %edx
leaq 0xf832(%rip), %rax      # 0x17920
movl %edx, 0x4(%rax,%rcx,8)
movslq -0x8(%rbp), %rcx
leaq 0xf823(%rip), %rax      # 0x17920
cmpl $0x0, 0x4(%rax,%rcx,8)
jne 0x8150
movl 0xf806(%rip), %eax      # 0x17910
addl $-0x1, %eax
movl %eax, 0xf7fd(%rip)      # 0x17910
movslq -0x8(%rbp), %rcx
leaq 0xf802(%rip), %rax      # 0x17920
movslq (%rax,%rcx,8), %rcx
leaq 0xf607(%rip), %rax      # 0x17730
movq (%rax,%rcx,8), %rsi
leaq 0x3711(%rip), %rdi      # 0xb845
movb $0x0, %al
callq 0x1040
movslq -0x8(%rbp), %rcx
leaq 0xf7da(%rip), %rax      # 0x17920
movl (%rax,%rcx,8), %edi
callq 0x8360
jmp 0x8187
movslq -0x8(%rbp), %rcx
leaq 0xf7c5(%rip), %rax      # 0x17920
movslq (%rax,%rcx,8), %rcx
leaq 0xf5ca(%rip), %rax      # 0x17730
movq (%rax,%rcx,8), %rsi
movslq -0x8(%rbp), %rcx
leaq 0xf7ab(%rip), %rax      # 0x17920
movl 0x4(%rax,%rcx,8), %edx
leaq 0x36d0(%rip), %rdi      # 0xb850
movb $0x0, %al
callq 0x1040
jmp 0x8189
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x80cb
callq 0x7de0
callq 0x7ff0
cmpl $0x0, 0x7640(%rip)      # 0xf7e8
jne 0x833c
leaq 0x36b4(%rip), %rdi      # 0xb869
movb $0x0, %al
callq 0x1040
leaq 0x36b3(%rip), %rdi      # 0xb876
leaq -0x4(%rbp), %rsi
movb $0x0, %al
callq 0x10b0
cmpl $0x0, -0x4(%rbp)
jl 0x832f
movslq -0x4(%rbp), %rcx
leaq 0xf54d(%rip), %rax      # 0x17730
movq (%rax,%rcx,8), %rsi
leaq 0x368c(%rip), %rdi      # 0xb87a
movb $0x0, %al
callq 0x1040
movl -0x4(%rbp), %edi
callq 0x83e0
cmpl $0x0, %eax
je 0x82fc
movl -0x4(%rbp), %edi
callq 0x88f0
movl 0xf6fc(%rip), %eax      # 0x17910
movl %eax, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0xf6e9(%rip), %eax      # 0x17910
jge 0x825d
movslq -0x4(%rbp), %rcx
leaq 0xf40c(%rip), %rax      # 0x17640
movl (%rax,%rcx,4), %eax
movslq -0x8(%rbp), %rdx
leaq 0xf6de(%rip), %rcx      # 0x17920
cmpl 0x4(%rcx,%rdx,8), %eax
jle 0x8250
movl -0x8(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x825d
jmp 0x8252
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x821e
movl 0xf6ad(%rip), %eax      # 0x17910
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x82bd
movl -0x8(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0xf6a2(%rip), %rax      # 0x17920
movl (%rax,%rcx,8), %edx
movslq -0x8(%rbp), %rcx
leaq 0xf694(%rip), %rax      # 0x17920
movl %edx, (%rax,%rcx,8)
movl -0x8(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0xf681(%rip), %rax      # 0x17920
movl 0x4(%rax,%rcx,8), %edx
movslq -0x8(%rbp), %rcx
leaq 0xf672(%rip), %rax      # 0x17920
movl %edx, 0x4(%rax,%rcx,8)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x8266
movl -0x4(%rbp), %edx
movslq -0xc(%rbp), %rcx
leaq 0xf655(%rip), %rax      # 0x17920
movl %edx, (%rax,%rcx,8)
movslq -0x4(%rbp), %rcx
leaq 0xf367(%rip), %rax      # 0x17640
movl (%rax,%rcx,4), %edx
movslq -0xc(%rbp), %rcx
leaq 0xf639(%rip), %rax      # 0x17920
movl %edx, 0x4(%rax,%rcx,8)
movl 0xf61f(%rip), %eax      # 0x17910
addl $0x1, %eax
movl %eax, 0xf616(%rip)      # 0x17910
jmp 0x830a
leaq 0x3583(%rip), %rdi      # 0xb886
movb $0x0, %al
callq 0x1040
leaq 0x3558(%rip), %rdi      # 0xb869
movb $0x0, %al
callq 0x1040
leaq 0x3557(%rip), %rdi      # 0xb876
leaq -0x4(%rbp), %rsi
movb $0x0, %al
callq 0x10b0
jmp 0x81ce
imull $0xffffffff, -0x4(%rbp), %eax # imm = 0xFFFFFFFF
movl %eax, 0x74ac(%rip)      # 0xf7e8
movl 0x74a6(%rip), %eax      # 0xf7e8
addl $-0x1, %eax
movl %eax, 0x749d(%rip)      # 0xf7e8
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)