// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x2090
leaq -0xb0(%rbp), %rdi
addq $0x8, %rdi
callq 0x24f0
leaq 0x1d6(%rip), %rax       # 0x8f10
movq %rax, -0xb0(%rbp)
movl $0x2, %edi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2330
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x2d18(%rip), %rdi      # 0xba7c
leaq 0x2d24(%rip), %rdx      # 0xba8f
movb $0x0, %al
callq 0x2080
cmpl $0x4, -0x8(%rbp)
jne 0x8daa
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
callq 0x9510
movq %rax, 0x662c(%rip)      # 0xf3c8
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x8fb0
jmp 0x8dfc
cmpl $0x1, -0x8(%rbp)
jne 0x8dc8
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rdi
movq %rdx, %rsi
callq 0x9510
movq %rax, 0x6602(%rip)      # 0xf3c8
jmp 0x8dfa
movl $0x1, %edi
leaq 0x2865(%rip), %rsi      # 0xb639
leaq 0x280b(%rip), %rdx      # 0xb5e6
movl $0x26e, %ecx            # imm = 0x26E
leaq 0x2cb4(%rip), %r8       # 0xba9b
movb $0x0, %al
callq 0x4f90
movl $0x0, -0x4(%rbp)
jmp 0x8ef6
jmp 0x8dfc
cmpq $0x0, 0x65c4(%rip)      # 0xf3c8
je 0x8e30
movq 0x65bb(%rip), %rax      # 0xf3c8
cmpq $0x0, 0x18(%rax)
je 0x8e30
movq 0x65ad(%rip), %rax      # 0xf3c8
cmpq $0x0, 0x20(%rax)
je 0x8e30
movq 0x659f(%rip), %rax      # 0xf3c8
cmpq $0x0, 0x28(%rax)
jne 0x8e62
movl $0x3, %edi
leaq 0x27a4(%rip), %rsi      # 0xb5e0
leaq 0x27a3(%rip), %rdx      # 0xb5e6
movl $0x273, %ecx            # imm = 0x273
leaq 0x2c97(%rip), %r8       # 0xbae6
movb $0x0, %al
callq 0x4f90
movl $0x0, -0x4(%rbp)
jmp 0x8ef6
callq 0x9030
xorl %eax, %eax
movl %eax, %edi
callq 0x25b0
movl %eax, %edi
callq 0x2460
cmpl $0x0, 0x64ba(%rip)      # 0xf338
je 0x8ee1
movb $0x0, %al
callq 0xa310
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x8e9e
movl $0x1, %edi
callq 0x2300
jmp 0x8e77
callq 0x6fb0
movl -0x14(%rbp), %r9d
addl $0x1, %r9d
movl %r9d, -0x14(%rbp)
movl $0x1, %edi
leaq 0x277e(%rip), %rsi      # 0xb639
leaq 0x2724(%rip), %rdx      # 0xb5e6
movl $0x280, %ecx            # imm = 0x280
leaq 0x2c2f(%rip), %r8       # 0xbafd
movb $0x0, %al
callq 0x4f90
movl $0x1, %edi
callq 0x2300
jmp 0x8e77
movb $0x0, %al
callq 0x9f20
movb $0x0, %al
callq 0xa3a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)