// File: /workspace/github_cpp_makefile_star2_O1/gty980218[P]ee450/scheduler.cpp
// Function: main
int main(){
    //initailize UDP sock
    int sock_udp;
    if((sock_udp=socket(PF_INET,SOCK_DGRAM,0))<0){
        fprintf(stderr,"Create UDP socket failed!\n");
        exit(1);
    }
    struct sockaddr_in scheaddr;
    memset(&scheaddr, 0, sizeof(scheaddr));
	scheaddr.sin_family = AF_INET;                          //use IPv4
	scheaddr.sin_port = htons(33188);
	scheaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    if(bind(sock_udp, (struct sockaddr*)& scheaddr, sizeof(scheaddr)) < 0){
        fprintf(stderr,"Binding UDP failed,check the availability of port!\n");
        exit(1);
    }
    cout<<"The Scheduler is up and running."<<endl;
    //initialize sheduler
    init_sche(sock_udp);
    //initialize TCP sock
    int sock_tcp;
    if((sock_tcp=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP))<0){
        fprintf(stderr,"Create TCP socket failed!\n");
        exit(1);
    }
    struct sockaddr_in servaddr;
    memset(&servaddr, 0, sizeof(servaddr));
	servaddr.sin_family = AF_INET;
	servaddr.sin_port = htons(34188); 
	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    if(bind(sock_tcp, (struct sockaddr*)& servaddr, sizeof(servaddr)) < 0){
        fprintf(stderr,"Binding TCP failed,check the availability of port!\n");
        exit(1);
    }
    if(listen(sock_tcp,SOMAXCONN)<0){
        fprintf(stderr,"Listen failed!");
        exit(1);
    }
    //connect tcp
    tcp_conn(sock_tcp,sock_udp);

    close(sock_tcp);
    close(sock_udp); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x2070
testl %eax, %eax
jns 0x24bb
movq 0x3b2e(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b5c(%rip), %rdi      # 0x4010
movl $0x1a, %esi
jmp 0x24f5
movl %eax, %ebx
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rsi
movaps %xmm0, (%rsi)
movl $0xa4810002, %eax       # imm = 0xA4810002
movq %rax, (%rsi)
movl %ebx, %edi
movl $0x10, %edx
callq 0x2050
testl %eax, %eax
jns 0x2509
movq 0x3af2(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b3b(%rip), %rdi      # 0x402b
movl $0x33, %esi
movl $0x1, %edx
callq 0x22c0
movl $0x1, %edi
callq 0x21d0
movq 0x3ac0(%rip), %r14      # 0x5fd0
leaq 0x1b48(%rip), %rsi      # 0x405f
movl $0x20, %edx
movq %r14, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl %ebx, %edi
callq 0x25f2
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2070
testl %eax, %eax
jns 0x2580
movq 0x3a67(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b05(%rip), %rdi      # 0x4080
jmp 0x24b4
movl %eax, %r14d
xorps %xmm0, %xmm0
leaq -0x20(%rbp), %rsi
movaps %xmm0, (%rsi)
movl $0x8c850002, %eax       # imm = 0x8C850002
movq %rax, (%rsi)
movl %r14d, %edi
movl $0x10, %edx
callq 0x2050
testl %eax, %eax
jns 0x25bc
movq 0x3a2b(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1ae4(%rip), %rdi      # 0x409b
jmp 0x24f0
movl %r14d, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x21a0
testl %eax, %eax
jns 0x25e8
movq 0x3a04(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1af1(%rip), %rdi      # 0x40cf
movl $0xe, %esi
jmp 0x24f5
movl %r14d, %edi
movl %ebx, %esi
callq 0x294c