// File: /workspace/github_cpp_makefile_star2_O1/fieryzig[P]GameServer/LogicServer/LogicServer.cpp
// Function: fieryzig::LogicServer::SetConfig(char const*)
RS LogicServer::SetConfig(const char* configFile)
{
    string json = GetStringFromFile(configFile);
    if (json == "") {
        cout << configFile << " doesn't exist!" << endl;
        return RS::FAILED;
    }
    using rapidjson::Document;
    
    Document d;
    d.Parse(json.c_str());
    
    string type; ServerType st;
    int port = -1;
    string ip;
    
    using rapidjson::Value;
    
    Value& v = d["ServerType"];
    if (v.IsString()) {
        type = v.GetString();
        if (type == "CLIENT") {
            st = ServerType::CLIENT;
        }
        else if (type == "GATEWAY") {
            st = ServerType::GATEWAY;
        }
        else if (type == "LOGIC") {
            st = ServerType::LOGIC;
        }
        else {
            cout << "Wrong Server Type!" << endl;
            return RS::FAILED;
        }
    }
    v = d["IP"];
    if (v.IsString()) {
        ip = v.GetString();
    }
    else {
        cout << "Wrong IP Format!" << endl;
    }
    
    v = d["PORT"];
    if (v.IsInt()) {
        port = v.GetInt();
    }
    else {
        cout << "Wrong port!" << endl;
    }
    
    v = d["GATEWAY"];
    if (v.IsArray()) {
        for (int i = 0; i < v.Size(); i++) {
            Value& content = v[i];
            string ip; int port;
            if (content.HasMember("IP") && content["IP"].IsString()) {
                ip = content["IP"].GetString();
            }
            if (content.HasMember("PORT") && content["PORT"].IsInt()) {
                port = content["PORT"].GetInt();
            }
            gateway = make_pair(ip,port);
        }
    }

    config = new ServerConfig(st, ip, port);
    return RS::SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movq %rdi, -0x40(%rbp)
leaq -0x118(%rbp), %r14
movq %r14, %rdi
callq 0x28ac
leaq 0x6cb6(%rip), %rsi      # 0x9af5
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x2fa4
leaq -0x178(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x367c
movq -0x118(%rbp), %rax
leaq -0xb0(%rbp), %rsi
movq %rax, (%rsi)
movq %rax, 0x8(%rsi)
leaq -0x178(%rbp), %rdi
callq 0x4162
leaq -0x78(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xc8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x41d8(%rip), %rsi      # 0x7085
leaq -0x178(%rbp), %rdi
callq 0x3704
movq %rax, %r14
testb $0x4, 0xf(%rax)
movq %rax, -0x38(%rbp)
je 0x3043
movq %r14, %rdi
callq 0x376e
movq %rax, %rbx
leaq -0x88(%rbp), %r15
movq 0x8(%r15), %r12
movq %rax, %rdi
callq 0x2100
movq $0x0, -0x38(%rbp)
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x22f0
leaq 0x4186(%rip), %rsi      # 0x7090
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x3043
leaq 0x4172(%rip), %rsi      # 0x7097
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x3033
leaq 0x415f(%rip), %rsi      # 0x709f
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x303a
movq 0xa07d(%rip), %rbx      # 0xcfd8
leaq 0x4143(%rip), %rsi      # 0x70a5
movl $0x12, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0xa04b(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2160
jmp 0x33f1
testq %rbx, %rbx
je 0x2fc5
movq %rbx, %rdi
callq 0x2100
movq 0xa020(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2240
jmp 0x2fe3
movq 0xa00c(%rip), %rax      # 0xcfd8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x2330
movq 0x9fee(%rip), %rbx      # 0xcfd8
leaq 0x4084(%rip), %rsi      # 0x7075
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x9fbc(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2160
jmp 0x342a
movl $0x1, %eax
jmp 0x303f
movl $0x2, %eax
movq %rax, -0x38(%rbp)
leaq 0x406e(%rip), %rsi      # 0x70b8
leaq -0x178(%rbp), %rdi
callq 0x3704
cmpq %rax, %r14
je 0x3472
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
testb $0x4, 0xf(%r14)
jne 0x30bb
movq 0x9f5e(%rip), %rbx      # 0xcfd8
leaq 0x403a(%rip), %rsi      # 0x70bb
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x9f2c(%rip), %rdi      # 0xcfd8
callq 0x2030
movq %rax, %rdi
callq 0x2160
jmp 0x30ec
movq %r14, %rdi
callq 0x376e
movq %rax, %rbx
leaq -0xd8(%rbp), %r15
movq 0x8(%r15), %r12
movq %rax, %rdi
callq 0x2100
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x22f0
leaq 0x3fd9(%rip), %rsi      # 0x70cc
leaq -0x178(%rbp), %rdi
callq 0x3704
cmpq %rax, %r14
je 0x3472
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
testb $0x20, 0xe(%r14)
jne 0x316b
movq 0x9eb5(%rip), %rbx      # 0xcfd8
leaq 0x3fa7(%rip), %rsi      # 0x70d1
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x9e83(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2160
jmp 0x3171
movl (%r14), %eax
movl %eax, -0x2c(%rbp)
leaq 0x3f1f(%rip), %rsi      # 0x7097
leaq -0x178(%rbp), %rdi
callq 0x3704
cmpq %rax, %r14
je 0x3472
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
cmpw $0x4, 0xe(%r14)
jne 0x336e
cmpw $0x4, 0xe(%r14)
jne 0x334f
movq -0x40(%rbp), %rax
addq $0x170, %rax            # imm = 0x170
movq %rax, -0xb8(%rbp)
xorl %r12d, %r12d
cmpl (%r14), %r12d
jae 0x336e
movq %r14, %rbx
movq %r14, %rdi
movl %r12d, %esi
callq 0x37b2
movq %rax, %r13
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movb $0x0, -0x58(%rbp)
leaq -0xb0(%rbp), %rdi
movq %r13, %rsi
leaq 0x3eb3(%rip), %rdx      # 0x70b8
callq 0x5fb0
movq -0xb0(%rbp), %r14
movq %r13, %rdi
callq 0x5f6e
cmpq %rax, %r14
je 0x326d
movq %r13, %rdi
leaq 0x3e90(%rip), %rsi      # 0x70b8
callq 0x3704
testb $0x4, 0xf(%rax)
je 0x326d
movq %r13, %rdi
leaq 0x3e7b(%rip), %rsi      # 0x70b8
callq 0x3704
movq %rax, %rdi
callq 0x376e
movq %rax, %r15
movq -0x60(%rbp), %r14
movq %rax, %rdi
callq 0x2100
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x22f0
leaq -0xb0(%rbp), %rdi
movq %r13, %rsi
leaq 0x3e4e(%rip), %rdx      # 0x70cc
callq 0x5fb0
movq -0xb0(%rbp), %r14
movq %r13, %rdi
callq 0x5f6e
cmpq %rax, %r14
je 0x32ca
movq %r13, %rdi
leaq 0x3e2b(%rip), %rsi      # 0x70cc
callq 0x3704
testb $0x20, 0xe(%rax)
je 0x32ca
movq %r13, %rdi
leaq 0x3e16(%rip), %rsi      # 0x70cc
callq 0x3704
testb $0x20, 0xe(%rax)
je 0x3453
movl (%rax), %eax
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %r14
movq %r14, -0xb0(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
callq 0x3850
movl -0x44(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0xb8(%rbp), %rdi
movq %r15, %rsi
callq 0x2280
movl -0x90(%rbp), %eax
movq -0x40(%rbp), %rcx
movl %eax, 0x190(%rcx)
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
movq %rbx, %r14
je 0x332e
callq 0x21d0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x3340
callq 0x21d0
incl %r12d
cmpw $0x4, 0xe(%r14)
je 0x31c6
leaq 0x5a94(%rip), %rdi      # 0x8dea
leaq 0x3dd0(%rip), %rsi      # 0x712d
leaq 0x5a90(%rip), %rcx      # 0x8df4
movl $0x5f1, %edx            # imm = 0x5F1
callq 0x2150
movl $0x30, %edi
callq 0x2200
movq %rax, %r14
leaq -0xe8(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %rdi
callq 0x3850
movq -0x38(%rbp), %rax
movl %eax, (%r14)
leaq 0x8(%r14), %rdi
movq %r14, %rax
addq $0x18, %rax
movq %rax, 0x8(%r14)
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
addq %rsi, %rdx
callq 0x3850
movl -0x2c(%rbp), %eax
movl %eax, 0x28(%r14)
movq -0x40(%rbp), %rax
movq %r14, 0x8(%rax)
movq -0xf8(%rbp), %rdi
xorl %ebx, %ebx
cmpq %r15, %rdi
je 0x33f1
callq 0x21d0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x3409
callq 0x21d0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x341e
callq 0x21d0
leaq -0x178(%rbp), %rdi
callq 0x3818
leaq -0x108(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x343f
callq 0x21d0
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58eb(%rip), %rdi      # 0x8d45
leaq 0x3ccc(%rip), %rsi      # 0x712d
leaq 0x58f6(%rip), %rcx      # 0x8d5e
movl $0x69f, %edx            # imm = 0x69F
callq 0x2150
leaq 0x57f4(%rip), %rdi      # 0x8c6d
leaq 0x3cad(%rip), %rsi      # 0x712d
leaq 0x57f3(%rip), %rcx      # 0x8c7a
movl $0x326, %edx            # imm = 0x326
callq 0x2150
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x34aa
callq 0x21d0
jmp 0x34aa
movq %rax, %rbx
movq %r14, %rdi
jmp 0x34d4
movq %rax, %rbx
jmp 0x3506
jmp 0x34b6
movq %rax, %rbx
jmp 0x3512
jmp 0x34bd
movq %rax, %rbx
jmp 0x34d9
jmp 0x34c4
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x34d9
callq 0x21d0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x34f1
callq 0x21d0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x3506
callq 0x21d0
leaq -0x178(%rbp), %rdi
callq 0x3818
leaq -0x108(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3527
callq 0x21d0
movq %rbx, %rdi
callq 0x2350
nop