// File: /workspace/github_c_makefile_star2_O3/xiaowenhuyuehu[P]remote_access/src/core/config_manager.c
// Function: init_cfg
CFG_STARTUP *init_cfg(char *pk, char *dn, char *ds)
{
	char *working_dir = NULL, *tmp = NULL;
	char *cfg_json = NULL;
	int len_val = 0;
	int type_val = 0;
    if(g_cfg != NULL){
        log_warning("configure is already exist."); 
        return g_cfg;
    }

    g_cfg = malloc(sizeof(CFG_STARTUP));
    if(g_cfg == NULL){
        log_error("failed to alloc memory for store configure info."); 
        return NULL;
    }

	working_dir = _get_current_work_dir();

	cfg_json = _load_cfg_from_json(working_dir, CFG_FILE_NAME);
	
	GET_STRING_VAL("cloud_ip", &g_cfg->cloud_ip);
	GET_STRING_VAL("cloud_port", &g_cfg->cloud_port);
	GET_STRING_VAL("cert_path", &g_cfg->cert_path);
	GET_STRING_VAL("listen_ip", &g_cfg->listen_ip);
	GET_INT_VAL("is_tls_on", &g_cfg->is_tls_on);
	GET_INT_VAL("listen_port", &g_cfg->listen_port);
	GET_INT_VAL("is_debug_on", &g_cfg->is_debug_on);

    if(pk == NULL)
        GET_STRING_VAL("product_key", &g_cfg->pk);
    else
        g_cfg->pk = strdup(pk);

    if(dn == NULL)
        GET_STRING_VAL("device_name", &g_cfg->dn);
    else
        g_cfg->dn = strdup(dn);

    if(ds == NULL)
        GET_STRING_VAL("device_secret", &g_cfg->ds);
    else
        g_cfg->ds = strdup(ds);
    free(working_dir);
	free(cfg_json);

	_dump_cfg();
	return g_cfg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
cmpq $0x0, 0x7484(%rip)      # 0xe7b0
je 0x736d
leaq 0x2bf4(%rip), %rsi      # 0x9f29
leaq 0x2bf3(%rip), %rdx      # 0x9f2f
leaq 0x2c06(%rip), %r8       # 0x9f49
movl $0x2, %edi
movl $0xa1, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x7455(%rip), %rbx      # 0xe7b0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl $0x40, %edi
callq 0x2150
movq %rax, 0x7429(%rip)      # 0xe7b0
testq %rax, %rax
je 0x777a
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x24a0
testq %rax, %rax
je 0x7ad0
movq %rax, %rbx
leaq 0x2cc3(%rip), %rdi      # 0xa075
movl $0xfff, %edx            # imm = 0xFFF
movq %rax, %rsi
callq 0x2370
testl %eax, %eax
jle 0x7af1
movq %r12, 0x20(%rsp)
movq %r14, 0x10(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%rbx,%rax)
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x22f0
testq %rax, %rax
je 0x73ef
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x2270
addl $0x16, %eax
movslq %eax, %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x24a0
testq %rax, %rax
je 0x7b12
movq %rax, %rbp
leaq 0x2ca4(%rip), %rdx      # 0xa0c1
leaq 0x2b72(%rip), %r8       # 0x9f96
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0x2487(%rip), %rsi      # 0x98c2
movq %rbp, %rdi
callq 0x2160
testq %rax, %rax
je 0x7b3d
movq %rax, %r14
movq %rbx, 0x18(%rsp)
movq %r15, %rbx
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20e0
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x20e0
movq %r14, %rdi
callq 0x20a0
testq %rax, %rax
jle 0x7b78
movq %rax, %r15
leaq 0x1(%rax), %r13
movl $0x1, %edi
movq %r13, %rsi
callq 0x24a0
testq %rax, %rax
je 0x7ba3
movq %rax, %r12
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20e0
movl $0x1, %esi
movq %r12, %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0x23e0
cmpq %r15, %rax
jae 0x74fc
callq 0x2400
movl (%rax), %edi
callq 0x2330
leaq 0x2146(%rip), %rsi      # 0x9620
leaq 0x2a4e(%rip), %rdx      # 0x9f2f
leaq 0x2c41(%rip), %r8       # 0xa129
movl $0x3, %edi
movl $0x4c, %ecx
movq %rax, %r9
xorl %eax, %eax
callq 0x42c5
movq %r14, %rdi
callq 0x24b0
movq %rbp, %rdi
callq 0x2250
movq %r12, %rdi
callq 0x2270
leaq 0x2a90(%rip), %rdx      # 0x9fab
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7bde
cmpl $0x0, 0x8(%rsp)
jne 0x7bde
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7bde
movq %rbx, %r13
movq %rax, %rdi
callq 0x25a0
movq 0x724f(%rip), %rcx      # 0xe7b0
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2a64(%rip), %rdx      # 0x9fd7
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
movq 0x20(%rsp), %rbx
je 0x7c09
cmpl $0x0, 0x8(%rsp)
jne 0x7c09
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7c09
movq %rax, %rdi
callq 0x25a0
movq 0x71f5(%rip), %rcx      # 0xe7b0
movq %rax, 0x8(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2a14(%rip), %rdx      # 0x9fe2
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7c34
cmpl $0x0, 0x8(%rsp)
jne 0x7c34
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7c34
movq %rax, %rdi
callq 0x25a0
movq 0x719f(%rip), %rcx      # 0xe7b0
movq %rax, 0x10(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x29c8(%rip), %rdx      # 0x9fec
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7c5f
cmpl $0x0, 0x8(%rsp)
jne 0x7c5f
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7c5f
movq %rax, %rdi
callq 0x25a0
movq 0x7149(%rip), %rcx      # 0xe7b0
movq %rax, 0x30(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x297c(%rip), %rdx      # 0x9ff6
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7c87
cmpl $0x3, 0x8(%rsp)
jne 0x7c87
cmpl $0x0, 0xc(%rsp)
jle 0x7c87
movq %rax, %rdi
callq 0x2380
movq 0x70f4(%rip), %rcx      # 0xe7b0
movb %al, 0x3c(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2932(%rip), %rdx      # 0xa000
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7caf
cmpl $0x3, 0x8(%rsp)
jne 0x7caf
cmpl $0x0, 0xc(%rsp)
jle 0x7caf
movq %rax, %rdi
callq 0x2380
movq 0x70a0(%rip), %rcx      # 0xe7b0
movl %eax, 0x38(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x28ea(%rip), %rdx      # 0xa00c
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x382b
testq %rax, %rax
je 0x7cd7
cmpl $0x3, 0x8(%rsp)
jne 0x7cd7
cmpl $0x0, 0xc(%rsp)
jle 0x7cd7
movq %rax, %rdi
callq 0x2380
movq 0x704c(%rip), %r14      # 0xe7b0
movb %al, 0x3d(%r14)
testq %rbx, %rbx
je 0x77a7
movq %rbx, %rdi
callq 0x2410
jmp 0x7804
leaq 0x1e9f(%rip), %rsi      # 0x9620
leaq 0x27a7(%rip), %rdx      # 0x9f2f
leaq 0x27d6(%rip), %r8       # 0x9f65
xorl %ebx, %ebx
movl $0x3, %edi
movl $0xa7, %ecx
xorl %eax, %eax
callq 0x42c5
jmp 0x735b
movq %r12, %rdi
callq 0x2270
leaq 0x2862(%rip), %rdx      # 0xa018
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x382b
testq %rax, %rax
setne %dl
cmpl $0x0, (%r15)
sete %sil
movl (%r14), %ecx
testl %ecx, %ecx
setg %dil
andb %sil, %dil
andb %dl, %dil
cmpb $0x1, %dil
jne 0x7808
movl %ecx, %esi
movq %rax, %rdi
callq 0x25a0
movq 0x6fac(%rip), %r14      # 0xe7b0
movq %rax, 0x18(%r14)
testq %r13, %r13
je 0x781c
movq %r13, %rdi
callq 0x2410
movq 0x10(%rsp), %r14
jmp 0x7877
movq %r12, %rdi
callq 0x2270
leaq 0x27f9(%rip), %rdx      # 0xa024
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x382b
testq %rax, %rax
setne %dl
cmpl $0x0, (%r15)
sete %sil
movl (%r14), %ecx
testl %ecx, %ecx
setg %dil
andb %sil, %dil
andb %dl, %dil
cmpb $0x1, %dil
movq 0x10(%rsp), %r14
jne 0x7882
movl %ecx, %esi
movq %rax, %rdi
callq 0x25a0
movq 0x6f32(%rip), %rcx      # 0xe7b0
movq %rax, 0x20(%rcx)
testq %r14, %r14
je 0x7891
movq %r14, %rdi
callq 0x2410
jmp 0x78eb
movq %r12, %rdi
callq 0x2270
leaq 0x2790(%rip), %rdx      # 0xa030
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x382b
testq %rax, %rax
setne %dl
cmpl $0x0, (%r15)
sete %sil
movl (%r14), %ecx
testl %ecx, %ecx
setg %dil
andb %sil, %dil
andb %dl, %dil
cmpb $0x1, %dil
jne 0x7ac4
movl %ecx, %esi
movq %rax, %rdi
callq 0x25a0
movq 0x6ebe(%rip), %r14      # 0xe7b0
movq %rax, 0x28(%r14)
movq 0x18(%rsp), %rdi
callq 0x2250
movq %r12, %rdi
callq 0x2250
testq %r14, %r14
je 0x7abd
movq (%r14), %r9
leaq 0x1d5e(%rip), %rbx      # 0x9679
leaq 0x260d(%rip), %r14      # 0x9f2f
leaq 0x2821(%rip), %r8       # 0xa14a
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0xf, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6e69(%rip), %rax      # 0xe7b0
movq 0x8(%rax), %r9
leaq 0x2805(%rip), %r8       # 0xa157
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x10, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6e40(%rip), %rax      # 0xe7b0
movq 0x10(%rax), %r9
leaq 0x27eb(%rip), %r8       # 0xa166
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x11, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6e17(%rip), %rax      # 0xe7b0
movzbl 0x3c(%rax), %r9d
leaq 0x27cf(%rip), %r8       # 0xa174
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x12, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6ded(%rip), %rax      # 0xe7b0
movq 0x30(%rax), %r9
leaq 0x27b5(%rip), %r8       # 0xa183
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x13, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6dc4(%rip), %rax      # 0xe7b0
movl 0x38(%rax), %r9d
leaq 0x279a(%rip), %r8       # 0xa191
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x14, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6d9b(%rip), %rbx      # 0xe7b0
movq 0x18(%rbx), %r9
testq %r9, %r9
je 0x7a4b
leaq 0x1c54(%rip), %rsi      # 0x9679
leaq 0x2503(%rip), %rdx      # 0x9f2f
leaq 0x276e(%rip), %r8       # 0xa1a1
movl $0x1, %edi
movl $0x16, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6d65(%rip), %rbx      # 0xe7b0
movq 0x20(%rbx), %r9
testq %r9, %r9
je 0x7a81
leaq 0x1c1e(%rip), %rsi      # 0x9679
leaq 0x24cd(%rip), %rdx      # 0x9f2f
leaq 0x2748(%rip), %r8       # 0xa1b1
movl $0x1, %edi
movl $0x18, %ecx
xorl %eax, %eax
callq 0x42c5
movq 0x6d2f(%rip), %rbx      # 0xe7b0
movq 0x28(%rbx), %r9
testq %r9, %r9
je 0x735b
addq $0xa, %r9
leaq 0x1be0(%rip), %rsi      # 0x9679
leaq 0x248f(%rip), %rdx      # 0x9f2f
leaq 0x271a(%rip), %r8       # 0xa1c1
movl $0x1, %edi
movl $0x1a, %ecx
xorl %eax, %eax
callq 0x42c5
jmp 0x7354
xorl %ebx, %ebx
jmp 0x735b
movq 0x6ce5(%rip), %r14      # 0xe7b0
jmp 0x78f6
leaq 0x1b49(%rip), %rsi      # 0x9620
leaq 0x2451(%rip), %rdx      # 0x9f2f
leaq 0x2568(%rip), %r8       # 0xa04d
movl $0x3, %edi
movl $0x5d, %ecx
jmp 0x7b31
leaq 0x1b28(%rip), %rsi      # 0x9620
leaq 0x2430(%rip), %rdx      # 0x9f2f
leaq 0x257e(%rip), %r8       # 0xa084
movl $0x3, %edi
movl $0x75, %ecx
jmp 0x7b31
leaq 0x1b07(%rip), %rsi      # 0x9620
leaq 0x240f(%rip), %rdx      # 0x9f2f
leaq 0x2572(%rip), %r8       # 0xa099
movl $0x3, %edi
movl $0x2b, %ecx
xorl %eax, %eax
callq 0x42c5
jmp 0x7d04
callq 0x2400
movl (%rax), %edi
callq 0x2330
movq %rax, (%rsp)
leaq 0x1acc(%rip), %rsi      # 0x9620
leaq 0x23d4(%rip), %rdx      # 0x9f2f
leaq 0x2565(%rip), %r8       # 0xa0c7
movl $0x3, %edi
movl $0x32, %ecx
movq %rbp, %r9
xorl %eax, %eax
callq 0x42c5
jmp 0x7bd1
leaq 0x1aa1(%rip), %rsi      # 0x9620
leaq 0x23a9(%rip), %rdx      # 0x9f2f
leaq 0x2556(%rip), %r8       # 0xa0e3
movl $0x3, %edi
movl $0x3b, %ecx
movq %rbp, %r9
xorl %eax, %eax
callq 0x42c5
jmp 0x7bc9
leaq 0x1a76(%rip), %rsi      # 0x9620
leaq 0x237e(%rip), %rdx      # 0x9f2f
leaq 0x253d(%rip), %r8       # 0xa0f5
movl $0x3, %edi
movl $0x44, %ecx
xorl %eax, %eax
callq 0x42c5
movq %r14, %rdi
callq 0x24b0
movq %rbp, %rdi
callq 0x2250
jmp 0x7d04
leaq 0x1a3b(%rip), %rsi      # 0x9620
leaq 0x2343(%rip), %rdx      # 0x9f2f
leaq 0x23c1(%rip), %r8       # 0x9fb4
leaq 0x23b1(%rip), %r9       # 0x9fab
movl $0x3, %edi
movl $0xaf, %ecx
jmp 0x7cfd
leaq 0x1a10(%rip), %rsi      # 0x9620
leaq 0x2318(%rip), %rdx      # 0x9f2f
leaq 0x2396(%rip), %r8       # 0x9fb4
leaq 0x23b2(%rip), %r9       # 0x9fd7
movl $0x3, %edi
movl $0xb0, %ecx
jmp 0x7cfd
leaq 0x19e5(%rip), %rsi      # 0x9620
leaq 0x22ed(%rip), %rdx      # 0x9f2f
leaq 0x236b(%rip), %r8       # 0x9fb4
leaq 0x2392(%rip), %r9       # 0x9fe2
movl $0x3, %edi
movl $0xb1, %ecx
jmp 0x7cfd
leaq 0x19ba(%rip), %rsi      # 0x9620
leaq 0x22c2(%rip), %rdx      # 0x9f2f
leaq 0x2340(%rip), %r8       # 0x9fb4
leaq 0x2371(%rip), %r9       # 0x9fec
movl $0x3, %edi
movl $0xb2, %ecx
jmp 0x7cfd
leaq 0x1992(%rip), %rsi      # 0x9620
leaq 0x229a(%rip), %rdx      # 0x9f2f
leaq 0x2318(%rip), %r8       # 0x9fb4
leaq 0x2353(%rip), %r9       # 0x9ff6
movl $0x3, %edi
movl $0xb3, %ecx
jmp 0x7cfd
leaq 0x196a(%rip), %rsi      # 0x9620
leaq 0x2272(%rip), %rdx      # 0x9f2f
leaq 0x22f0(%rip), %r8       # 0x9fb4
leaq 0x2335(%rip), %r9       # 0xa000
movl $0x3, %edi
movl $0xb4, %ecx
jmp 0x7cfd
leaq 0x1942(%rip), %rsi      # 0x9620
leaq 0x224a(%rip), %rdx      # 0x9f2f
leaq 0x22c8(%rip), %r8       # 0x9fb4
leaq 0x2319(%rip), %r9       # 0xa00c
movl $0x3, %edi
movl $0xb5, %ecx
xorl %eax, %eax
callq 0x42c5
movl $0x1, %edi
callq 0x2100