// File: /workspace/github_c_makefile_star2_O1/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, 0x74e4(%rip)      # 0xe7a0
je 0x72fd
leaq 0x2c74(%rip), %rsi      # 0x9f39
leaq 0x2c73(%rip), %rdx      # 0x9f3f
leaq 0x2c86(%rip), %r8       # 0x9f59
movl $0x2, %edi
movl $0xa1, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x74b5(%rip), %rbx      # 0xe7a0
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, 0x7489(%rip)      # 0xe7a0
testq %rax, %rax
je 0x7724
movl $0x1000, %edi           # imm = 0x1000
callq 0x2150
testq %rax, %rax
je 0x7a6a
movq %rax, %rbx
movl $0x1000, %edx           # imm = 0x1000
movq %rax, %rdi
xorl %esi, %esi
callq 0x2090
leaq 0x2d39(%rip), %rdi      # 0xa085
movl $0xfff, %edx            # imm = 0xFFF
movq %rbx, %rsi
callq 0x2370
testl %eax, %eax
jle 0x7a8b
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 0x7389
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x2270
addl $0x16, %eax
movslq %eax, %r14
movq %r14, %rdi
callq 0x2150
testq %rax, %rax
je 0x7aac
movq %rax, %rbp
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2090
leaq 0x2d12(%rip), %rdx      # 0xa0d1
leaq 0x2be0(%rip), %r8       # 0x9fa6
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x20b0
leaq 0x24f5(%rip), %rsi      # 0x98d2
movq %rbp, %rdi
callq 0x2160
testq %rax, %rax
je 0x7ad7
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 0x7b12
movq %rax, %r15
leaq 0x1(%rax), %r13
movq %r13, %rdi
callq 0x2150
testq %rax, %rax
je 0x7b3d
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2090
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 0x74a6
callq 0x2400
movl (%rax), %edi
callq 0x2330
leaq 0x21ac(%rip), %rsi      # 0x9630
leaq 0x2ab4(%rip), %rdx      # 0x9f3f
leaq 0x2ca7(%rip), %r8       # 0xa139
movl $0x3, %edi
movl $0x4c, %ecx
movq %rax, %r9
xorl %eax, %eax
callq 0x4371
movq %r14, %rdi
callq 0x24a0
movq %rbp, %rdi
callq 0x2250
movq %r12, %rdi
callq 0x2270
leaq 0x2af6(%rip), %rdx      # 0x9fbb
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7b78
cmpl $0x0, 0x8(%rsp)
jne 0x7b78
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7b78
movq %rbx, %r13
movq %rax, %rdi
callq 0x2590
movq 0x7295(%rip), %rcx      # 0xe7a0
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2aca(%rip), %rdx      # 0x9fe7
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
movq 0x20(%rsp), %rbx
je 0x7ba3
cmpl $0x0, 0x8(%rsp)
jne 0x7ba3
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7ba3
movq %rax, %rdi
callq 0x2590
movq 0x723b(%rip), %rcx      # 0xe7a0
movq %rax, 0x8(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2a7a(%rip), %rdx      # 0x9ff2
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7bce
cmpl $0x0, 0x8(%rsp)
jne 0x7bce
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7bce
movq %rax, %rdi
callq 0x2590
movq 0x71e5(%rip), %rcx      # 0xe7a0
movq %rax, 0x10(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2a2e(%rip), %rdx      # 0x9ffc
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7bf9
cmpl $0x0, 0x8(%rsp)
jne 0x7bf9
movl 0xc(%rsp), %esi
testl %esi, %esi
jle 0x7bf9
movq %rax, %rdi
callq 0x2590
movq 0x718f(%rip), %rcx      # 0xe7a0
movq %rax, 0x30(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x29e2(%rip), %rdx      # 0xa006
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7c21
cmpl $0x3, 0x8(%rsp)
jne 0x7c21
cmpl $0x0, 0xc(%rsp)
jle 0x7c21
movq %rax, %rdi
callq 0x2380
movq 0x713a(%rip), %rcx      # 0xe7a0
movb %al, 0x3c(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2998(%rip), %rdx      # 0xa010
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7c49
cmpl $0x3, 0x8(%rsp)
jne 0x7c49
cmpl $0x0, 0xc(%rsp)
jle 0x7c49
movq %rax, %rdi
callq 0x2380
movq 0x70e6(%rip), %rcx      # 0xe7a0
movl %eax, 0x38(%rcx)
movq %r12, %rdi
callq 0x2270
leaq 0x2950(%rip), %rdx      # 0xa01c
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r12, %rdi
movl %eax, %esi
callq 0x38fb
testq %rax, %rax
je 0x7c71
cmpl $0x3, 0x8(%rsp)
jne 0x7c71
cmpl $0x0, 0xc(%rsp)
jle 0x7c71
movq %rax, %rdi
callq 0x2380
movq 0x7092(%rip), %r14      # 0xe7a0
movb %al, 0x3d(%r14)
testq %rbx, %rbx
je 0x7751
movq %rbx, %rdi
callq 0x2410
jmp 0x77ae
leaq 0x1f05(%rip), %rsi      # 0x9630
leaq 0x280d(%rip), %rdx      # 0x9f3f
leaq 0x283c(%rip), %r8       # 0x9f75
xorl %ebx, %ebx
movl $0x3, %edi
movl $0xa7, %ecx
xorl %eax, %eax
callq 0x4371
jmp 0x72eb
movq %r12, %rdi
callq 0x2270
leaq 0x28c8(%rip), %rdx      # 0xa028
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x38fb
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 0x77b2
movl %ecx, %esi
movq %rax, %rdi
callq 0x2590
movq 0x6ff2(%rip), %r14      # 0xe7a0
movq %rax, 0x18(%r14)
testq %r13, %r13
je 0x77c6
movq %r13, %rdi
callq 0x2410
movq 0x10(%rsp), %r14
jmp 0x7821
movq %r12, %rdi
callq 0x2270
leaq 0x285f(%rip), %rdx      # 0xa034
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x38fb
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 0x782c
movl %ecx, %esi
movq %rax, %rdi
callq 0x2590
movq 0x6f78(%rip), %rcx      # 0xe7a0
movq %rax, 0x20(%rcx)
testq %r14, %r14
je 0x783b
movq %r14, %rdi
callq 0x2410
jmp 0x7891
movq %r12, %rdi
callq 0x2270
leaq 0x27f6(%rip), %rdx      # 0xa040
leaq 0xc(%rsp), %r14
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movl %eax, %esi
movq %r14, %rcx
movq %r15, %r8
callq 0x38fb
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 0x789c
movl %ecx, %esi
movq %rax, %rdi
callq 0x2590
movq 0x6f08(%rip), %rcx      # 0xe7a0
movq %rax, 0x28(%rcx)
movq 0x18(%rsp), %rdi
callq 0x2250
movq %r12, %rdi
callq 0x2250
movq 0x6eeb(%rip), %rax      # 0xe7a0
testq %rax, %rax
je 0x72e4
movq (%rax), %r9
leaq 0x1dc1(%rip), %rbx      # 0x9689
leaq 0x2670(%rip), %r14      # 0x9f3f
leaq 0x2884(%rip), %r8       # 0xa15a
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0xf, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6eac(%rip), %rax      # 0xe7a0
movq 0x8(%rax), %r9
leaq 0x2868(%rip), %r8       # 0xa167
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x10, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6e83(%rip), %rax      # 0xe7a0
movq 0x10(%rax), %r9
leaq 0x284e(%rip), %r8       # 0xa176
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x11, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6e5a(%rip), %rax      # 0xe7a0
movzbl 0x3c(%rax), %r9d
leaq 0x2832(%rip), %r8       # 0xa184
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x12, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6e30(%rip), %rax      # 0xe7a0
movq 0x30(%rax), %r9
leaq 0x2818(%rip), %r8       # 0xa193
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x13, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6e07(%rip), %rax      # 0xe7a0
movl 0x38(%rax), %r9d
leaq 0x27fd(%rip), %r8       # 0xa1a1
movl $0x1, %edi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x14, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6dde(%rip), %rax      # 0xe7a0
movq 0x18(%rax), %r9
testq %r9, %r9
je 0x79f1
leaq 0x1cb7(%rip), %rsi      # 0x9689
leaq 0x2566(%rip), %rdx      # 0x9f3f
leaq 0x27d1(%rip), %r8       # 0xa1b1
movl $0x1, %edi
movl $0x16, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6da8(%rip), %rax      # 0xe7a0
movq 0x20(%rax), %r9
testq %r9, %r9
je 0x7a27
leaq 0x1c81(%rip), %rsi      # 0x9689
leaq 0x2530(%rip), %rdx      # 0x9f3f
leaq 0x27ab(%rip), %r8       # 0xa1c1
movl $0x1, %edi
movl $0x18, %ecx
xorl %eax, %eax
callq 0x4371
movq 0x6d72(%rip), %rax      # 0xe7a0
movq 0x28(%rax), %r9
testq %r9, %r9
je 0x72e4
addq $0xa, %r9
leaq 0x1c43(%rip), %rsi      # 0x9689
leaq 0x24f2(%rip), %rdx      # 0x9f3f
leaq 0x277d(%rip), %r8       # 0xa1d1
movl $0x1, %edi
movl $0x1a, %ecx
xorl %eax, %eax
callq 0x4371
jmp 0x72e4
leaq 0x1bbf(%rip), %rsi      # 0x9630
leaq 0x24c7(%rip), %rdx      # 0x9f3f
leaq 0x25de(%rip), %r8       # 0xa05d
movl $0x3, %edi
movl $0x5d, %ecx
jmp 0x7acb
leaq 0x1b9e(%rip), %rsi      # 0x9630
leaq 0x24a6(%rip), %rdx      # 0x9f3f
leaq 0x25f4(%rip), %r8       # 0xa094
movl $0x3, %edi
movl $0x75, %ecx
jmp 0x7acb
leaq 0x1b7d(%rip), %rsi      # 0x9630
leaq 0x2485(%rip), %rdx      # 0x9f3f
leaq 0x25e8(%rip), %r8       # 0xa0a9
movl $0x3, %edi
movl $0x2b, %ecx
xorl %eax, %eax
callq 0x4371
jmp 0x7c9e
callq 0x2400
movl (%rax), %edi
callq 0x2330
movq %rax, (%rsp)
leaq 0x1b42(%rip), %rsi      # 0x9630
leaq 0x244a(%rip), %rdx      # 0x9f3f
leaq 0x25db(%rip), %r8       # 0xa0d7
movl $0x3, %edi
movl $0x32, %ecx
movq %rbp, %r9
xorl %eax, %eax
callq 0x4371
jmp 0x7b6b
leaq 0x1b17(%rip), %rsi      # 0x9630
leaq 0x241f(%rip), %rdx      # 0x9f3f
leaq 0x25cc(%rip), %r8       # 0xa0f3
movl $0x3, %edi
movl $0x3b, %ecx
movq %rbp, %r9
xorl %eax, %eax
callq 0x4371
jmp 0x7b63
leaq 0x1aec(%rip), %rsi      # 0x9630
leaq 0x23f4(%rip), %rdx      # 0x9f3f
leaq 0x25b3(%rip), %r8       # 0xa105
movl $0x3, %edi
movl $0x44, %ecx
xorl %eax, %eax
callq 0x4371
movq %r14, %rdi
callq 0x24a0
movq %rbp, %rdi
callq 0x2250
jmp 0x7c9e
leaq 0x1ab1(%rip), %rsi      # 0x9630
leaq 0x23b9(%rip), %rdx      # 0x9f3f
leaq 0x2437(%rip), %r8       # 0x9fc4
leaq 0x2427(%rip), %r9       # 0x9fbb
movl $0x3, %edi
movl $0xaf, %ecx
jmp 0x7c97
leaq 0x1a86(%rip), %rsi      # 0x9630
leaq 0x238e(%rip), %rdx      # 0x9f3f
leaq 0x240c(%rip), %r8       # 0x9fc4
leaq 0x2428(%rip), %r9       # 0x9fe7
movl $0x3, %edi
movl $0xb0, %ecx
jmp 0x7c97
leaq 0x1a5b(%rip), %rsi      # 0x9630
leaq 0x2363(%rip), %rdx      # 0x9f3f
leaq 0x23e1(%rip), %r8       # 0x9fc4
leaq 0x2408(%rip), %r9       # 0x9ff2
movl $0x3, %edi
movl $0xb1, %ecx
jmp 0x7c97
leaq 0x1a30(%rip), %rsi      # 0x9630
leaq 0x2338(%rip), %rdx      # 0x9f3f
leaq 0x23b6(%rip), %r8       # 0x9fc4
leaq 0x23e7(%rip), %r9       # 0x9ffc
movl $0x3, %edi
movl $0xb2, %ecx
jmp 0x7c97
leaq 0x1a08(%rip), %rsi      # 0x9630
leaq 0x2310(%rip), %rdx      # 0x9f3f
leaq 0x238e(%rip), %r8       # 0x9fc4
leaq 0x23c9(%rip), %r9       # 0xa006
movl $0x3, %edi
movl $0xb3, %ecx
jmp 0x7c97
leaq 0x19e0(%rip), %rsi      # 0x9630
leaq 0x22e8(%rip), %rdx      # 0x9f3f
leaq 0x2366(%rip), %r8       # 0x9fc4
leaq 0x23ab(%rip), %r9       # 0xa010
movl $0x3, %edi
movl $0xb4, %ecx
jmp 0x7c97
leaq 0x19b8(%rip), %rsi      # 0x9630
leaq 0x22c0(%rip), %rdx      # 0x9f3f
leaq 0x233e(%rip), %r8       # 0x9fc4
leaq 0x238f(%rip), %r9       # 0xa01c
movl $0x3, %edi
movl $0xb5, %ecx
xorl %eax, %eax
callq 0x4371
movl $0x1, %edi
callq 0x2100