// File: gty980218[P]ee450/scheduler.cpp
// Function: serve(int, int)
void serve(int conn,int sock_udp){
    char buf_tcp[64]={0};
    char buf_udp[64]={0};
    memset( buf_tcp,0,sizeof( buf_tcp));
    int ret=read(conn, buf_tcp,sizeof( buf_tcp));
    if(ret==-1){
        fprintf(stderr,"Runtime read error");
        exit(1);
    }
    cout<<"The Scheduler has received client at location "<<buf_tcp<<" from the client using TCP over port 34188"<<endl;
    for(int i=0;i<3;i++){
        if(scheduler.hspt_info[i].cpblt>scheduler.hspt_info[i].ocpt){    //cability>occupancy do while
            memset( buf_udp,0,sizeof( buf_udp));
            sendto(sock_udp,  buf_tcp, strlen( buf_tcp), 0, (struct sockaddr*)&scheduler.hspt_info[i].addr, sizeof(scheduler.hspt_info[i].addr));//send location to hospital
            recvfrom(sock_udp, buf_udp, sizeof(buf_udp), 0, NULL, NULL);//get score and dist from hospital
            char* pch;
            pch=strtok(buf_udp," ");
            double score=atof(pch);
            pch=strtok(NULL," ");
            double dist=atof(pch);
            scheduler.add_info(i,score,dist); 
            if(i==0){
                cout<<"The Scheduler has sent client location to Hospital A using UDP over port 33188."<<endl;
                if(dist!=-1){
                    cout<<"The Scheduler has received map information from Hospital A, the score = "<<score<<" and the distance = "<<dist<<endl;
                }else{
                    cout<<"The Scheduler has received map information from Hospital A, the score = none and the distance = none"<<endl;
                }
            }else if(i==1){
                cout<<"The Scheduler has sent client location to Hospital B using UDP over port 33188."<<endl;
                if(dist!=-1){
                    cout<<"The Scheduler has received map information from Hospital B, the score = "<<score<<" and the distance = "<<dist<<endl;
                }else{
                    cout<<"The Scheduler has received map information from Hospital B, the score = none and the distance = none"<<endl;
                }
            }else{
                cout<<"The Scheduler has sent client location to Hospital C using UDP over port 33188."<<endl;
                if(dist!=-1){
                    cout<<"The Scheduler has received map information from Hospital C, the score = "<<score<<" and the distance = "<<dist<<endl;
                }else{
                    cout<<"The Scheduler has received map information from Hospital C, the score = none and the distance = none"<<endl;
                }
            }

        }
        
    }
    int assigned=-1;//-1:not find;-2:is hospital;
    if(scheduler.hspt_info[0].dist!=-1 && scheduler.hspt_info[1].dist!=-1 && scheduler.hspt_info[2].dist!=-1 ){     //whether client is in map and is not hospital
        if(scheduler.hspt_info[0].score!=-1 || scheduler.hspt_info[1].score!=-1 || scheduler.hspt_info[2].score!=-1){
            double max_sc=0;//find the max score and min distance
            double min_dist;
            assigned=0;
            for(int i=0;i<3;i++){
                if(scheduler.hspt_info[i].score!=-1){
                    if(max_sc<scheduler.hspt_info[i].score){
                        max_sc=scheduler.hspt_info[i].score;
                        min_dist=scheduler.hspt_info[i].dist;
                        assigned=i;// decide which hospital will be assigned
                    }else if(max_sc==scheduler.hspt_info[i].score){
                        if(min_dist<scheduler.hspt_info[i].dist){
                            min_dist=scheduler.hspt_info[i].dist;
                            assigned=i;
                        }
                    }
                }
            }
        }
    }else if(scheduler.hspt_info[0].dist!=-1 || scheduler.hspt_info[1].dist!=-1 || scheduler.hspt_info[2].dist!=-1){//is hospital
        assigned=-2;
    }
    if(assigned>=0){
        scheduler.hspt_info[assigned].ocpt+=1;
        ofstream out_file("info.txt");              //write the changed occupancy to info.txt
        for(int i=0;i<3;i++){
            out_file<<scheduler.hspt_info[i].ocpt<<endl;
        }
        out_file.close();

        memset( buf_udp,0,sizeof( buf_udp));
        memset( buf_tcp,0,sizeof( buf_tcp));
        strcpy(buf_udp,"assigned");
        sendto(sock_udp,  buf_udp,sizeof(buf_udp), 0, (struct sockaddr*)&scheduler.hspt_info[assigned].addr, sizeof(scheduler.hspt_info[assigned].addr));
        string str_asn;
        if(assigned==0){
            str_asn="A";
            cout<<"The Scheduler has assigned Hospital A to the client"<<endl;
            cout<<"The Scheduler has sent the result to Hospital A using UDP over port 33188"<<endl;

        }else if(assigned==1){
            str_asn="B";
            cout<<"The Scheduler has assigned Hospital B to the client"<<endl;
            cout<<"The Scheduler has sent the result to Hospital B using UDP over port 33188"<<endl;

        }else{
            str_asn="C";
            cout<<"The Scheduler has assigned Hospital C to the client"<<endl;
            cout<<"The Scheduler has sent the result to Hospital C using UDP over port 33188"<<endl;

        }
        strcpy(buf_tcp,str_asn.c_str());
        write(conn,buf_tcp,sizeof(buf_tcp));
    }else if(assigned==-1){// not find
        string str_err="NF";
        if(scheduler.hspt_info[0].cpblt<=scheduler.hspt_info[0].ocpt && scheduler.hspt_info[1].cpblt<=scheduler.hspt_info[1].ocpt && scheduler.hspt_info[2].cpblt<=scheduler.hspt_info[2].ocpt){
            str_err="OL";  //overload
        }
        strcpy(buf_tcp,str_err.c_str());
        write(conn,buf_tcp,sizeof(buf_tcp));
    }else{
        string str_err="N";// client is in hospital illegal input
        strcpy(buf_tcp,str_err.c_str());
        write(conn,buf_tcp,sizeof(buf_tcp));
    }
    cout<<"The Scheduler has sent the result to client using TCP over port 34188 "<<endl;
    cout<<"------------------------------------------------------------------------------------------------"<<endl;
    
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movl -0x4(%rbp), %edi
leaq -0x50(%rbp), %rsi
movl $0x40, %edx
callq 0x22e0
movl %eax, -0x94(%rbp)
cmpl $-0x1, -0x94(%rbp)
jne 0x2e96
movq 0x315d(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
leaq 0x12b4(%rip), %rsi      # 0x4139
movb $0x0, %al
callq 0x22d0
movl $0x1, %edi
callq 0x2260
movq 0x3133(%rip), %rdi      # 0x5fd0
leaq 0x12a8(%rip), %rsi      # 0x414c
callq 0x21d0
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x21d0
movq %rax, %rdi
leaq 0x12bc(%rip), %rsi      # 0x417b
callq 0x21d0
movq %rax, %rdi
movq 0x30f2(%rip), %rsi      # 0x5fc0
callq 0x21e0
movl $0x0, -0x98(%rbp)
cmpl $0x3, -0x98(%rbp)
jge 0x326e
movslq -0x98(%rbp), %rcx
leaq 0x3320(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movslq -0x98(%rbp), %rdx
leaq 0x3308(%rip), %rcx      # 0x6218
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jle 0x3258
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movl -0x8(%rbp), %eax
movl %eax, -0x364(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x360(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2100
movl -0x364(%rbp), %edi
movq -0x360(%rbp), %rsi
movq %rax, %rdx
movslq -0x98(%rbp), %rax
leaq 0x32aa(%rip), %r8       # 0x6218
imulq $0x28, %rax, %rax
addq %rax, %r8
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x2040
movl -0x8(%rbp), %edi
leaq -0x90(%rbp), %rsi
movl $0x40, %edx
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x2180
leaq -0x90(%rbp), %rdi
leaq 0x16dd(%rip), %rsi      # 0x468b
callq 0x2330
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x2280
movsd %xmm0, -0xa8(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x16b2(%rip), %rsi      # 0x468b
callq 0x2330
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x2280
movsd %xmm0, -0xb0(%rbp)
movl -0x98(%rbp), %esi
movsd -0xa8(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm1
leaq 0x3202(%rip), %rdi      # 0x6218
callq 0x25a0
cmpl $0x0, -0x98(%rbp)
jne 0x30de
movq 0x2fa1(%rip), %rdi      # 0x5fd0
leaq 0x1170(%rip), %rsi      # 0x41a6
callq 0x21d0
movq %rax, %rdi
movq 0x2f7b(%rip), %rsi      # 0x5fc0
callq 0x21e0
movsd -0xb0(%rbp), %xmm0
movsd 0xfae(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x3064
jp 0x3064
jmp 0x30b7
movq 0x2f65(%rip), %rdi      # 0x5fd0
leaq 0x1184(%rip), %rsi      # 0x41f6
callq 0x21d0
movq %rax, %rdi
movsd -0xa8(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
leaq 0x11ae(%rip), %rsi      # 0x423f
callq 0x21d0
movq %rax, %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
movq 0x2f10(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x30d9
movq 0x2f12(%rip), %rdi      # 0x5fd0
leaq 0x118f(%rip), %rsi      # 0x4254
callq 0x21d0
movq %rax, %rdi
movq 0x2eec(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3256
cmpl $0x1, -0x98(%rbp)
jne 0x31a1
movq 0x2ede(%rip), %rdi      # 0x5fd0
leaq 0x11c0(%rip), %rsi      # 0x42b9
callq 0x21d0
movq %rax, %rdi
movq 0x2eb8(%rip), %rsi      # 0x5fc0
callq 0x21e0
movsd -0xb0(%rbp), %xmm0
movsd 0xeeb(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x3127
jp 0x3127
jmp 0x317a
movq 0x2ea2(%rip), %rdi      # 0x5fd0
leaq 0x11d4(%rip), %rsi      # 0x4309
callq 0x21d0
movq %rax, %rdi
movsd -0xa8(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
leaq 0x10eb(%rip), %rsi      # 0x423f
callq 0x21d0
movq %rax, %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
movq 0x2e4d(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x319c
movq 0x2e4f(%rip), %rdi      # 0x5fd0
leaq 0x11ca(%rip), %rsi      # 0x4352
callq 0x21d0
movq %rax, %rdi
movq 0x2e29(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3254
movq 0x2e28(%rip), %rdi      # 0x5fd0
leaq 0x1208(%rip), %rsi      # 0x43b7
callq 0x21d0
movq %rax, %rdi
movq 0x2e02(%rip), %rsi      # 0x5fc0
callq 0x21e0
movsd -0xb0(%rbp), %xmm0
movsd 0xe35(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x31dd
jp 0x31dd
jmp 0x3230
movq 0x2dec(%rip), %rdi      # 0x5fd0
leaq 0x121c(%rip), %rsi      # 0x4407
callq 0x21d0
movq %rax, %rdi
movsd -0xa8(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
leaq 0x1035(%rip), %rsi      # 0x423f
callq 0x21d0
movq %rax, %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x23b0
movq %rax, %rdi
movq 0x2d97(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3252
movq 0x2d99(%rip), %rdi      # 0x5fd0
leaq 0x1212(%rip), %rsi      # 0x4450
callq 0x21d0
movq %rax, %rdi
movq 0x2d73(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3254
jmp 0x3256
jmp 0x3258
jmp 0x325a
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x2edd
movl $0xffffffff, -0xb4(%rbp) # imm = 0xFFFFFFFF
movsd 0x2fb8(%rip), %xmm0     # 0x6238
movsd 0xd80(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x3295
jp 0x3295
jmp 0x3490
movsd 0x2fc3(%rip), %xmm0     # 0x6260
movsd 0xd63(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x32b2
jp 0x32b2
jmp 0x3490
movsd 0x2fce(%rip), %xmm0     # 0x6288
movsd 0xd46(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x32cf
jp 0x32cf
jmp 0x3490
movsd 0x2f59(%rip), %xmm0     # 0x6230
movsd 0xd29(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x331c
jp 0x331c
movsd 0x2f69(%rip), %xmm0     # 0x6258
movsd 0xd11(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x331c
jp 0x331c
movsd 0x2f79(%rip), %xmm0     # 0x6280
movsd 0xcf9(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x331c
jp 0x331c
jmp 0x348e
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
movl $0x0, -0xb4(%rbp)
movl $0x0, -0xcc(%rbp)
cmpl $0x3, -0xcc(%rbp)
jge 0x348c
movslq -0xcc(%rbp), %rcx
leaq 0x2ec2(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd 0xc9e(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x3377
jp 0x3377
jmp 0x3476
movsd -0xc0(%rbp), %xmm1
movslq -0xcc(%rbp), %rcx
leaq 0x2e8b(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x33f4
movslq -0xcc(%rbp), %rcx
leaq 0x2e6b(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movslq -0xcc(%rbp), %rcx
leaq 0x2e49(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x3474
movsd -0xc0(%rbp), %xmm0
movslq -0xcc(%rbp), %rcx
leaq 0x2e0e(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
ucomisd 0x18(%rax), %xmm0
jne 0x3472
jp 0x3472
movsd -0xc8(%rbp), %xmm1
movslq -0xcc(%rbp), %rcx
leaq 0x2de8(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3470
movslq -0xcc(%rbp), %rcx
leaq 0x2dc8(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x3472
jmp 0x3474
jmp 0x3476
jmp 0x3478
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x333b
jmp 0x348e
jmp 0x34e6
movsd 0x2da0(%rip), %xmm0     # 0x6238
movsd 0xb68(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x34da
jp 0x34da
movsd 0x2db0(%rip), %xmm0     # 0x6260
movsd 0xb50(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x34da
jp 0x34da
movsd 0x2dc0(%rip), %xmm0     # 0x6288
movsd 0xb38(%rip), %xmm1      # 0x4008
ucomisd %xmm1, %xmm0
jne 0x34da
jp 0x34da
jmp 0x34e4
movl $0xfffffffe, -0xb4(%rbp) # imm = 0xFFFFFFFE
jmp 0x34e6
cmpl $0x0, -0xb4(%rbp)
jl 0x3847
movslq -0xb4(%rbp), %rcx
leaq 0x2d17(%rip), %rax      # 0x6218
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
leaq -0x2d0(%rbp), %rdi
leaq 0xbe4(%rip), %rsi       # 0x4103
movl $0x10, %edx
callq 0x2210
movl $0x0, -0x2d4(%rbp)
cmpl $0x3, -0x2d4(%rbp)
jge 0x35a6
movslq -0x2d4(%rbp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0x2cca(%rip), %rax      # 0x6218
movl 0x14(%rax,%rcx,8), %esi
leaq -0x2d0(%rbp), %rdi
callq 0x2360
movq %rax, -0x370(%rbp)
jmp 0x3567
movq -0x370(%rbp), %rdi
movq 0x2a4b(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x357c
jmp 0x357e
movl -0x2d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d4(%rbp)
jmp 0x3533
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
jmp 0x3836
leaq -0x2d0(%rbp), %rdi
callq 0x22c0
jmp 0x35b4
xorps %xmm0, %xmm0
movaps %xmm0, -0x390(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x20(%rbp)
movaps %xmm0, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
leaq 0xecd(%rip), %rsi       # 0x44b5
leaq -0x90(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x21c0
movq -0x378(%rbp), %rsi
movl -0x8(%rbp), %edi
movslq -0xb4(%rbp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0x2c01(%rip), %rax      # 0x6218
leaq (%rax,%rcx,8), %r8
movl $0x40, %edx
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x2040
jmp 0x362f
leaq -0x308(%rbp), %rdi
callq 0x22b0
cmpl $0x0, -0xb4(%rbp)
jne 0x36e7
leaq 0xe6f(%rip), %rsi       # 0x44be
leaq -0x308(%rbp), %rdi
callq 0x22a0
jmp 0x365d
movq 0x296c(%rip), %rdi      # 0x5fd0
leaq 0xe55(%rip), %rsi       # 0x44c0
callq 0x21d0
movq %rax, -0x398(%rbp)
jmp 0x3679
movq -0x398(%rbp), %rdi
movq 0x2939(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x368e
movq 0x293b(%rip), %rdi      # 0x5fd0
leaq 0xe58(%rip), %rsi       # 0x44f4
callq 0x21d0
movq %rax, -0x3a0(%rbp)
jmp 0x36aa
movq -0x3a0(%rbp), %rdi
movq 0x2908(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x36bf
jmp 0x37e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x2120
jmp 0x3836
cmpl $0x1, -0xb4(%rbp)
jne 0x3769
leaq 0xe47(%rip), %rsi       # 0x453e
leaq -0x308(%rbp), %rdi
callq 0x22a0
jmp 0x3705
movq 0x28c4(%rip), %rdi      # 0x5fd0
leaq 0xe2d(%rip), %rsi       # 0x4540
callq 0x21d0
movq %rax, -0x3a8(%rbp)
jmp 0x3721
movq -0x3a8(%rbp), %rdi
movq 0x2891(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3736
movq 0x2893(%rip), %rdi      # 0x5fd0
leaq 0xe30(%rip), %rsi       # 0x4574
callq 0x21d0
movq %rax, -0x3b0(%rbp)
jmp 0x3752
movq -0x3b0(%rbp), %rdi
movq 0x2860(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x3767
jmp 0x37e2
leaq 0xe4e(%rip), %rsi       # 0x45be
leaq -0x308(%rbp), %rdi
callq 0x22a0
jmp 0x377e
movq 0x284b(%rip), %rdi      # 0x5fd0
leaq 0xe34(%rip), %rsi       # 0x45c0
callq 0x21d0
movq %rax, -0x3b8(%rbp)
jmp 0x379a
movq -0x3b8(%rbp), %rdi
movq 0x2818(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x37af
movq 0x281a(%rip), %rdi      # 0x5fd0
leaq 0xe37(%rip), %rsi       # 0x45f4
callq 0x21d0
movq %rax, -0x3c0(%rbp)
jmp 0x37cb
movq -0x3c0(%rbp), %rdi
movq 0x27e7(%rip), %rsi      # 0x5fc0
callq 0x21e0
jmp 0x37e0
jmp 0x37e2
jmp 0x37e4
leaq -0x308(%rbp), %rdi
callq 0x20f0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x21c0
movq -0x3c8(%rbp), %rsi
movl -0x4(%rbp), %edi
movl $0x40, %edx
callq 0x20d0
jmp 0x3819
leaq -0x308(%rbp), %rdi
callq 0x2120
leaq -0x2d0(%rbp), %rdi
callq 0x2300
jmp 0x3a1c
leaq -0x2d0(%rbp), %rdi
callq 0x2300
jmp 0x3a69
cmpl $-0x1, -0xb4(%rbp)
jne 0x395c
leaq -0x329(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x2380
movq -0x3d0(%rbp), %rdx
leaq 0xdc9(%rip), %rsi       # 0x463e
leaq -0x328(%rbp), %rdi
callq 0x3a80
jmp 0x3883
leaq -0x329(%rbp), %rdi
callq 0x2200
movl 0x2993(%rip), %eax      # 0x6228
cmpl 0x2991(%rip), %eax      # 0x622c
jg 0x3916
movl 0x29ad(%rip), %eax      # 0x6250
cmpl 0x29ab(%rip), %eax      # 0x6254
jg 0x3916
movl 0x29c7(%rip), %eax      # 0x6278
cmpl 0x29c5(%rip), %eax      # 0x627c
jg 0x3916
leaq 0xd81(%rip), %rsi       # 0x4641
leaq -0x328(%rbp), %rdi
callq 0x22a0
jmp 0x38ce
jmp 0x3916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
leaq -0x329(%rbp), %rdi
callq 0x2200
jmp 0x3a69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x2120
jmp 0x3a69
leaq -0x328(%rbp), %rdi
callq 0x20f0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x21c0
movq -0x3d8(%rbp), %rsi
movl -0x4(%rbp), %edi
movl $0x40, %edx
callq 0x20d0
jmp 0x394b
leaq -0x328(%rbp), %rdi
callq 0x2120
jmp 0x3a1a
leaq -0x351(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x2380
movq -0x3e0(%rbp), %rdx
leaq 0xcc7(%rip), %rsi       # 0x4644
leaq -0x350(%rbp), %rdi
callq 0x3a80
jmp 0x398b
leaq -0x351(%rbp), %rdi
callq 0x2200
leaq -0x350(%rbp), %rdi
callq 0x20f0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x21c0
movq -0x3e8(%rbp), %rsi
movl -0x4(%rbp), %edi
movl $0x40, %edx
callq 0x20d0
jmp 0x39cc
leaq -0x350(%rbp), %rdi
callq 0x2120
jmp 0x3a1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
leaq -0x351(%rbp), %rdi
callq 0x2200
jmp 0x3a69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2e0(%rbp)
movl %eax, -0x2e4(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x2120
jmp 0x3a69
jmp 0x3a1c
movq 0x25ad(%rip), %rdi      # 0x5fd0
leaq 0xc1c(%rip), %rsi       # 0x4646
callq 0x21d0
movq %rax, %rdi
movq 0x2587(%rip), %rsi      # 0x5fc0
callq 0x21e0
movq 0x258b(%rip), %rdi      # 0x5fd0
leaq 0xc41(%rip), %rsi       # 0x468d
callq 0x21d0
movq %rax, %rdi
movq 0x2565(%rip), %rsi      # 0x5fc0
callq 0x21e0
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
movq -0x2e0(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)
nop