// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./src/main.cpp
// Function: check_ip(mg_connection*, bool)
bool check_ip(mg_connection* conn, bool verbose = false){
    if(!configs.global().get<bool>("security::access_control")) return true;

    time_t rawtime;
    time(&rawtime);
    const char * cip = cc_get_client_ip(conn);
    string sip(cip);
    time_t lasttime = IPAccessList[sip];
    
    if(is_admin(conn)) return true;
    if(!is_assist(conn).empty()) return true;

    if(IPBanList.find(sip) != IPBanList.end()) {
        // views::info::render(conn, STRING_YOUR_IP_IS_BANNED);
        views::info::render(conn, templates.invoke("misc").toggle("ip_is_banned").build_destory().c_str());
        logLog("Banned IP %s trying to access", cip);
        return false; //banned
    }

    if( abs(lasttime - rawtime) < configs.global().get<int>("user::cooldown") && lasttime != 0){
        views::info::render(conn, templates.invoke("misc").toggle("rapid_accessing").var("IP", cip).build_destory().c_str());
        if(verbose) logLog("%s is rapidly accessing", cip);
        return false;
    }
    IPAccessList[sip] = rawtime;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %esi, %ebp
movq %rdi, %r14
leaq 0x762ea(%rip), %rdi     # 0x87b70
callq 0x1008c
movq %rax, %rbx
leaq 0x4fe7f(%rip), %rsi     # 0x61714
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xcb10
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x14efa
movl %eax, %ebx
leaq 0x30(%rsp), %rdi
callq 0xcd88
movb $0x1, %r15b
testb %bl, %bl
je 0x11b91
leaq 0x28(%rsp), %rdi
callq 0xc850
movq %r14, %rdi
callq 0xe898
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %rax, %rsi
callq 0xcb10
leaq 0x7641a(%rip), %rdi     # 0x87d10
leaq 0x30(%rsp), %rsi
callq 0x14f4a
movslq (%rax), %r13
movq %r14, %rdi
callq 0xe080
movb $0x1, %r15b
testb %al, %al
jne 0x11b87
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xe111
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %r12
callq 0xcd88
testq %r12, %r12
jne 0x11b87
leaq 0x76397(%rip), %rdi     # 0x87cd8
leaq 0x30(%rsp), %rsi
callq 0x1e5e8
testq %rax, %rax
je 0x119ff
leaq 0x51f3f(%rip), %rsi     # 0x6389a
leaq 0x50(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0xcb10
leaq 0x763d4(%rip), %rdi     # 0x87d48
leaq 0x50(%rsp), %rsi
callq 0x14fb0
movq %rax, %r15
leaq 0x4fda5(%rip), %rsi     # 0x6172d
leaq 0x78(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%r15), %rdi
leaq 0x78(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1501c
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x1e718
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x78(%rsp), %rdi
callq 0xcd88
leaq 0x50(%rsp), %rdi
callq 0xcd88
leaq 0x4fd4d(%rip), %rdi     # 0x6173a
xorl %r15d, %r15d
movq %rbx, %rsi
xorl %eax, %eax
callq 0xeb8f
jmp 0x11b87
movq %r13, %rax
subq 0x28(%rsp), %rax
movq %rax, %r12
negq %r12
cmovsq %rax, %r12
leaq 0x76158(%rip), %rdi     # 0x87b70
callq 0x1008c
movq %rax, 0x70(%rsp)
leaq 0x4fd2f(%rip), %rsi     # 0x61758
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xcb10
leaq 0x8(%rsp), %rsi
movq 0x70(%rsp), %rdi
callq 0x100e4
cltq
cmpq %rax, %r12
setl %al
testl %r13d, %r13d
setne %r12b
andb %al, %r12b
leaq 0x8(%rsp), %rdi
callq 0xcd88
cmpb $0x1, %r12b
jne 0x11b6a
leaq 0x51e26(%rip), %rsi     # 0x6389a
leaq 0x50(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xcb10
leaq 0x762be(%rip), %rdi     # 0x87d48
leaq 0x50(%rsp), %rsi
callq 0x14fb0
movq %rax, %r15
leaq 0x4fcc9(%rip), %rsi     # 0x61767
leaq 0x78(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%r15), %rdi
leaq 0x78(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
leaq 0x54ede(%rip), %rsi     # 0x669a6
leaq 0xb8(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0xcb10
leaq 0x98(%rsp), %rdi
leaq 0x4(%rsp), %rdx
movq %rbx, %rsi
callq 0xcb10
leaq 0xb8(%rsp), %rsi
leaq 0x98(%rsp), %rdx
movq %r15, %rdi
callq 0x1505c
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x1501c
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x1e718
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x98(%rsp), %rdi
callq 0xcd88
leaq 0xb8(%rsp), %rdi
callq 0xcd88
leaq 0x78(%rsp), %rdi
callq 0xcd88
leaq 0x50(%rsp), %rdi
callq 0xcd88
testb %bpl, %bpl
je 0x11b84
leaq 0x4fc12(%rip), %rdi     # 0x61777
jmp 0x119ed
movq 0x28(%rsp), %rbx
leaq 0x7619a(%rip), %rdi     # 0x87d10
leaq 0x30(%rsp), %rsi
callq 0x14f4a
movl %ebx, (%rax)
jmp 0x11b87
xorl %r15d, %r15d
leaq 0x30(%rsp), %rdi
callq 0xcd88
movl %r15d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd88
jmp 0x11bc7
movq %rax, %rbx
jmp 0x11bd4
jmp 0x11c04
jmp 0x11c04
jmp 0x11bfb
jmp 0x11bfb
jmp 0x11c28
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xcd88
leaq 0xb8(%rsp), %rdi
jmp 0x11bf2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x11c16
jmp 0x11c28
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd88
jmp 0x11c07
jmp 0x11bfb
movq %rax, %rbx
jmp 0x11c11
jmp 0x11c28
jmp 0x11c28
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0xcd88
leaq 0x50(%rsp), %rdi
callq 0xcd88
jmp 0x11c2b
jmp 0x11c28
jmp 0x11c23
jmp 0x11c28
movq %rax, %rbx
jmp 0x11c35
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xcd88
movq %rbx, %rdi
callq 0xc790