// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/shutdown.cc
// Function: subproc_buffer::mark_overflow()
void mark_overflow()
    {
        // Try to find the last newline in the buffer
        int begin = 0;
        if (last_overflow != -1) {
            begin = last_overflow + sizeof(int16_t);
        }
        int end = get_length() - 1 - sizeof(int16_t); // -1, then -2 for storage of marker

        int i;
        for (i = end; i >= begin; i--) {
            if ((*this)[i] == '\n') break;
        }

        if (last_overflow != -1 && i < begin) {
            // No new line after existing marker: trim all beyond that marker, don't
            // create a new marker:
            trim_to(last_overflow + sizeof(uint16_t));
            return;
        }

        if (i < begin) {
            // No newline in the whole buffer... we'll put the overflow marker at the end,
            // on the assumption that it is better to output a partial line than it is to
            // discard the entire buffer:
            last_overflow = get_length() - sizeof(int16_t);
            overflow_marker = last_overflow;
            int16_t overflow16 = -1;
            char * overflow16_ptr = reinterpret_cast<char *>(&overflow16);
            *get_ptr(last_overflow + 0) = overflow16_ptr[0];
            *get_ptr(last_overflow + 1) = overflow16_ptr[1];
            return;
        }

        // We found a newline, put the overflow marker just after it:
        int new_overflow = i + 1;
        if (last_overflow != -1) {
            int16_t new_overflow16 = new_overflow;
            char * new_overflow16_ptr = reinterpret_cast<char *>(&new_overflow16);
            *get_ptr(last_overflow + 0) = new_overflow16_ptr[0];
            *get_ptr(last_overflow + 1) = new_overflow16_ptr[1];
        }
        last_overflow = new_overflow;
        if (overflow_marker == -1) {
            overflow_marker = last_overflow;
        }

        int16_t overflow16 = -1;
        char * overflow16_ptr = reinterpret_cast<char *>(&overflow16);
        *get_ptr(last_overflow + 0) = overflow16_ptr[0];
        *get_ptr(last_overflow + 0) = overflow16_ptr[1];
        trim_to(last_overflow + sizeof(int16_t));
    }

// Assembly:
movl 0x100c(%rdi), %edx
leal 0x2(%rdx), %r8d
xorl %r9d, %r9d
cmpl $-0x1, %edx
cmovnel %r8d, %r9d
movl 0x1000(%rdi), %ecx
movl 0x1004(%rdi), %esi
leal -0x3(%rsi), %eax
cmpl %r9d, %eax
jl 0x50da
leal (%rcx,%rax), %r10d
cmpl $0x1000, %r10d          # imm = 0x1000
leal -0x1000(%rcx,%rax), %r11d
cmovbl %r10d, %r11d
cmpb $0xa, (%rdi,%r11)
je 0x50eb
decl %eax
jmp 0x50b3
cmpl $-0x1, %edx
je 0x5199
movl %r8d, 0x1004(%rdi)
retq
pushq %rbx
leal 0x1(%rax), %ebx
cmpl $-0x1, %edx
je 0x5131
leal (%rcx,%rdx), %esi
movl $0x1000, %r8d           # imm = 0x1000
cmpl %r8d, %esi
leal -0x1000(%rcx,%rdx), %ecx
cmovbl %esi, %ecx
leal 0x1(%rax), %edx
movb %dl, (%rdi,%rcx)
movl 0x1000(%rdi), %ecx
movl 0x100c(%rdi), %edx
leal (%rdx,%rcx), %esi
incl %esi
cmpl %r8d, %esi
leal -0xfff(%rdx,%rcx), %ecx
cmovbl %esi, %ecx
movb %bh, (%rdi,%rcx)
movl %ebx, 0x100c(%rdi)
cmpl $-0x1, 0x1008(%rdi)
jne 0x5146
movl %ebx, 0x1008(%rdi)
movl 0x1000(%rdi), %ecx
leal (%rcx,%rax), %edx
incl %edx
movl $0x1000, %esi           # imm = 0x1000
cmpl %esi, %edx
leal -0xfff(%rcx,%rax), %eax
cmovbl %edx, %eax
movb $-0x1, %cl
movb %cl, (%rdi,%rax)
movl 0x1000(%rdi), %eax
movl 0x100c(%rdi), %edx
leal (%rax,%rdx), %r8d
cmpl %esi, %r8d
leal -0x1000(%rax,%rdx), %eax
cmovbl %r8d, %eax
movb %cl, (%rdi,%rax)
movl 0x100c(%rdi), %eax
addl $0x2, %eax
movl %eax, 0x1004(%rdi)
popq %rbx
retq
leal -0x2(%rsi), %eax
movl %eax, 0x100c(%rdi)
movl %eax, 0x1008(%rdi)
leal (%rcx,%rsi), %eax
addl $-0x2, %eax
movl $0x1000, %edx           # imm = 0x1000
cmpl %edx, %eax
leal -0x1002(%rcx,%rsi), %ecx
cmovbl %eax, %ecx
movb $-0x1, %al
movb %al, (%rdi,%rcx)
movl 0x1000(%rdi), %ecx
movl 0x100c(%rdi), %esi
leal (%rsi,%rcx), %r8d
incl %r8d
cmpl %edx, %r8d
leal -0xfff(%rsi,%rcx), %ecx
cmovbl %r8d, %ecx
movb %al, (%rdi,%rcx)
retq
nop