// File: /workspace/github_c_makefile_star2_O2/pencode-lab[P]Shoit/sendstream.c
// Function: main
int main(int argc,char **argv)
{
    int sendRate = SEND_RATE;
    int packetSize = MTU; 
    int port = 38000;

    char *logFile =NULL;
    char *localhost=NULL;
    char *password=NULL; 
    char *sendFile=NULL;


    static shoit_callbacks_t dataSource_callbacks={&open_data_source,&close_data_source,NULL};

    /* resolve command line options and arguments */
    char ch;
    while ((ch = getopt(argc, argv, "w:l:s:p:E:vTh")) != -1) {
        switch (ch) {
            case 'w': 
                sendRate = atoi(optarg)>0 ? atoi(optarg) : sendRate;
                break;
            case 'l':
                packetSize = (atoi(optarg)>512 && (atoi(optarg) < 65535)) ? atoi(optarg):packetSize;
                break;
            case 's':
                localhost = strdup(optarg);
                break;
            case 'p':
                port = atoi(optarg)>0 ? atoi(optarg):port;
                break;
            case 'E':/* event logging */
                logFile = strdup(optarg); 
                break;
            case 'v':
                shoit_show_copyright();
                exit(1);
            case 'h':
            default:
                helpe(argv[0]);
                exit(1); 
        }
    }//while 

    if(argc <2){                                                                                                                     
        helpe(argv[0]);                                                                                                              
        exit(0);                                                                                                                     
    }    

    argc -= optind;
    argv += optind;
    if (argc != 0){
        password = *argv++;
    }
    password = shoit_misc_nocr(password);
    if(!password ){ 
        helpe(argv[0]);
        exit(1);
    }

    //init sender
    shoit_core_t sender;
    bzero(&sender,sizeof(sender));

    sender.verbose= 1;
    sender.fileName = sendFile;

    sender.bindHost = localhost;
    sender.password = password; 

    /*bind local port,remote udpserver port will be control channel deliver from receiver*/
    sender.tcpPort = port;

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


    sender.iStream =true; 

    sender.callbacks = &dataSource_callbacks;

    /*run sender*/
    sender_run_loop(&sender,sendRate,packetSize);


    
    exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %r12
movl %edi, %r13d
movl $0x186a0, %ebx          # imm = 0x186A0
movl $0x9470, 0x8(%rsp)      # imm = 0x9470
movl $0x550, 0xc(%rsp)       # imm = 0x550
movq $0x0, 0x10(%rsp)
leaq 0x3a2c(%rip), %r14      # 0x6034
movq 0x69c9(%rip), %rbp      # 0x8fd8
leaq 0x39ee(%rip), %r15      # 0x6004
movq $0x0, 0x18(%rsp)
movl %r13d, %edi
movq %r12, %rsi
movq %r14, %rdx
callq 0x23b0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x26c1
sarl $0x18, %eax
leal -0x6c(%rax), %ecx
cmpl $0xb, %ecx
ja 0x265f
movslq (%r15,%rcx,4), %rax
addq %r15, %rax
jmpq *%rax
movq (%rbp), %rdi
callq 0x23e0
testl %eax, %eax
cmovgl %eax, %ebx
jmp 0x261f
cmpl $0x45, %eax
jne 0x26c7
movq (%rbp), %rdi
callq 0x2440
movq %rax, 0x10(%rsp)
jmp 0x261f
movq (%rbp), %rdi
callq 0x23e0
testl %eax, %eax
movl 0x8(%rsp), %ecx
cmovgl %eax, %ecx
movl %ecx, 0x8(%rsp)
jmp 0x261f
movq (%rbp), %rdi
callq 0x2440
movq %rax, 0x18(%rsp)
jmp 0x261f
movq (%rbp), %rdi
callq 0x23e0
leal -0x201(%rax), %ecx
cmpl $0xfdfe, %ecx           # imm = 0xFDFE
movl 0xc(%rsp), %ecx
cmovbl %eax, %ecx
movl %ecx, 0xc(%rsp)
jmp 0x261f
cmpl $0x1, %r13d
jg 0x26df
movq (%r12), %rdi
callq 0x27c3
xorl %eax, %eax
callq 0x27dc
pushq $0x1
popq %rdi
callq 0x23f0
movq 0x68ea(%rip), %rax      # 0x8fd0
movslq (%rax), %rax
leaq (%r12,%rax,8), %r14
cmpl %r13d, %eax
jne 0x26f6
xorl %edi, %edi
jmp 0x26fd
movq (%r14), %rdi
addq $0x8, %r14
callq 0x323c
testq %rax, %rax
jne 0x270f
movq (%r14), %rdi
callq 0x27c3
movq %rax, %r12
leaq 0x20(%rsp), %r14
movl $0x1b0, %edx            # imm = 0x1B0
movq %r14, %rdi
xorl %esi, %esi
callq 0x2190
pushq $0x1
popq %rbp
movl %ebp, 0x5c(%r14)
movq 0x18(%rsp), %rax
movq %rax, 0x70(%r14)
movq %r12, 0x60(%r14)
movl 0x8(%rsp), %eax
movl %eax, 0x9c(%r14)
movq 0x10(%rsp), %rdi
callq 0x3425
testq %rax, %rax
jne 0x275e
movq 0x689d(%rip), %rax      # 0x8ff8
movq (%rax), %rax
movq %rax, 0x108(%rsp)
movl %ebp, 0x1c4(%rsp)
leaq 0x6b04(%rip), %rax      # 0x9278
movq %rax, 0x1d0(%rsp)
movq %r14, %rdi
movl %ebx, %esi
movl 0xc(%rsp), %edx
callq 0x3a47
xorl %edi, %edi
callq 0x23f0