// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/main.cpp
// Function: main
int main()
{

	ConfigParser *config = ConfigParser::getConfigParser();
	if ( config == NULL )
	{
		mylog( ERROR, "Config Error!");
		return -1;
	}

	URLManager *urlm = URLManager::getURLManager();
	if ( urlm == NULL )
	{
		mylog( ERROR, "URLManager Error!");
		return -1;
	}
	
	TaskControl tasks( config->getJobNum() , download );
	URL *tUrl = NULL;


	while( 1 )
	{
		urlm->loadURL();
		if (!tasks.getCurrentRun() && !urlm->getCurrentSize() )
		{
			puts("END");
			break;
		}
		
		if ( tasks.isAllTaskDone() )
		{
			for ( int i = 0 ; i < config->getJobNum() && (tUrl = urlm->popURL()) !=NULL; i++)
			{
				tasks.addTaskToQueue( tUrl);
			}
		}

		if ( config->getDuration() != 0 )
		{
			sleep(config->getDuration());
		}
		else
		{
			sleep(2);
		}

	}
	
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
callq 0xaed0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x878c
movl $0x2, %edi
leaq 0x99889(%rip), %rsi     # 0xa2004
callq 0xbdb0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x891d
callq 0xa670
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x87b9
movl $0x2, %edi
leaq 0x9986a(%rip), %rsi     # 0xa2012
callq 0xbdb0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x891d
movq -0x10(%rbp), %rdi
callq 0xae80
movl %eax, %esi
leaq -0x28(%rbp), %rdi
leaq 0x411(%rip), %rdx       # 0x8be0
callq 0x8670
movq $0x0, -0x30(%rbp)
jmp 0x87de
movq -0x18(%rbp), %rdi
callq 0xa700
jmp 0x87e9
leaq -0x28(%rbp), %rdi
callq 0x8730
movl %eax, -0x44(%rbp)
jmp 0x87f7
movl -0x44(%rbp), %eax
cmpl $0x0, %eax
jne 0x8842
movq -0x18(%rbp), %rdi
callq 0xa6e0
movl %eax, -0x48(%rbp)
jmp 0x880d
movl -0x48(%rbp), %eax
cmpl $0x0, %eax
jne 0x8842
leaq 0x99808(%rip), %rdi     # 0xa2024
callq 0x8470
jmp 0x8823
jmp 0x890d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x86b0
jmp 0x8926
leaq -0x28(%rbp), %rdi
callq 0x8710
movl %eax, -0x4c(%rbp)
jmp 0x8850
movl -0x4c(%rbp), %eax
cmpl $0x0, %eax
je 0x88ca
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
callq 0xae80
movl %eax, -0x50(%rbp)
jmp 0x8873
movl -0x54(%rbp), %ecx
movl -0x50(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x55(%rbp)
jge 0x88a3
movq -0x18(%rbp), %rdi
callq 0xa7b0
movq %rax, -0x60(%rbp)
jmp 0x8891
movq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x88ac
jmp 0x88c8
movq -0x30(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x86e0
jmp 0x88bb
jmp 0x88bd
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x885f
jmp 0x88ca
movq -0x10(%rbp), %rdi
callq 0xaec0
movl %eax, -0x64(%rbp)
jmp 0x88d8
movl -0x64(%rbp), %eax
cmpl $0x0, %eax
je 0x88fa
movq -0x10(%rbp), %rdi
callq 0xaec0
movl %eax, -0x68(%rbp)
jmp 0x88ee
movl -0x68(%rbp), %edi
callq 0x81d0
jmp 0x88f8
jmp 0x8908
movl $0x2, %edi
callq 0x81d0
jmp 0x8906
jmp 0x8908
jmp 0x87dc
movl $0x0, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x86b0
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x84e0
nop