// File: /workspace/github_cpp_makefile_star2_O1/Necrelox[P]Auto_Presence/src/automatic_presence.cpp
// Function: automatic_presence::AutomaticPresence()
void automatic_presence::AutomaticPresence()
{
    filehandle handle(this->path);
    std::string buff;
    this->newfile << "login;present" << std::endl;
    while (std::getline(handle.file, buff)) {
        short count = std::count(buff.begin(), buff.end(), '\t');
        if (count == 5) {
            short valid = 0;
            std::stringstream manipule(buff);
            std::vector<std::string> tab;
            std::string push;
            while(getline(manipule, push, ' '))
                tab.push_back(push);

            int key = 0;
            this->time_player_start = 0;
            this->time_player_end = 0;
            for (size_t i = 0, check = 0; i < tab.size(); i++) {
                check = std::count(tab[i].begin(), tab[i].end(), ':');
                if (check == 2) {
                    std::istringstream flux_player(tab[i]);
                    std::string split_player;
                    for (int t = 0, div = 10000; t < 3; t++) {
                        getline(flux_player, split_player, ':');
                        split_player.erase(std::remove(split_player.begin(), split_player.end(), 0), split_player.end()); 
                        split_player.erase(split_player.begin() + 2, split_player.end());
                        for (size_t j = 0; j < split_player.size() ; j++)
                            if (!std::isdigit(split_player[j])) {
                                valid = 1;
                                break;
                            }
                        if (key == 0)
                            this->time_player_start += std::atoi(split_player.c_str()) * div;
                        else 
                            this->time_player_end += std::atoi(split_player.c_str()) * div;
                        div /= 100;

                        if (t == 0 && std::atoi(split_player.c_str()) > 24) {
                            valid = 1;
                            break;
                        }
                        if (t > 0 && std::atoi(split_player.c_str()) > 60) {
                            valid = 1;
                            break;
                        }
                    }
                    if (valid == 1) {
                        valid = 0;
                        break;
                    }
                    key++;
                }
                tab[i].erase(std::remove(tab[i].begin(), tab[i].end(), 0), tab[i].end()); 
                if (tab[i].find("@epitech.eu") != std::string::npos) {
                    tab[i].erase(0, tab[i].find("\t")+1);
                    tab[i].erase(tab[i].find("@epitech.eu")+11);
                    if (tab[i].find("\t") != std::string::npos)
                        tab[i].erase(0, tab[i].find("\t")+1);
                    this->email = tab[i];
                }
            }
            if (key == 2 && !this->email.empty() && this->time_player_start != 0 && this->time_player_end != 0) {
                this->newfile << this->email << ";";
                int presence = 1;
                int hour_p = this->time_player_start / 10000;
                int hour_r = this->time_rules_start / 10000;
                int min_p = (this->time_player_start - (hour_p * 10000))/100;
                int min_r = (this->time_rules_start - (hour_r * 10000))/100;

                if (hour_p <= hour_r) {
                    if (hour_p < hour_r) {
                        hour_p = hour_r;
                        min_p = min_r;
                    }
                    if (min_p > min_r + this->late_authorized)
                        presence = 0;
                }
                else
                    presence = 0;

                if (this->time_player_end < this->time_rules_end)
                    presence = 0;

                if (presence == 0)
                    this->newfile << "absent" << std::endl;
                else
                    this->newfile << "present" << std::endl;
            }

        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5d8, %rsp            # imm = 0x5D8
movq %rdi, %rbx
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x4b66
leaq 0x3d0(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x5326
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x41ca
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x20(%rbx), %rdi
leaq 0x1e54(%rip), %rsi      # 0x6040
movl $0xd, %edx
movq %rdi, (%rsp)
callq 0x3260
movq (%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq (%rsp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3150
leaq 0x238(%rbx), %r13
leaq 0x80(%rsp), %r14
leaq 0x248(%rsp), %r15
leaq 0x60(%rsp), %rbp
movq %rbx, 0x50(%rsp)
movq %r13, 0xa0(%rsp)
movq 0x3d0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x3390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
movq 0x80(%rsp), %rdi
jne 0x484c
movq 0x88(%rsp), %rax
testq %rax, %rax
je 0x424f
xorl %edx, %edx
xorl %ecx, %ecx
xorl %esi, %esi
cmpb $0x9, (%rdi,%rdx)
sete %sil
addq %rsi, %rcx
incq %rdx
cmpq %rdx, %rax
jne 0x42a1
cmpw $0x5, %cx
jne 0x424f
movq %r15, %rdi
movq %r14, %rsi
movl $0x18, %edx
callq 0x3300
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x20(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rcx, 0x68(%rsp)
movb $0x0, 0x70(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movl $0x20, %edx
callq 0x3390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x431c
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x4a24
jmp 0x42ef
movq $0x0, 0x228(%rbx)
movq 0x10(%rsp), %rsi
cmpq %rsi, 0x18(%rsp)
je 0x4805
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %rbx, %r15
shlq $0x5, %r15
movq 0x8(%rsi,%r15), %rax
testq %rax, %rax
je 0x4529
movq (%rsi,%r15), %rcx
addq %r15, %rsi
xorl %edi, %edi
xorl %edx, %edx
xorl %r8d, %r8d
cmpb $0x3a, (%rcx,%rdi)
sete %r8b
addq %r8, %rdx
incq %rdi
cmpq %rdi, %rax
jne 0x4365
cmpq $0x2, %rdx
jne 0x4529
leaq 0xc8(%rsp), %rdi
movl $0x8, %edx
callq 0x3320
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movl $0x2710, %r14d          # imm = 0x2710
xorl %r13d, %r13d
leaq 0xc8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0x3a, %edx
callq 0x3390
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addq %rdi, %rsi
movl $0x0, 0x5c(%rsp)
leaq 0x5c(%rsp), %rdx
callq 0x4c86
movq %rax, %rcx
subq 0x30(%rsp), %rcx
movq %rcx, 0x38(%rsp)
xorl %ecx, %ecx
movb %cl, (%rax)
movq 0x30(%rsp), %rax
movq $0x2, 0x38(%rsp)
movb %cl, 0x2(%rax)
movq 0x30(%rsp), %rbp
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x4441
xorl %ecx, %ecx
movsbl (%rbp,%rcx), %edx
addl $-0x30, %edx
cmpl $0xa, %edx
jae 0x4438
incq %rcx
cmpq %rcx, %rax
jne 0x4421
jmp 0x4441
movw $0x1, %ax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
callq 0x32f0
imull %r14d, %eax
testl %r12d, %r12d
je 0x445f
movq 0x50(%rsp), %rcx
addl %eax, 0x22c(%rcx)
jmp 0x446a
movq 0x50(%rsp), %rcx
addl %eax, 0x228(%rcx)
movq %rbp, %rdi
callq 0x32f0
testl %r13d, %r13d
je 0x447e
cmpl $0x3c, %eax
jle 0x4483
jmp 0x44aa
cmpl $0x18, %eax
jg 0x44aa
movslq %r14d, %rax
imulq $0x51eb851f, %rax, %r14 # imm = 0x51EB851F
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x25, %r14
addl %eax, %r14d
incl %r13d
cmpl $0x3, %r13d
jne 0x43b8
jmp 0x44b3
movw $0x1, %ax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
cmpw $0x1, %ax
setne %r13b
movl $0x0, %ebp
cmovnel %eax, %ebp
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x44e7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3230
movb %r13b, %r14b
addl %r14d, %r12d
leaq 0xc8(%rsp), %rdi
movq 0x3acc(%rip), %rsi      # 0x7fc8
callq 0x32a0
leaq 0x140(%rsp), %rdi
callq 0x30b0
cmpw $0x1, 0x8(%rsp)
movl %ebp, %eax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %r13
je 0x4697
movq 0x10(%rsp), %rbp
movq (%rbp,%r15), %rdi
movq 0x8(%rbp,%r15), %rsi
addq %rdi, %rsi
movl $0x0, 0xc8(%rsp)
leaq 0xc8(%rsp), %rdx
callq 0x4c86
addq %r15, %rbp
movq 0x10(%rsp), %rcx
movq (%rcx,%r15), %rdx
addq 0x8(%rcx,%r15), %rdx
movq (%rbp), %rcx
movq %rax, %rsi
subq %rcx, %rsi
movq 0x8(%rbp), %rdi
addq %rcx, %rdi
cmpq %rdx, %rdi
je 0x4587
subq %rax, %rdx
movq %rbp, %rdi
callq 0x3280
jmp 0x458f
movq %rsi, 0x8(%rbp)
movb $0x0, (%rcx,%rsi)
movq 0x10(%rsp), %rdi
addq %r15, %rdi
movl $0xb, %ecx
leaq 0x1aab(%rip), %rsi      # 0x604e
xorl %edx, %edx
callq 0x3350
cmpq $-0x1, %rax
je 0x467a
movq 0x10(%rsp), %rbp
addq %r15, %rbp
movl $0x1, %ecx
movq %rbp, %rdi
leaq 0x1a8f(%rip), %rsi      # 0x605a
xorl %edx, %edx
callq 0x3350
leaq 0x1(%rax), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3050
movq 0x10(%rsp), %r14
leaq (%r14,%r15), %rbp
movl $0xb, %ecx
movq %rbp, %rdi
leaq 0x1a56(%rip), %rsi      # 0x604e
xorl %edx, %edx
callq 0x3350
addq $0xb, %rax
movq 0x8(%r14,%r15), %rcx
cmpq %rax, %rcx
jb 0x4888
movq %rax, 0x8(%rbp)
movq (%rbp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%rsp), %rdi
addq %r15, %rdi
movl $0x1, %ecx
leaq 0x1a29(%rip), %rsi      # 0x605a
xorl %edx, %edx
callq 0x3350
cmpq $-0x1, %rax
je 0x466a
movq 0x10(%rsp), %rbp
addq %r15, %rbp
movl $0x1, %ecx
movq %rbp, %rdi
leaq 0x1a05(%rip), %rsi      # 0x605a
xorl %edx, %edx
callq 0x3350
leaq 0x1(%rax), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3050
addq 0x10(%rsp), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x3140
incq %rbx
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %rbx
jb 0x4345
cmpl $0x2, %r12d
movq 0x50(%rsp), %rbx
leaq 0x3d0(%rsp), %r12
leaq 0x80(%rsp), %r14
leaq 0x248(%rsp), %r15
leaq 0x60(%rsp), %rbp
jne 0x4805
movq 0x240(%rbx), %rdx
testq %rdx, %rdx
je 0x4805
cmpl $0x0, 0x228(%rbx)
je 0x4805
cmpl $0x0, 0x22c(%rbx)
je 0x4805
movq 0x238(%rbx), %rsi
movq (%rsp), %rdi
callq 0x3260
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1950(%rip), %rsi      # 0x605c
callq 0x3260
movslq 0x228(%rbx), %rcx
imulq $0x68db8bad, %rcx, %rax # imm = 0x68DB8BAD
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x2c, %rax
addl %edx, %eax
movslq 0x220(%rbx), %rsi
imulq $0x68db8bad, %rsi, %rdx # imm = 0x68DB8BAD
movq %rdx, %rdi
shrq $0x3f, %rdi
sarq $0x2c, %rdx
addl %edi, %edx
movb $0x1, %dil
cmpl %edx, %eax
jg 0x47a0
imull $0xffffd8f0, %edx, %edi # imm = 0xFFFFD8F0
addl %esi, %edi
movslq %edi, %rsi
imulq $0x51eb851f, %rsi, %rsi # imm = 0x51EB851F
movq %rsi, %rdi
shrq $0x3f, %rdi
sarq $0x25, %rsi
addl %edi, %esi
imull $0xffffd8f0, %eax, %edi # imm = 0xFFFFD8F0
addl %ecx, %edi
movslq %edi, %rcx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdi
shrq $0x3f, %rdi
sarq $0x25, %rcx
addl %edi, %ecx
cmpl %edx, %eax
cmovll %esi, %ecx
movswl 0x230(%rbx), %eax
addl %esi, %eax
cmpl %eax, %ecx
setg %dil
movl 0x22c(%rbx), %eax
cmpl 0x224(%rbx), %eax
setl %al
orb %dil, %al
testb $0x1, %al
leaq 0x188b(%rip), %rsi      # 0x6046
leaq 0x189c(%rip), %rcx      # 0x605e
cmovneq %rcx, %rsi
movzbl %al, %edx
andl $0x1, %edx
xorq $0x7, %rdx
movq (%rsp), %rdi
callq 0x3260
movq (%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq (%rsp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3150
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4821
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x10(%rsp), %rdi
callq 0x4a62
movq %r15, %rdi
movq 0x3773(%rip), %rsi      # 0x7fa8
callq 0x3180
leaq 0x2c8(%rsp), %rdi
callq 0x30b0
jmp 0x424f
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x4869
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x3d0(%rsp), %rdi
callq 0x5370
addq $0x5d8, %rsp            # imm = 0x5D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1800(%rip), %rdi      # 0x608f
leaq 0x184a(%rip), %rsi      # 0x60e0
movq %rax, %rdx
xorl %eax, %eax
callq 0x32c0
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x49a3
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x49a3
jmp 0x48e3
jmp 0x48d3
jmp 0x48e3
jmp 0x48d3
jmp 0x48e3
movq %rax, %rbx
jmp 0x4971
jmp 0x48e3
jmp 0x48e3
jmp 0x48e3
jmp 0x48e3
movq %rax, %rbx
jmp 0x492a
jmp 0x48ea
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4909
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x36b8(%rip), %rsi      # 0x7fc8
leaq 0xc8(%rsp), %rdi
callq 0x32a0
leaq 0x140(%rsp), %rdi
callq 0x30b0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4946
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x10(%rsp), %rdi
callq 0x4a62
movq 0x3651(%rip), %rsi      # 0x7fa8
leaq 0x248(%rsp), %rdi
callq 0x3180
leaq 0x2c8(%rsp), %rdi
callq 0x30b0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x4996
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3230
leaq 0x3d0(%rsp), %rdi
callq 0x5370
movq %rbx, %rdi
callq 0x3360
nop