// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x186a0, -0x14(%rbp)   # imm = 0x186A0
movl $0x550, -0x18(%rbp)     # imm = 0x550
movl $0x9470, -0x1c(%rbp)    # imm = 0x9470
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x6aa4(%rip), %rdx      # 0x90d0
callq 0x23b0
movb %al, -0x41(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x27a3
movsbl -0x41(%rbp), %eax
addl $-0x45, %eax
movl %eax, %ecx
movq %rcx, -0x210(%rbp)
subl $0x32, %eax
ja 0x2788
movq -0x210(%rbp), %rax
leaq 0x699d(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x9961(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
cmpl $0x0, %eax
jle 0x269b
movq 0x994d(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
movl %eax, -0x214(%rbp)
jmp 0x26a4
movl -0x14(%rbp), %eax
movl %eax, -0x214(%rbp)
movl -0x214(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x279e
movq 0x991f(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
cmpl $0x200, %eax            # imm = 0x200
jle 0x26f5
movq 0x9909(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x26f5
movq 0x98f3(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
movl %eax, -0x218(%rbp)
jmp 0x26fe
movl -0x18(%rbp), %eax
movl %eax, -0x218(%rbp)
movl -0x218(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x279e
movq 0x98c5(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x2440
movq %rax, -0x30(%rbp)
jmp 0x279e
movq 0x98b0(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
cmpl $0x0, %eax
jle 0x274c
movq 0x989c(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x23e0
movl %eax, -0x21c(%rbp)
jmp 0x2755
movl -0x1c(%rbp), %eax
movl %eax, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x279e
movq 0x9871(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x2440
movq %rax, -0x28(%rbp)
jmp 0x279e
movb $0x0, %al
callq 0x29a0
movl $0x1, %edi
callq 0x23f0
jmp 0x2788
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2970
movl $0x1, %edi
callq 0x23f0
jmp 0x261e
cmpl $0x2, -0x8(%rbp)
jge 0x27bc
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2970
xorl %edi, %edi
callq 0x23f0
movq 0x980d(%rip), %rax      # 0xbfd0
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x97fc(%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 0x2804
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3a20
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x282e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2970
movl $0x1, %edi
callq 0x23f0
leaq -0x200(%rbp), %rdi
xorl %esi, %esi
movl $0x1b8, %edx            # imm = 0x1B8
callq 0x21a0
movl $0x1, -0x1a4(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x164(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3d40
movq %rax, -0x208(%rbp)
cmpq $0x0, -0x208(%rbp)
je 0x289f
movq -0x208(%rbp), %rax
movq %rax, -0x228(%rbp)
jmp 0x28b0
movq 0x9752(%rip), %rax      # 0xbff8
movq (%rax), %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
movq %rax, -0x118(%rbp)
movl $0x1, -0x5c(%rbp)
leaq 0x99ac(%rip), %rax      # 0xc278
movq %rax, -0x50(%rbp)
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq -0x200(%rbp), %rdi
callq 0x4920
xorl %edi, %edi
callq 0x23f0
nopl (%rax)