// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d9c
leaq 0x67c6(%rip), %rsi      # 0x9af5
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x3494
leaq -0x178(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3b60
movq -0x118(%rbp), %rax
leaq -0xb0(%rbp), %rsi
movq %rax, (%rsi)
movq %rax, 0x8(%rsi)
leaq -0x178(%rbp), %rdi
callq 0x460a
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 0x3ce8(%rip), %rsi      # 0x7085
leaq -0x178(%rbp), %rdi
callq 0x3be0
movq %rax, %r14
testb $0x4, 0xf(%rax)
movq %rax, -0x38(%rbp)
je 0x3533
movq %r14, %rdi
callq 0x3c4a
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 0x3c96(%rip), %rsi      # 0x7090
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x3533
leaq 0x3c82(%rip), %rsi      # 0x7097
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x3523
leaq 0x3c6f(%rip), %rsi      # 0x709f
leaq -0x88(%rbp), %rdi
callq 0x20b0
testl %eax, %eax
je 0x352a
movq 0x9b8d(%rip), %rbx      # 0xcfd8
leaq 0x3c53(%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 0x9b5b(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2160
jmp 0x38d5
testq %rbx, %rbx
je 0x34b5
movq %rbx, %rdi
callq 0x2100
movq 0x9b30(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2240
jmp 0x34d3
movq 0x9b1c(%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 0x9afe(%rip), %rbx      # 0xcfd8
leaq 0x3b94(%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 0x9acc(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2160
jmp 0x390e
movl $0x1, %eax
jmp 0x352f
movl $0x2, %eax
movq %rax, -0x38(%rbp)
leaq 0x3b7e(%rip), %rsi      # 0x70b8
leaq -0x178(%rbp), %rdi
callq 0x3be0
cmpq %rax, %r14
je 0x3956
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
testb $0x4, 0xf(%r14)
jne 0x35ab
movq 0x9a6e(%rip), %rbx      # 0xcfd8
leaq 0x3b4a(%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 0x9a3c(%rip), %rdi      # 0xcfd8
callq 0x2030
movq %rax, %rdi
callq 0x2160
jmp 0x35dc
movq %r14, %rdi
callq 0x3c4a
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 0x3ae9(%rip), %rsi      # 0x70cc
leaq -0x178(%rbp), %rdi
callq 0x3be0
cmpq %rax, %r14
je 0x3956
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
testb $0x20, 0xe(%r14)
jne 0x365b
movq 0x99c5(%rip), %rbx      # 0xcfd8
leaq 0x3ab7(%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 0x9993(%rip), %rdi      # 0xcfd8
callq 0x2030
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2160
jmp 0x3661
movl (%r14), %eax
movl %eax, -0x2c(%rbp)
leaq 0x3a2f(%rip), %rsi      # 0x7097
leaq -0x178(%rbp), %rdi
callq 0x3be0
cmpq %rax, %r14
je 0x3956
movups (%rax), %xmm0
movups %xmm0, (%r14)
movw $0x0, 0xe(%rax)
cmpw $0x4, 0xe(%r14)
jne 0x3852
movq -0x40(%rbp), %rax
addq $0x170, %rax            # imm = 0x170
movq %rax, -0xb8(%rbp)
xorl %r12d, %r12d
cmpl (%r14), %r12d
jae 0x3852
movq %r14, %rbx
movq %r14, %rdi
movl %r12d, %esi
callq 0x3c8e
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 0x39cf(%rip), %rdx      # 0x70b8
callq 0x5d5a
movq -0xb0(%rbp), %r14
movq %r13, %rdi
callq 0x5d18
cmpq %rax, %r14
je 0x3751
movq %r13, %rdi
leaq 0x39ac(%rip), %rsi      # 0x70b8
callq 0x3be0
testb $0x4, 0xf(%rax)
je 0x3751
movq %r13, %rdi
leaq 0x3997(%rip), %rsi      # 0x70b8
callq 0x3be0
movq %rax, %rdi
callq 0x3c4a
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 0x396a(%rip), %rdx      # 0x70cc
callq 0x5d5a
movq -0xb0(%rbp), %r14
movq %r13, %rdi
callq 0x5d18
cmpq %rax, %r14
je 0x37ae
movq %r13, %rdi
leaq 0x3947(%rip), %rsi      # 0x70cc
callq 0x3be0
testb $0x20, 0xe(%rax)
je 0x37ae
movq %r13, %rdi
leaq 0x3932(%rip), %rsi      # 0x70cc
callq 0x3be0
testb $0x20, 0xe(%rax)
je 0x3937
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 0x3d28
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 0x3812
callq 0x21d0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x3824
callq 0x21d0
incl %r12d
cmpw $0x4, 0xe(%r14)
je 0x36aa
leaq 0x55b0(%rip), %rdi      # 0x8dea
leaq 0x38ec(%rip), %rsi      # 0x712d
leaq 0x55ac(%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 0x3d28
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 0x3d28
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 0x38d5
callq 0x21d0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x38ed
callq 0x21d0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x3902
callq 0x21d0
leaq -0x178(%rbp), %rdi
callq 0x3cf4
leaq -0x108(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3923
callq 0x21d0
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5407(%rip), %rdi      # 0x8d45
leaq 0x37e8(%rip), %rsi      # 0x712d
leaq 0x5412(%rip), %rcx      # 0x8d5e
movl $0x69f, %edx            # imm = 0x69F
callq 0x2150
leaq 0x5310(%rip), %rdi      # 0x8c6d
leaq 0x37c9(%rip), %rsi      # 0x712d
leaq 0x530f(%rip), %rcx      # 0x8c7a
movl $0x326, %edx            # imm = 0x326
callq 0x2150
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x398e
callq 0x21d0
jmp 0x398e
movq %rax, %rbx
movq %r14, %rdi
jmp 0x39b8
movq %rax, %rbx
jmp 0x39ea
jmp 0x399a
movq %rax, %rbx
jmp 0x39f6
jmp 0x39a1
movq %rax, %rbx
jmp 0x39bd
jmp 0x39a8
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x39bd
callq 0x21d0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x39d5
callq 0x21d0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x39ea
callq 0x21d0
leaq -0x178(%rbp), %rdi
callq 0x3cf4
leaq -0x108(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a0b
callq 0x21d0
movq %rbx, %rdi
callq 0x2350
nop