// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, %r14
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rdx, 0x10(%rsp)
movl %esi, %ebx
movb $0x0, 0x10(%rdi)
addq $0x20, %rdi
movq %rdi, 0x40(%rsp)
movq %r14, 0x8(%rsp)
callq 0x3330
xorps %xmm0, %xmm0
movups %xmm0, 0x220(%r14)
movw $0x5, 0x230(%r14)
leaq 0x238(%r14), %rdi
leaq 0x1a7e(%rip), %rsi      # 0x505b
leaq 0x138(%rsp), %rdx
movq %rdi, 0x38(%rsp)
callq 0x4086
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x33b0
cmpl $0x5, %ebx
jne 0x361f
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
movq 0x8(%rsp), %rcx
movw %ax, 0x230(%rcx)
xorl %edi, %edi
callq 0x3210
leaq 0x130(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3190
movq %rax, %rbx
movl 0xc(%rax), %esi
leaq 0xf0(%rsp), %rdi
callq 0x416b
leaq 0x19d0(%rip), %rsi      # 0x5020
leaq 0x90(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x4147
leaq 0x19be(%rip), %rdx      # 0x502a
leaq 0x48(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x40c1
movl 0x10(%rbx), %esi
incl %esi
leaq 0xd0(%rsp), %rdi
callq 0x416b
leaq 0x18(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x40e0
leaq 0x197c(%rip), %rdx      # 0x502a
leaq 0x68(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x40c1
movl $0x76c, %esi            # imm = 0x76C
addl 0x14(%rbx), %esi
leaq 0xb0(%rsp), %rdi
callq 0x416b
leaq 0x138(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x40e0
leaq 0x1939(%rip), %rdx      # 0x502c
leaq 0x110(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x40c1
leaq 0x138(%rsp), %rdi
callq 0x3100
leaq 0xb0(%rsp), %rdi
callq 0x3100
leaq 0x68(%rsp), %rdi
callq 0x3100
leaq 0x18(%rsp), %rdi
callq 0x3100
leaq 0xd0(%rsp), %rdi
callq 0x3100
leaq 0x48(%rsp), %rdi
callq 0x3100
leaq 0x90(%rsp), %rdi
callq 0x3100
leaq 0xf0(%rsp), %rdi
callq 0x3100
leaq 0x110(%rsp), %rsi
pushq $0x10
popq %rdx
movq 0x40(%rsp), %rdi
callq 0x3120
movq 0x8(%rsp), %rax
addq $0x220, %rax            # imm = 0x220
movq %rax, 0x88(%rsp)
pushq $0x2
popq %r15
leaq 0x138(%rsp), %rbp
leaq 0x18(%rsp), %r12
cmpq $0x4, %r15
je 0x38d0
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rsi
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x4086
movq %rbp, %rdi
movq %rbx, %rsi
pushq $0x8
popq %rdx
callq 0x3320
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
addq %rdi, %rsi
movb $0x3a, 0x48(%rsp)
leaq 0x48(%rsp), %rdx
callq 0x4381
movq %rax, %r13
movl $0x2710, %ebx           # imm = 0x2710
xorl %r14d, %r14d
cmpl %r13d, %r14d
jg 0x38ae
movq %rbp, %rdi
movq %r12, %rsi
pushq $0x3a
popq %rdx
callq 0x3380
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
andl $0x0, 0x48(%rsp)
leaq 0x48(%rsp), %rdx
callq 0x439c
movq 0x18(%rsp), %rdx
addq 0x20(%rsp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x3050
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x3877
movsbl (%rdi,%rcx), %edx
addl $-0x30, %edx
incq %rcx
cmpl $0xa, %edx
jb 0x3861
jmp 0x38ef
callq 0x32e0
imull %ebx, %eax
cmpq $0x2, %r15
jne 0x3891
movq 0x88(%rsp), %rcx
addl %eax, (%rcx)
jmp 0x389c
movq 0x8(%rsp), %rcx
addl %eax, 0x224(%rcx)
movl %ebx, %eax
cltd
pushq $0x64
popq %rcx
idivl %ecx
incl %r14d
movl %eax, %ebx
jmp 0x380d
movq %r12, %rdi
callq 0x3100
movq %rbp, %rdi
callq 0x3110
leaq 0x68(%rsp), %rdi
callq 0x3100
incq %r15
jmp 0x37a0
leaq 0x110(%rsp), %rdi
callq 0x3100
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3140
movq %rax, %rbx
leaq 0x1730(%rip), %rsi      # 0x5031
leaq 0x48(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x4086
movb $0x1, %bpl
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x4806
xorl %ebp, %ebp
leaq 0x4444(%rip), %rsi      # 0x7d70
leaq 0x891(%rip), %rdx       # 0x41c4
movq %rbx, %rdi
callq 0x3340
jmp 0x39d3
movq %rax, %r12
leaq 0x138(%rsp), %rdi
callq 0x3100
jmp 0x3955
movq %rax, %r12
leaq 0xb0(%rsp), %rdi
callq 0x3100
jmp 0x3967
movq %rax, %r12
leaq 0x68(%rsp), %rdi
callq 0x3100
jmp 0x3976
movq %rax, %r12
leaq 0x18(%rsp), %rdi
callq 0x3100
jmp 0x3985
movq %rax, %r12
leaq 0xd0(%rsp), %rdi
callq 0x3100
leaq 0x48(%rsp), %rdi
callq 0x3100
leaq 0x90(%rsp), %rdi
callq 0x3100
leaq 0xf0(%rsp), %rdi
jmp 0x3a30
movq %rax, %r12
jmp 0x3992
movq %rax, %r12
jmp 0x399c
movq %rax, %r12
jmp 0x39a9
jmp 0x39c4
movq %rax, %r12
jmp 0x3a35
movq %rax, %r12
jmp 0x3a3f
movq %rax, %r12
jmp 0x3a49
movq %rax, %r12
jmp 0x3a28
movq %rax, %r12
jmp 0x3a1e
jmp 0x39e3
jmp 0x39e3
jmp 0x39e3
movq %rax, %r12
jmp 0x3a07
movq %rax, %r12
leaq 0x48(%rsp), %rdi
callq 0x3100
testb %bpl, %bpl
jne 0x39ff
jmp 0x3a07
movq %rax, %r12
movq %rbx, %rdi
callq 0x3180
leaq 0x18(%rsp), %rdi
callq 0x3100
leaq 0x138(%rsp), %rdi
callq 0x3110
leaq 0x68(%rsp), %rdi
callq 0x3100
leaq 0x110(%rsp), %rdi
callq 0x3100
movq 0x38(%rsp), %rdi
callq 0x3100
movq 0x40(%rsp), %rdi
callq 0x32c0
movq 0x8(%rsp), %rdi
callq 0x3100
movq %r12, %rdi
callq 0x3350
nop