// File: /workspace/github_cpp_makefile_star2_O3/JohnPapad[P]Mini-Search-Engine/minisearch.cpp
// Function: underline(unsigned int, unsigned int&, int**, int&, bool)
void underline(unsigned int init_llen, unsigned int & curr_llen, int ** underline_info, int & underline_info_size, bool exit)
{//underlining words based on the underline info array

    cout<<endl;
    for(int i = 0; i < *underline_info[0]; i++)
    {//set cursor to the correct spot
        cout<<" ";
    }

    for(int i = 0; i <= underline_info_size - 2; i+=2)
    {
        unsigned int start_ul = *underline_info[i];
        unsigned int end_ul = *underline_info[i+1];

        for(unsigned int j = start_ul; j < end_ul; j++)
        {//underline word
            cout<<"^";
        }

        if(i != (underline_info_size - 2))
        {//if there are more than one words that needs underlining set cursor to the correct spot
            unsigned int start_sp = end_ul;
            unsigned int end_sp = *underline_info[i+2];

            for(unsigned int j = start_sp; j < end_sp; j++)
            {
                cout<<" ";
            }
        }
    }

    for(int i = 0; i < underline_info_size; i++)
    {
        free(underline_info[i]);
    }

    underline_info = NULL;
    underline_info_size = 0;

    if(exit == 0)
    {// if there are more words to be printed set cursor to the correct spot
        init_newline(init_llen, curr_llen);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x14(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movl %edi, 0x10(%rsp)
movq 0x4d1c(%rip), %rbx      # 0x7fd0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
movq (%r15), %rax
cmpl $0x0, (%rax)
jle 0x330c
xorl %ebp, %ebp
movq 0x4ce4(%rip), %rbx      # 0x7fd0
leaq 0x222e(%rip), %r13      # 0x5521
movl $0x1, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2120
incl %ebp
movq (%r15), %rax
cmpl (%rax), %ebp
jl 0x32f3
movq %r14, 0x8(%rsp)
movl (%r14), %eax
cmpl $0x2, %eax
jl 0x33b9
xorl %r14d, %r14d
movq 0x4ca9(%rip), %r13      # 0x7fd0
leaq 0x1f75(%rip), %rbx      # 0x52a3
leaq 0x21ec(%rip), %rbp      # 0x5521
movq %r15, 0x18(%rsp)
movq (%r15,%r14,8), %rcx
movq 0x8(%r15,%r14,8), %rdx
movl (%rdx), %r15d
movl %r15d, %r12d
subl (%rcx), %r12d
jbe 0x336a
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2120
decl %r12d
jne 0x334e
movq 0x8(%rsp), %rax
movl (%rax), %eax
leal -0x2(%rax), %ecx
cmpq %rcx, %r14
jne 0x3379
movq 0x18(%rsp), %r15
jmp 0x33ad
movq 0x18(%rsp), %rsi
movq 0x10(%rsi,%r14,8), %rdx
movl (%rdx), %r12d
subl %r15d, %r12d
movq %rsi, %r15
jbe 0x33ad
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2120
decl %r12d
jne 0x338e
movq 0x8(%rsp), %rax
movl (%rax), %eax
leal -0x2(%rax), %ecx
addq $0x2, %r14
movslq %ecx, %rcx
cmpq %rcx, %r14
jle 0x333a
testl %eax, %eax
movq 0x8(%rsp), %r14
jle 0x33d8
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x2140
incq %rbx
movslq (%r14), %rax
cmpq %rax, %rbx
jl 0x33c4
movl $0x0, (%r14)
cmpb $0x0, 0x14(%rsp)
je 0x33f5
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%rsp), %edi
movq 0x20(%rsp), %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3411