// File: /workspace/github_cpp_makefile_star2_O1/aquirel[P]reminder/reminder.cpp
// Function: main
int main(int argc, char *argv[])
{
    const char *rc_file_name = ".reminderrc";
    string rc_file_path;

    if (2 <= argc)
    {
        if (0 == strcmp("--help", argv[1]) ||
            0 == strcmp("-h", argv[1]))
        {
            printf("Usage: %s [.reminderrc]\n", argv[0]);
            return 0;
        }
        else
        {
            rc_file_path = argv[1];
        }
    }

    if (0 == rc_file_path.length())
    {
        rc_file_path = getenv("HOME") ?: ".";

        if ('/' != rc_file_path.back())
        {
            rc_file_path.append("/");
        }

        rc_file_path.append(rc_file_name);
    }

    vector<Person> persons;
    unsigned remind_before = 3; // In days.

    ifstream rc_file(rc_file_path);

    string remind_before_prefix = "remind_before",
           buf;

    while (rc_file.good())
    {
        getline(rc_file, buf, '\n');

        if (0 == buf.length() ||
            '#' == buf[0] ||
            ';' == buf[0])
        {
            continue;
        }

        if (equal(remind_before_prefix.begin(), remind_before_prefix.end(), buf.begin()))
        {
            buf = buf.substr(remind_before_prefix.length());
            while (0 < buf.length() && isspace(buf[0]))
            {
                buf.erase(0, 1);
            }

            if (0 < buf.length() && '=' == buf[0])
            {
                buf.erase(0, 1);

                if (0 < buf.length())
                {
                    remind_before = stoul(buf);
                }
            }
        }
        else
        {
            unsigned year, month, day;
            if (3 != sscanf(buf.c_str(), "%4u-%02u-%02u", &year, &month, &day))
            {
                continue;
            }

            tm birthday;
            memset(&birthday, 0, sizeof(birthday));

            birthday.tm_year = year - 1900;
            birthday.tm_mon = month - 1;
            birthday.tm_mday = day;

            if (-1 == mktime(&birthday))
            {
                continue;
            }

            auto delimiter = find_if(buf.begin(), buf.end(), [] (const char c) { return isspace(c); });
            if (buf.end() == delimiter)
            {
                continue;
            }

            buf = buf.substr(delimiter - buf.begin());

            while (0 < buf.length() && isspace(buf[0]))
            {
                buf.erase(0, 1);
            }

            while (0 < buf.length() && isspace(buf.back()))
            {
                buf.erase(buf.length() - 1, 1);
            }

            Person new_person {
                .birthday = birthday,
                .name = buf
            };

            persons.push_back(new_person);
        }
    }

    rc_file.close();

    time_t time_since_epoch = time(nullptr);
    tm now = *localtime(&time_since_epoch);

    for (unsigned shift = 0; shift <= remind_before; ++shift)
    {
        tm birthday = now;
        birthday.tm_mday += shift;
        mktime(&birthday);

        for (auto person = persons.begin(); person != persons.end(); ++person)
        {
            if (birthday.tm_mon == person->birthday.tm_mon &&
                birthday.tm_mday == person->birthday.tm_mday)
            {
                char buf[16];
                strftime(buf, sizeof(buf), "%F", &birthday);

                printf("%s has birthday on %s ", person->name.c_str(), buf);

                if (0 == shift)
                {
                    printf("(TODAY!). ");
                }
                else
                {
                    printf("(in %u days). ", shift);
                }

                printf("He/she becomes %u.\n", birthday.tm_year - person->birthday.tm_year);
            }
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
cmpl $0x2, %edi
jl 0x2418
movq %rsi, %r14
movq 0x8(%rsi), %rbx
leaq 0x1c3b(%rip), %rdi      # 0x4010
movq %rbx, %rsi
callq 0x21e0
testl %eax, %eax
je 0x26d7
leaq 0x1c2b(%rip), %rdi      # 0x4017
movq %rbx, %rsi
callq 0x21e0
testl %eax, %eax
je 0x26d7
movq %rbx, %rdi
callq 0x20d0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x2210
movq 0x48(%rsp), %rbx
testq %rbx, %rbx
jne 0x248c
leaq 0x1c0a(%rip), %rdi      # 0x4033
callq 0x21c0
testq %rax, %rax
leaq 0x1c00(%rip), %r14      # 0x4038
cmovneq %rax, %r14
movq %r14, %rdi
callq 0x20d0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x2210
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x247b
leaq 0x1bc9(%rip), %rsi      # 0x403a
leaq 0x40(%rsp), %rdi
callq 0x2270
leaq 0x1b82(%rip), %rsi      # 0x4004
leaq 0x40(%rsp), %rdi
callq 0x2270
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
movq $0x0, 0x110(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x8, %edx
callq 0x2220
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1b6f(%rip), %rsi      # 0x403c
leaq 0x1b75(%rip), %rdx      # 0x4049
leaq 0x120(%rsp), %rdi
callq 0x2e06
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
movl $0x3, %ecx
movq %rcx, 0x30(%rsp)
cmpl $0x0, 0x170(%rsp,%rax)
je 0x2713
leaq 0x150(%rsp), %rdi
callq 0x2060
xorl %edi, %edi
callq 0x2160
leaq 0xf8(%rsp), %rdi
movq %rax, (%rdi)
callq 0x2120
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0x90(%rsp)
leaq 0xc0(%rsp), %r14
leaq 0x140(%rsp), %r12
leaq 0x1ade(%rip), %r13      # 0x405b
leaq 0x1b08(%rip), %rbx      # 0x408c
xorl %ebp, %ebp
movaps 0x60(%rsp), %xmm0
movaps 0x70(%rsp), %xmm1
movaps 0x80(%rsp), %xmm2
movaps %xmm0, 0xc0(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0xf0(%rsp)
movaps %xmm2, 0xe0(%rsp)
movaps %xmm1, 0xd0(%rsp)
addl %ebp, 0xcc(%rsp)
movq %r14, %rdi
callq 0x2100
movq 0x100(%rsp), %r15
cmpq 0x108(%rsp), %r15
je 0x2669
movl 0xd0(%rsp), %eax
cmpl 0x10(%r15), %eax
jne 0x2660
movl 0xcc(%rsp), %eax
cmpl 0xc(%r15), %eax
jne 0x2660
movl $0x10, %esi
movq %r12, %rdi
leaq 0x1a4a(%rip), %rdx      # 0x4058
movq %r14, %rcx
callq 0x2140
movq 0x38(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2040
testl %ebp, %ebp
je 0x263d
leaq 0x1a4b(%rip), %rdi      # 0x407d
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x264b
leaq 0x1a2e(%rip), %rdi      # 0x4072
xorl %eax, %eax
callq 0x2040
movl 0xd4(%rsp), %esi
subl 0x14(%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2040
addq $0x58, %r15
jmp 0x25d7
incl %ebp
cmpl 0x30(%rsp), %ebp
jbe 0x2586
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2691
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
leaq 0x50(%rsp), %r15
je 0x26bb
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x150(%rsp), %rdi
callq 0x2080
leaq 0x100(%rsp), %rdi
callq 0x2d10
jmp 0x26e8
movq (%r14), %rsi
leaq 0x1939(%rip), %rdi      # 0x401a
xorl %eax, %eax
callq 0x2040
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x26ff
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2190
xorl %eax, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, %eax
movq %rax, 0x30(%rsp)
leaq 0x150(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0x60(%rsp), %r13
leaq 0x1914(%rip), %rbp      # 0x404a
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2260
cmpq $0x0, 0x18(%rsp)
je 0x2a57
movq 0x10(%rsp), %rbx
movzbl (%rbx), %eax
cmpl $0x3b, %eax
je 0x2a57
cmpl $0x23, %eax
je 0x2a57
movq 0x128(%rsp), %r14
testq %r14, %r14
je 0x2904
movq 0x120(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x21a0
testl %eax, %eax
je 0x2904
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x140(%rsp), %rdx
leaq 0xf8(%rsp), %rcx
leaq 0x3c(%rsp), %r8
xorl %eax, %eax
callq 0x2170
cmpl $0x3, %eax
jne 0x2a57
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
movl 0x140(%rsp), %eax
movl $0xfffff894, %ecx       # imm = 0xFFFFF894
addl %ecx, %eax
movl %eax, 0xd4(%rsp)
movl 0xf8(%rsp), %eax
decl %eax
movl %eax, 0xd0(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0xcc(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x2100
cmpq $-0x1, %rax
je 0x2a50
movq %r15, %r13
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rax
leaq (%rax,%rbp), %rcx
movq %rax, %r15
sarq $0x2, %r15
movq %rbp, %r14
testq %r15, %r15
movq %rcx, 0x8(%rsp)
jle 0x28bc
andq $-0x4, %rax
movq %rax, %r14
addq %rbp, %r14
incq %r15
leaq 0x3(%rbp), %rbx
movsbl -0x3(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2970
movsbl -0x2(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2976
movsbl -0x1(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x297c
movsbl (%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x297f
decq %r15
addq $0x4, %rbx
cmpq $0x1, %r15
jg 0x2867
movq 0x8(%rsp), %rcx
movq %rcx, %rax
subq %r14, %rax
cmpq $0x1, %rax
je 0x29ac
cmpq $0x2, %rax
movq %r13, %r15
je 0x2989
movq %rcx, %rbx
cmpq $0x3, %rax
leaq 0x60(%rsp), %r13
jne 0x2a4b
movsbl (%r14), %edi
callq 0x2050
testl %eax, %eax
jne 0x299f
incq %r14
jmp 0x298e
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x21b0
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2940
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x18(%rsp), %rbx
testq %rbx, %rbx
je 0x2a57
movq 0x10(%rsp), %rax
movsbl (%rax), %edi
callq 0x2050
testl %eax, %eax
je 0x29b6
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
jmp 0x2940
addq $-0x3, %rbx
jmp 0x297f
addq $-0x2, %rbx
jmp 0x297f
decq %rbx
movq %r13, %r15
leaq 0x60(%rsp), %r13
jmp 0x29a2
leaq 0x60(%rsp), %r13
movsbl (%r14), %edi
callq 0x2050
testl %eax, %eax
je 0x2a31
movq %r14, %rbx
movq 0x8(%rsp), %rcx
jmp 0x2a4b
movq %r13, %r15
leaq 0x60(%rsp), %r13
jmp 0x2a34
testq %rbx, %rbx
je 0x2a57
movq 0x10(%rsp), %rax
cmpb $0x3d, (%rax)
jne 0x2a57
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
cmpq $0x0, 0x18(%rsp)
je 0x2a57
movq 0x10(%rsp), %r14
callq 0x2030
movq %rax, %rbx
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x20a0
movq %rax, 0x30(%rsp)
cmpq %r14, 0x60(%rsp)
je 0x2bc1
movl (%rbx), %eax
testl %eax, %eax
je 0x2bb6
cmpl $0x22, %eax
jne 0x2a57
jmp 0x2bcd
incq %r14
movsbl (%r14), %edi
callq 0x2050
testl %eax, %eax
movq 0x8(%rsp), %rcx
cmoveq %rcx, %r14
movq %r14, %rbx
cmpq %rbx, %rcx
jne 0x2a76
leaq 0x15f3(%rip), %rbp      # 0x404a
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x170(%rsp,%rax)
je 0x2736
jmp 0x2519
subq %rbp, %rbx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0x21b0
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2ab5
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x158e(%rip), %rbp      # 0x404a
cmpq $0x0, 0x18(%rsp)
je 0x2af9
movq 0x10(%rsp), %rax
movsbl (%rax), %edi
callq 0x2050
testl %eax, %eax
je 0x2af9
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
jmp 0x2abc
decq %rbx
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2070
movq 0x18(%rsp), %rbx
testq %rbx, %rbx
je 0x2b16
movq 0x10(%rsp), %rax
movsbl -0x1(%rax,%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2ae6
movq 0xf0(%rsp), %rax
movq %rax, 0x90(%rsp)
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movaps %xmm2, 0x80(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x10(%rsp), %rsi
addq %rsi, %rbx
leaq 0x98(%rsp), %rdi
movq %rbx, %rdx
callq 0x2d76
leaq 0x100(%rsp), %rdi
movq %r13, %rsi
callq 0x2cb4
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2a57
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x2a57
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
jmp 0x2a57
leaq 0x14d8(%rip), %rdi      # 0x40a0
callq 0x20f0
leaq 0x14cc(%rip), %rdi      # 0x40a0
callq 0x21f0
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x2c35
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
jmp 0x2c35
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c35
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x2c35
jmp 0x2c32
jmp 0x2c32
jmp 0x2c32
jmp 0x2c32
jmp 0x2c32
jmp 0x2c32
jmp 0x2c32
movq %rax, %r14
jmp 0x2c76
movq %rax, %r14
jmp 0x2c83
movq %rax, %r14
jmp 0x2c90
jmp 0x2c32
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2c51
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x2c76
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x150(%rsp), %rdi
callq 0x2080
leaq 0x100(%rsp), %rdi
callq 0x2d10
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2cac
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2190
movq %r14, %rdi
callq 0x2240