// File: /workspace/github_cpp_makefile_star2_O3/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 0x2428
movq %rsi, %r14
movq 0x8(%rsi), %rbx
leaq 0x1c3b(%rip), %rdi      # 0x4010
movq %rbx, %rsi
callq 0x21e0
testl %eax, %eax
je 0x26de
movzbl (%rbx), %eax
subl $0x2d, %eax
jne 0x23fa
movzbl 0x1(%rbx), %eax
subl $0x68, %eax
jne 0x23fa
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x26de
movq %rbx, %rdi
callq 0x20d0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x2210
cmpq $0x0, 0x48(%rsp)
jne 0x2491
leaq 0x1c01(%rip), %rdi      # 0x4030
callq 0x21c0
testq %rax, %rax
leaq 0x1bf7(%rip), %rbx      # 0x4035
cmovneq %rax, %rbx
movq %rbx, %rdi
callq 0x20d0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x2210
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x2480
leaq 0x1bc1(%rip), %rsi      # 0x4037
leaq 0x40(%rsp), %rdi
callq 0x2270
leaq 0x1b7d(%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 0x1b67(%rip), %rsi      # 0x4039
leaq 0x1b6d(%rip), %rdx      # 0x4046
leaq 0x120(%rsp), %rdi
callq 0x2dfc
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 0x271a
leaq 0x150(%rsp), %rdi
callq 0x2060
xorl %edi, %edi
callq 0x2160
leaq 0x98(%rsp), %rdi
movq %rax, (%rdi)
callq 0x2120
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movaps %xmm0, 0xa0(%rsp)
movaps %xmm1, 0xb0(%rsp)
movaps %xmm2, 0xc0(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0xd0(%rsp)
leaq 0x60(%rsp), %r14
leaq 0x140(%rsp), %r12
leaq 0x1ad3(%rip), %r13      # 0x4058
leaq 0x1afd(%rip), %rbx      # 0x4089
xorl %ebp, %ebp
movaps 0xa0(%rsp), %xmm0
movaps 0xb0(%rsp), %xmm1
movaps 0xc0(%rsp), %xmm2
movaps %xmm0, 0x60(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x90(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm1, 0x70(%rsp)
addl %ebp, 0x6c(%rsp)
movq %r14, %rdi
callq 0x2100
movq 0x100(%rsp), %r15
movq 0x108(%rsp), %rax
cmpq %rax, %r15
je 0x2670
movl 0x70(%rsp), %ecx
cmpl 0x10(%r15), %ecx
jne 0x2667
movl 0x6c(%rsp), %ecx
cmpl 0xc(%r15), %ecx
jne 0x2667
movl $0x10, %esi
movq %r12, %rdi
leaq 0x1a45(%rip), %rdx      # 0x4055
movq %r14, %rcx
callq 0x2140
movq 0x38(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2040
testl %ebp, %ebp
je 0x263f
leaq 0x1a46(%rip), %rdi      # 0x407a
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x264d
leaq 0x1a29(%rip), %rdi      # 0x406f
xorl %eax, %eax
callq 0x2040
movl 0x74(%rsp), %esi
subl 0x14(%r15), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2040
movq 0x108(%rsp), %rax
addq $0x58, %r15
jmp 0x25e4
incl %ebp
cmpl 0x30(%rsp), %ebp
jbe 0x258e
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2698
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
leaq 0x50(%rsp), %r15
je 0x26c2
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x150(%rsp), %rdi
callq 0x2080
leaq 0x100(%rsp), %rdi
callq 0x2cfc
jmp 0x26ef
movq (%r14), %rsi
leaq 0x192f(%rip), %rdi      # 0x4017
xorl %eax, %eax
callq 0x2040
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x2706
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 0xa0(%rsp), %r13
leaq 0x1907(%rip), %rbp      # 0x4047
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2260
cmpq $0x0, 0x18(%rsp)
je 0x29c3
movq 0x10(%rsp), %rbx
movzbl (%rbx), %eax
cmpl $0x3b, %eax
je 0x29c3
cmpl $0x23, %eax
je 0x29c3
movq 0x128(%rsp), %r14
testq %r14, %r14
je 0x28f2
movq 0x120(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x21a0
testl %eax, %eax
je 0x28f2
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x140(%rsp), %rdx
leaq 0x98(%rsp), %rcx
leaq 0x3c(%rsp), %r8
xorl %eax, %eax
callq 0x2170
cmpl $0x3, %eax
jne 0x29c3
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movl 0x140(%rsp), %eax
movl $0xfffff894, %ecx       # imm = 0xFFFFF894
addl %ecx, %eax
movl %eax, 0x74(%rsp)
movl 0x98(%rsp), %eax
decl %eax
movl %eax, 0x70(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x6c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x2100
cmpq $-0x1, %rax
je 0x29b4
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
movq %r13, %rcx
addq %rbp, %rcx
movq %rbp, %r14
sarq $0x2, %r14
testq %r14, %r14
jle 0x28af
movq %rcx, 0x8(%rsp)
andq $-0x4, %rbp
addq %r13, %rbp
incq %r14
leaq 0x3(%r13), %rbx
movsbl -0x3(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x296b
movsbl -0x2(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2971
movsbl -0x1(%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2977
movsbl (%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x297a
decq %r14
addq $0x4, %rbx
cmpq $0x1, %r14
jg 0x2858
movq 0x8(%rsp), %rcx
jmp 0x28b2
movq %r13, %rbp
movq %rcx, %rax
subq %rbp, %rax
cmpq $0x1, %rax
je 0x2996
cmpq $0x2, %rax
je 0x2981
cmpq $0x3, %rax
jne 0x29b4
movq %rcx, %r14
movsbl (%rbp), %edi
callq 0x2050
testl %eax, %eax
jne 0x29a8
incq %rbp
jmp 0x2984
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x21b0
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2937
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x2190
cmpq $0x0, 0x18(%rsp)
je 0x29c3
movq 0x10(%rsp), %rax
movb (%rax), %bl
movsbl %bl, %edi
callq 0x2050
testl %eax, %eax
je 0x29e2
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
jmp 0x2937
addq $-0x3, %rbx
jmp 0x297a
addq $-0x2, %rbx
jmp 0x297a
decq %rbx
movq 0x8(%rsp), %r14
jmp 0x29ab
movq %rcx, %r14
movsbl (%rbp), %edi
callq 0x2050
testl %eax, %eax
jne 0x29a8
incq %rbp
jmp 0x2999
movq %rcx, %r14
movsbl (%rbp), %edi
callq 0x2050
testl %eax, %eax
cmoveq %r14, %rbp
movq %rbp, %rbx
cmpq %rbx, %r14
jne 0x2a52
leaq 0xa0(%rsp), %r13
leaq 0x1684(%rip), %rbp      # 0x4047
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x170(%rsp,%rax)
je 0x2740
jmp 0x251e
cmpb $0x3d, %bl
jne 0x29c3
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
cmpq $0x0, 0x18(%rsp)
je 0x29c3
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, 0xa0(%rsp)
je 0x2bad
movl (%rbx), %eax
testl %eax, %eax
je 0x2ba2
cmpl $0x22, %eax
jne 0x29c3
jmp 0x2bb9
subq %r13, %rbx
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0x21b0
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2aa2
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x159e(%rip), %rbp      # 0x4047
cmpq $0x0, 0x18(%rsp)
je 0x2ae6
movq 0x10(%rsp), %rax
movsbl (%rax), %edi
callq 0x2050
testl %eax, %eax
je 0x2ae6
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2070
jmp 0x2aa9
decq %rbx
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2070
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %rbx
testq %rbx, %rbx
je 0x2b04
movsbl -0x1(%r14,%rbx), %edi
callq 0x2050
testl %eax, %eax
jne 0x2ad3
movq 0x90(%rsp), %rax
movq %rax, 0xd0(%rsp)
movaps 0x60(%rsp), %xmm0
movaps 0x70(%rsp), %xmm1
movaps 0x80(%rsp), %xmm2
movaps %xmm2, 0xc0(%rsp)
movaps %xmm1, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
addq %r14, %rbx
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2d66
leaq 0x100(%rsp), %rdi
movq %r13, %rsi
callq 0x2ca0
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x29c3
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x29c3
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
jmp 0x29c3
leaq 0x14e9(%rip), %rdi      # 0x409d
callq 0x20f0
leaq 0x14dd(%rip), %rdi      # 0x409d
callq 0x21f0
movq %rax, %r14
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c21
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x2c21
jmp 0x2c1e
jmp 0x2c1e
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x2c21
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
jmp 0x2c21
jmp 0x2c1e
jmp 0x2c1e
jmp 0x2c1e
jmp 0x2c1e
jmp 0x2c1e
movq %rax, %r14
jmp 0x2c62
movq %rax, %r14
jmp 0x2c6f
movq %rax, %r14
jmp 0x2c7c
jmp 0x2c1e
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2c3d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x2c62
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x150(%rsp), %rdi
callq 0x2080
leaq 0x100(%rsp), %rdi
callq 0x2cfc
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2c98
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2190
movq %r14, %rdi
callq 0x2240