// File: /workspace/github_c_makefile_star2_O1/xiaowenhuyuehu[P]remote_access/src/core/remote_terminal.c
// Function: main
int main (int argc, char **argv)
{
    int times = 0;
 
    struct sigaction sig_int;
    memset(&sig_int, 0, sizeof(struct sigaction));
    sigemptyset(&sig_int.sa_mask);
    sig_int.sa_handler = _sig_int_handler;
    sigaction(SIGINT, &sig_int, NULL); 
    
    printf("%s compiled at %s\n", argv[0], __DATE__);
    if(argc == 4){
        g_cfg = init_cfg(argv[1], argv[2], argv[3]); 
        _clear_arguments(argc, argv); 
    } else if(argc == 1){
        g_cfg = init_cfg(NULL, NULL, NULL); 
    } else{
        log_info("./remote_terminal <product key>  <device name> <device secret> to startup ");
        return 0;
    }
  
    if(g_cfg == NULL || !g_cfg->pk || !g_cfg->dn || !g_cfg->ds){
        log_error("failed to init config\n"); 
        return 0;
    }

    _singleton();

    srand(time(NULL));
    while(g_is_running) {
        if( -1 == init_session_system()){
            sleep(1);
            continue;
        }
        sda_run_loop();
        log_info("reconnect: try %d times ", ++times);
        sleep(1);
    }

    deinit_cfg();
    deinit_session_system();
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x8(%rsp), %r14
movl $0x98, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2090
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x24f0
leaq 0x26f(%rip), %rax       # 0x6f68
movq %rax, -0x8(%r15)
movl $0x2, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2340
movq (%rbx), %rsi
leaq 0x2db6(%rip), %rdi      # 0x9acc
leaq 0x2dc2(%rip), %rdx      # 0x9adf
xorl %eax, %eax
callq 0x2080
cmpl $0x1, %ebp
je 0x6d82
cmpl $0x4, %ebp
jne 0x6ebb
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
callq 0x729c
movq %rax, 0x6646(%rip)      # 0xd390
movl $0x1, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x2270
testl %eax, %eax
jle 0x6d77
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
incq %rax
movq (%rbx,%r14,8), %rcx
movb $0x20, -0x2(%rcx,%rax)
decq %rax
cmpq $0x1, %rax
jg 0x6d65
incq %r14
cmpq $0x4, %r14
jne 0x6d50
jmp 0x6d94
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x729c
movq %rax, 0x65fc(%rip)      # 0xd390
movq 0x65f5(%rip), %rax      # 0xd390
testq %rax, %rax
je 0x6e9a
cmpq $0x0, 0x18(%rax)
je 0x6e9a
cmpq $0x0, 0x20(%rax)
je 0x6e9a
cmpq $0x0, 0x28(%rax)
je 0x6e9a
callq 0x21c0
leaq 0x2233(%rip), %rsi      # 0x9004
leaq 0x285e(%rip), %rdx      # 0x9636
leaq 0x2f4a(%rip), %r8       # 0x9d29
xorl %edi, %edi
movl $0x248, %ecx            # imm = 0x248
movl %eax, %r9d
xorl %eax, %eax
callq 0x4371
leaq 0xd4(%rsp), %rbx
movl $0x1cc, %edx            # imm = 0x1CC
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2090
movups 0x2f2d(%rip), %xmm0     # 0x9d3b
movaps %xmm0, -0x34(%rbx)
movups 0x2f32(%rip), %xmm0     # 0x9d4b
movaps %xmm0, -0x24(%rbx)
movups 0x2f37(%rip), %xmm0     # 0x9d5b
movaps %xmm0, -0x14(%rbx)
movl $0x6c6c75, -0x4(%rbx)   # imm = 0x6C6C75
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x2180
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2090
callq 0x21c0
leaq 0x2f15(%rip), %rdx      # 0x9d6f
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x20b0
movq %rbx, %rdi
callq 0x2180
xorl %edi, %edi
callq 0x25b0
movl %eax, %edi
callq 0x2470
cmpb $0x0, 0x6500(%rip)      # 0xd388
je 0x6ef1
xorl %eax, %eax
callq 0x7ca8
xorl %eax, %eax
callq 0x7da5
jmp 0x6ee1
leaq 0x278f(%rip), %rsi      # 0x9630
leaq 0x278e(%rip), %rdx      # 0x9636
leaq 0x2c87(%rip), %r8       # 0x9b36
movl $0x3, %edi
movl $0x273, %ecx            # imm = 0x273
jmp 0x6eda
leaq 0x27c7(%rip), %rsi      # 0x9689
leaq 0x276d(%rip), %rdx      # 0x9636
leaq 0x2c1b(%rip), %r8       # 0x9aeb
movl $0x1, %edi
movl $0x26e, %ecx            # imm = 0x26E
xorl %eax, %eax
callq 0x4371
xorl %eax, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2791(%rip), %rbx      # 0x9689
leaq 0x2737(%rip), %r14      # 0x9636
leaq 0x2c47(%rip), %r15      # 0x9b4d
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x7d38
cmpl $-0x1, %eax
jne 0x6f2c
movl $0x1, %edi
callq 0x2310
cmpb $0x0, 0x6463(%rip)      # 0xd388
je 0x6f08
jmp 0x6e8a
callq 0x57fb
incl %ebp
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x280, %ecx            # imm = 0x280
movq %r15, %r8
movl %ebp, %r9d
xorl %eax, %eax
callq 0x4371
movl $0x1, %edi
callq 0x2310
cmpb $0x1, 0x6427(%rip)      # 0xd388
jne 0x6f08
jmp 0x6e8a