// File: /workspace/github_cpp_makefile_star2_O1/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, 0xc(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x20(%rsp)
movl %edi, 0x8(%rsp)
movq 0x4d07(%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 (%r12), %rax
cmpl $0x0, (%rax)
jle 0x3323
xorl %ebp, %ebp
movq 0x4cce(%rip), %rbx      # 0x7fd0
leaq 0x2218(%rip), %r13      # 0x5521
movl $0x1, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2120
incl %ebp
movq (%r12), %rax
cmpl (%rax), %ebp
jl 0x3309
cmpl $0x2, (%r15)
jl 0x33c8
xorl %r14d, %r14d
movq 0x4c99(%rip), %r13      # 0x7fd0
leaq 0x1f65(%rip), %rbx      # 0x52a3
leaq 0x21dc(%rip), %rbp      # 0x5521
movq %r15, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq (%r12,%r14,8), %rax
movq 0x8(%r12,%r14,8), %rcx
movl (%rcx), %r12d
movl %r12d, %r15d
subl (%rax), %r15d
jbe 0x3378
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2120
decl %r15d
jne 0x3363
movq 0x18(%rsp), %rax
movl (%rax), %eax
addl $-0x2, %eax
cmpq %rax, %r14
je 0x33ae
movq 0x10(%rsp), %rax
movq 0x10(%rax,%r14,8), %rax
movl (%rax), %r15d
subl %r12d, %r15d
jbe 0x33ae
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2120
decl %r15d
jne 0x3399
addq $0x2, %r14
movq 0x18(%rsp), %r15
movslq (%r15), %rax
addq $-0x2, %rax
cmpq %rax, %r14
movq 0x10(%rsp), %r12
jle 0x334f
cmpl $0x0, (%r15)
jle 0x33e4
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x2140
incq %rbx
movslq (%r15), %rax
cmpq %rax, %rbx
jl 0x33d0
movl $0x0, (%r15)
cmpb $0x0, 0xc(%rsp)
je 0x3401
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rsp), %edi
movq 0x20(%rsp), %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x341d