// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %r14
pushq %rbx
movl 0x100c(%rdi), %ecx
leal 0x2(%rcx), %esi
xorl %r8d, %r8d
cmpl $-0x1, %ecx
cmovnel %esi, %r8d
movl 0x1004(%rdi), %edx
leal -0x3(%rdx), %eax
cmpl %r8d, %eax
setl %r9b
jl 0x55c2
movl 0x1000(%rdi), %ebx
leal (%rbx,%rax), %r10d
cmpl $0x1000, %r10d          # imm = 0x1000
leal -0x1000(%rbx,%rax), %r11d
cmovbl %r10d, %r11d
cmpb $0xa, (%rdi,%r11)
je 0x55c2
leal -0x1(%r8), %r10d
leal (%rdx,%rbx), %r11d
addl $-0x4, %r11d
addl %edx, %ebx
addl $0xffffeffc, %ebx       # imm = 0xFFFFEFFC
cmpl %r8d, %eax
setle %r9b
jle 0x55bf
decl %eax
cmpl $0x1000, %r11d          # imm = 0x1000
movl %r11d, %r14d
cmovael %ebx, %r14d
decl %r11d
decl %ebx
cmpb $0xa, (%rdi,%r14)
jne 0x5598
jmp 0x55c2
movl %r10d, %eax
cmpl $-0x1, %ecx
je 0x55d7
testb %r9b, %r9b
je 0x55d7
movl %esi, 0x1004(%rdi)
jmp 0x56d4
testb %r9b, %r9b
je 0x5636
leal -0x2(%rdx), %eax
movl %eax, 0x100c(%rdi)
movl %eax, 0x1008(%rdi)
movl 0x1000(%rdi), %eax
leal (%rax,%rdx), %ecx
addl $-0x2, %ecx
movl $0x1000, %esi           # imm = 0x1000
cmpl %esi, %ecx
leal -0x1002(%rax,%rdx), %eax
cmovbl %ecx, %eax
movb $-0x1, %cl
movb %cl, (%rdi,%rax)
movl 0x1000(%rdi), %eax
movl 0x100c(%rdi), %edx
leal (%rdx,%rax), %r8d
incl %r8d
cmpl %esi, %r8d
leal -0xfff(%rdx,%rax), %eax
cmovbl %r8d, %eax
movb %cl, (%rdi,%rax)
jmp 0x56d4
incl %eax
cmpl $-0x1, %ecx
je 0x567d
movl 0x1000(%rdi), %edx
leal (%rdx,%rcx), %esi
movl $0x1000, %r8d           # imm = 0x1000
cmpl %r8d, %esi
leal -0x1000(%rdx,%rcx), %ecx
cmovbl %esi, %ecx
movb %al, (%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 %ah, (%rdi,%rcx)
movl %eax, 0x100c(%rdi)
cmpl $-0x1, 0x1008(%rdi)
jne 0x5692
movl %eax, 0x1008(%rdi)
addl 0x1000(%rdi), %eax
movl $0xfffff000, %ecx       # imm = 0xFFFFF000
leal (%rax,%rcx), %edx
movl $0x1000, %esi           # imm = 0x1000
cmpl %esi, %eax
cmovbl %eax, %edx
movb $-0x1, %al
movb %al, (%rdi,%rdx)
movl 0x1000(%rdi), %edx
addl 0x100c(%rdi), %edx
addl %edx, %ecx
cmpl %esi, %edx
cmovbl %edx, %ecx
movb %al, (%rdi,%rcx)
movl 0x100c(%rdi), %eax
addl $0x2, %eax
movl %eax, 0x1004(%rdi)
popq %rbx
popq %r14
retq