// File: Necrelox[P]Auto_Presence/src/automatic_presence.cpp
// Function: automatic_presence::automatic_presence(int, char**)
automatic_presence::automatic_presence(int nbArg, char **args)
{
    this->path = args[1];
    if (nbArg == 5)
        this->late_authorized = std::atoi(args[4]);
    time_t now = time(NULL);
    tm *date = localtime(&now);
    std::string NameNewFile = "presence-" + std::to_string(date->tm_mday) + ":" + std::to_string(date->tm_mon+1) + ":" + std::to_string(date->tm_year+1900) + ".txt";
    this->newfile.open(NameNewFile, std::ios::out);

    for (int i = 2; i < 4 ; i++) {
        std::string rules(args[i]);
        std::istringstream flux_rules(rules);
        std::string split_rules;
        int check = std::count(rules.begin(), rules.end(), ':');
        for (int t = 0, div = 10000; t < check+1; t++) {
            getline(flux_rules, split_rules, ':');

            split_rules.erase(std::remove(split_rules.begin(), split_rules.end(), 0), split_rules.end()); 
            for (size_t j = 0; j < split_rules.size() ; j++) {
                // std::cout << "[" << split_rules[j] << "] \n";
                if (!std::isdigit(split_rules[j]))
                    throw CError("Error argument");
            }

            if (i == 2)
                this->time_rules_start += std::atoi(split_rules.c_str()) * div;
            else
                this->time_rules_end += std::atoi(split_rules.c_str()) * div;
            div /= 100;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
movq %rdi, %rax
movq %rax, -0x3d8(%rbp)
callq 0x33d0
movq -0x3d0(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x3490
jmp 0x37a9
movq -0x3d8(%rbp), %rax
movl $0x0, 0x220(%rax)
movl $0x0, 0x224(%rax)
movl $0x0, 0x228(%rax)
movl $0x0, 0x22c(%rax)
movw $0x5, 0x230(%rax)
addq $0x238, %rax            # imm = 0x238
movq %rax, -0x3e8(%rbp)
leaq -0x25(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x34c0
movq -0x3e8(%rbp), %rdi
movq -0x3e0(%rbp), %rdx
leaq 0x483c(%rip), %rsi      # 0x804f
callq 0x4d30
jmp 0x381a
leaq -0x25(%rbp), %rdi
callq 0x3330
movq -0x3d8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x33c0
jmp 0x3839
cmpl $0x5, -0xc(%rbp)
jne 0x389a
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x3430
movl %eax, %ecx
movq -0x3d8(%rbp), %rax
movw %cx, 0x230(%rax)
jmp 0x389a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3fc1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x25(%rbp), %rdi
callq 0x3330
jmp 0x3fb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3fa9
xorl %eax, %eax
movl %eax, %edi
callq 0x32d0
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3220
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0xc(%rax), %esi
leaq -0x118(%rbp), %rdi
callq 0x4f50
jmp 0x38c9
leaq 0x4744(%rip), %rsi      # 0x8014
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rdx
callq 0x4f00
jmp 0x38e5
leaq 0x4732(%rip), %rdx      # 0x801e
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4de0
jmp 0x3901
movq -0x38(%rbp), %rax
movl 0x10(%rax), %esi
incl %esi
leaq -0x138(%rbp), %rdi
callq 0x4f50
jmp 0x3918
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0x4e30
jmp 0x3934
leaq 0x46e3(%rip), %rdx      # 0x801e
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4de0
jmp 0x3950
movq -0x38(%rbp), %rax
movl 0x14(%rax), %esi
addl $0x76c, %esi            # imm = 0x76C
leaq -0x158(%rbp), %rdi
callq 0x4f50
jmp 0x396b
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x158(%rbp), %rdx
callq 0x4e30
jmp 0x3984
leaq 0x4695(%rip), %rdx      # 0x8020
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4de0
jmp 0x399a
leaq -0x78(%rbp), %rdi
callq 0x31d0
leaq -0x158(%rbp), %rdi
callq 0x31d0
leaq -0x98(%rbp), %rdi
callq 0x31d0
leaq -0xb8(%rbp), %rdi
callq 0x31d0
leaq -0x138(%rbp), %rdi
callq 0x31d0
leaq -0xd8(%rbp), %rdi
callq 0x31d0
leaq -0xf8(%rbp), %rdi
callq 0x31d0
leaq -0x118(%rbp), %rdi
callq 0x31d0
movq -0x3d8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x58(%rbp), %rsi
movl $0x10, %edx
callq 0x3180
jmp 0x3a12
movl $0x2, -0x15c(%rbp)
cmpl $0x4, -0x15c(%rbp)
jge 0x3f8e
movq -0x18(%rbp), %rax
movslq -0x15c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x34c0
movq -0x3f8(%rbp), %rsi
movq -0x3f0(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x4d30
jmp 0x3a6e
leaq -0x181(%rbp), %rdi
callq 0x3330
leaq -0x308(%rbp), %rdi
leaq -0x180(%rbp), %rsi
movl $0x8, %edx
callq 0x3480
jmp 0x3a94
leaq -0x328(%rbp), %rdi
callq 0x33d0
leaq -0x180(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x3290
movq -0x408(%rbp), %rdi
movq %rax, -0x338(%rbp)
callq 0x31b0
movq %rax, -0x340(%rbp)
movb $0x3a, -0x341(%rbp)
movq -0x338(%rbp), %rdi
movq -0x340(%rbp), %rsi
leaq -0x341(%rbp), %rdx
callq 0x5070
movq %rax, -0x400(%rbp)
jmp 0x3af7
movq -0x400(%rbp), %rax
movl %eax, -0x32c(%rbp)
movl $0x0, -0x348(%rbp)
movl $0x2710, -0x34c(%rbp)   # imm = 0x2710
movl -0x348(%rbp), %eax
movl -0x32c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x3f30
leaq -0x308(%rbp), %rdi
leaq -0x328(%rbp), %rsi
movl $0x3a, %edx
callq 0x34f0
jmp 0x3b49
leaq -0x328(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x3290
movq -0x418(%rbp), %rdi
movq %rax, -0x368(%rbp)
callq 0x31b0
movq %rax, -0x370(%rbp)
movl $0x0, -0x374(%rbp)
movq -0x368(%rbp), %rdi
movq -0x370(%rbp), %rsi
leaq -0x374(%rbp), %rdx
callq 0x50c0
movq %rax, -0x410(%rbp)
jmp 0x3ba3
movq -0x410(%rbp), %rax
movq %rax, -0x360(%rbp)
leaq -0x358(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x5110
leaq -0x328(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0x31b0
movq %rax, -0x388(%rbp)
leaq -0x380(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x5110
movq -0x428(%rbp), %rdi
movq -0x358(%rbp), %rsi
movq -0x380(%rbp), %rdx
callq 0x3080
movq %rax, -0x420(%rbp)
jmp 0x3c14
movq -0x420(%rbp), %rax
movq %rax, -0x390(%rbp)
movq $0x0, -0x398(%rbp)
movq -0x398(%rbp), %rax
movq %rax, -0x430(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x31f0
movq %rax, %rcx
movq -0x430(%rbp), %rax
cmpq %rcx, %rax
jae 0x3e9d
movq -0x398(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x3550
movq %rax, -0x438(%rbp)
jmp 0x3c76
movq -0x438(%rbp), %rax
movsbl (%rax), %edi
callq 0x32c0
cmpl $0x0, %eax
jne 0x3e84
movb $0x1, -0x3ba(%rbp)
movl $0x28, %edi
callq 0x3190
movq %rax, -0x448(%rbp)
leaq -0x3b9(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x34c0
movq -0x440(%rbp), %rdx
leaq 0x435e(%rip), %rsi      # 0x8025
leaq -0x3b8(%rbp), %rdi
callq 0x4d30
jmp 0x3cd5
movq -0x448(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x6bc0
jmp 0x3cea
movq -0x448(%rbp), %rdi
movb $0x0, -0x3ba(%rbp)
leaq 0x7061(%rip), %rsi      # 0xad60
leaq 0x144a(%rip), %rdx      # 0x5150
callq 0x34a0
jmp 0x3fd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3dd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3dc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3dbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3db1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3da5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x31d0
leaq -0x158(%rbp), %rdi
callq 0x31d0
leaq -0x98(%rbp), %rdi
callq 0x31d0
leaq -0xb8(%rbp), %rdi
callq 0x31d0
leaq -0x138(%rbp), %rdi
callq 0x31d0
leaq -0xd8(%rbp), %rdi
callq 0x31d0
leaq -0xf8(%rbp), %rdi
callq 0x31d0
leaq -0x118(%rbp), %rdi
callq 0x31d0
jmp 0x3fa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3fa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x181(%rbp), %rdi
callq 0x3330
jmp 0x3fa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3f80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3e5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x31d0
leaq -0x3b9(%rbp), %rdi
callq 0x3330
testb $0x1, -0x3ba(%rbp)
jne 0x3e73
jmp 0x3e7f
movq -0x448(%rbp), %rdi
callq 0x3210
jmp 0x3f68
jmp 0x3e86
movq -0x398(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x398(%rbp)
jmp 0x3c2d
cmpl $0x2, -0x15c(%rbp)
jne 0x3ed8
leaq -0x328(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x3430
movl %eax, %ecx
movq -0x3d8(%rbp), %rax
imull -0x34c(%rbp), %ecx
addl 0x220(%rax), %ecx
movl %ecx, 0x220(%rax)
jmp 0x3f08
leaq -0x328(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x3430
movl %eax, %ecx
movq -0x3d8(%rbp), %rax
imull -0x34c(%rbp), %ecx
addl 0x224(%rax), %ecx
movl %ecx, 0x224(%rax)
movl -0x34c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, -0x34c(%rbp)
movl -0x348(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x348(%rbp)
jmp 0x3b18
leaq -0x328(%rbp), %rdi
callq 0x31d0
leaq -0x308(%rbp), %rdi
callq 0x3170
leaq -0x180(%rbp), %rdi
callq 0x31d0
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
jmp 0x3a1c
leaq -0x328(%rbp), %rdi
callq 0x31d0
leaq -0x308(%rbp), %rdi
callq 0x3170
leaq -0x180(%rbp), %rdi
callq 0x31d0
jmp 0x3fa0
leaq -0x58(%rbp), %rdi
callq 0x31d0
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x31d0
movq -0x3e8(%rbp), %rdi
callq 0x31d0
movq -0x3c8(%rbp), %rdi
callq 0x3410
movq -0x3d0(%rbp), %rdi
callq 0x31d0
movq -0x20(%rbp), %rdi
callq 0x34b0
nopw %cs:(%rax,%rax)