// File: /workspace/github_c_makefile_star2_O0/pencode-lab[P]Shoit/recvstream.c
// Function: main
int main(int argc,char **argv)
{

    char *password=NULL;
    char *remoteHost=NULL;
    int port = 38000;

    struct sockaddr_storage sa;
    socklen_t salen;
    char *logFile=NULL;


    static shoit_callbacks_t recv_callbacks={NULL,NULL,&on_receiver};

    /* resolve command line options and arguments */
    char ch;
    while ((ch = getopt(argc, argv, "f:p:E:vdTh")) != -1) {
        switch (ch) {                                                                                                                   
            case 'p':                                                                                                                   
                port = atoi(optarg)>0 ? atoi(optarg):port;                                                                              
                break;                                                                                                                  
            case 'E':
                logFile=shoit_misc_nocr(strdup(optarg));
                break;
            case 'v':                                                                                                                   
                shoit_show_copyright();                                                                                               
                exit(1);                                                                                                                
            case 'h':                                                                                                                   
            default:                                                                                                                    
                helpe(argv[0]);                                                                                                         
                exit(1);                                                                                                                
        }                                                                                                                               
    }//while   
    if (argc < 3)
    {   
        helpe(argv[0]);
        exit (1);
    }
 
    signal(SIGBUS,catch_signal);

    argc -= optind;                                                                                                                     
    argv += optind;                                                                                                                     
    if (argc != 0){                                                                                                                     
        remoteHost  = *argv++;
        password    = *argv++;
    }

    if(!remoteHost || !password) {
        helpe(argv[0]);
        exit(1);
    }
    remoteHost = shoit_misc_nocr(remoteHost);
    password = shoit_misc_nocr(password);

    
    if (shoit_network_resolve_address((struct sockaddr *)&sa, &salen, remoteHost, port, AF_INET, SOCK_DGRAM, 0) != 0){
        fprintf(stderr,"remote host<%s> is unknown, can't resolve...\n",remoteHost);
        exit(1);
    }



     //init sender                                                                                                                    
    shoit_core_t receiver;
    bzero(&receiver,sizeof(receiver));
    receiver.verbose=1;
    receiver.password = password;

    memcpy(receiver.remoteHost,remoteHost,sizeof(receiver.remoteHost)-1);
    receiver.tcpPort = port;

    /*bind local udp server*/
    receiver.udpLocalPort = port; 
    receiver.udpRemotePort = port+1;
    receiver.bindHost =NULL;
    receiver.runing = false;

    FILE *log = shoit_misc_open_log(logFile);
    receiver.log = (log!=NULL) ? log:stderr;/*if open logfile error,set default is stderr*/

    receiver.iStream = true;
    int toFd =1;

    receiver.callbacks = &recv_callbacks;

    receiver_run_loop(&receiver,NULL,toFd);  


    exit(0);
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x9470, -0x24(%rbp)    # imm = 0x9470
movq $0x0, -0xb8(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x69eb(%rip), %rdx      # 0x9004
callq 0x23b0
movb %al, -0xb9(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x26fc
movsbl -0xb9(%rbp), %eax
movl %eax, -0x288(%rbp)
subl $0x45, %eax
je 0x26ae
jmp 0x2644
movl -0x288(%rbp), %eax
subl $0x68, %eax
je 0x26df
jmp 0x2655
movl -0x288(%rbp), %eax
subl $0x70, %eax
je 0x266f
jmp 0x2662
movl -0x288(%rbp), %eax
subl $0x76, %eax
je 0x26ce
jmp 0x26e1
movq 0x9962(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
cmpl $0x0, %eax
jle 0x269a
movq 0x994e(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
movl %eax, -0x28c(%rbp)
jmp 0x26a3
movl -0x24(%rbp), %eax
movl %eax, -0x28c(%rbp)
movl -0x28c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x26f7
movq 0x9923(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x2440
movq %rax, %rdi
callq 0x3a80
movq %rax, -0xb8(%rbp)
jmp 0x26f7
movb $0x0, %al
callq 0x2a00
movl $0x1, %edi
callq 0x23f0
jmp 0x26e1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2990
movl $0x1, %edi
callq 0x23f0
jmp 0x260b
cmpl $0x3, -0x8(%rbp)
jge 0x2718
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2990
movl $0x1, %edi
callq 0x23f0
movl $0x7, %edi
leaq 0x29c(%rip), %rsi       # 0x29c0
callq 0x2230
movq 0x98a0(%rip), %rax      # 0xbfd0
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x988f(%rip), %rax      # 0xbfd0
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x2787
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2795
cmpq $0x0, -0x18(%rbp)
jne 0x27ab
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2990
movl $0x1, %edi
callq 0x23f0
movq -0x20(%rbp), %rdi
callq 0x3a80
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3a80
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
leaq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rsi
movl $0x2, %r9d
xorl %eax, %eax
movl %r9d, %r8d
movl $0x0, (%rsp)
callq 0x2ee0
cmpl $0x0, %eax
je 0x281c
movq 0x97fb(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x6804(%rip), %rsi      # 0x900f
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23f0
leaq -0x278(%rbp), %rdi
xorl %esi, %esi
movl $0x1b8, %edx            # imm = 0x1B8
callq 0x21a0
movl $0x1, -0x21c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x200(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x1f8(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x1f0(%rbp)
movl 0x18(%rax), %ecx
movl %ecx, -0x1e8(%rbp)
movw 0x1c(%rax), %cx
movw %cx, -0x1e4(%rbp)
movb 0x1e(%rax), %al
movb %al, -0x1e2(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x1dc(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x1d8(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e0(%rbp)
movq $0x0, -0x208(%rbp)
movl $0x0, -0xd0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3da0
movq %rax, -0x280(%rbp)
cmpq $0x0, -0x280(%rbp)
je 0x28e5
movq -0x280(%rbp), %rax
movq %rax, -0x298(%rbp)
jmp 0x28f6
movq 0x970c(%rip), %rax      # 0xbff8
movq (%rax), %rax
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rax
movq %rax, -0x190(%rbp)
movl $0x1, -0xd4(%rbp)
movl $0x1, -0x284(%rbp)
leaq 0x9959(%rip), %rax      # 0xc278
movq %rax, -0xc8(%rbp)
movl -0x284(%rbp), %edx
leaq -0x278(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x65d0
xorl %edi, %edi
callq 0x23f0
nopw %cs:(%rax,%rax)