// File: npazosmendez[P]branchsearch/branchsearch.cpp
// Function: print_window(char*, std::vector<branch_t*, std::allocator<branch_t*>>, int)
void print_window(char* regex_value, vector<branch_t*> filtered_branches, int selected_branch){
    erase();

    // selection may be out of range because of new regex
    int lines = filtered_branches.size();
    if(lines && selected_branch >= lines) selected_branch = lines - 1;

    init_pair(1, -1, -1);
    init_pair(2, COLOR_RED, -1);

    // print regex
    printw("regex: %s | %d\n\n", regex_value, lines);

    // print branches
    int i = 0;
    for (; i < filtered_branches.size() && i < max_branch_shown; ++i){
        addstr("  ");
        if(i == selected_branch) attrset(COLOR_PAIR(2));
        addstr(filtered_branches[i]->name.c_str());
        if(filtered_branches[i]->remote && not filtered_branches[i]->local)
            addstr(" [R]");
        addstr("\n");
        if(i == selected_branch) attrset(COLOR_PAIR(1));
    }
    if(i < filtered_branches.size()) addstr("...");

    // marker on selected branch
    if(lines > 0) mvaddstr(selected_branch + 2, 0, ">");
    refresh();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x28(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
callq 0x5490
movq -0x28(%rbp), %rdi
callq 0x7c20
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x63df
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x63df
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x1, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x5080
movl $0x2, %edi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5080
movq -0x8(%rbp), %rsi
movl -0x18(%rbp), %edx
leaq 0x30dbd(%rip), %rdi     # 0x371cf
movb $0x0, %al
callq 0x5420
movl $0x0, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x38(%rbp)
callq 0x7c20
movq -0x38(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x29(%rbp)
jae 0x6451
movl -0x1c(%rbp), %eax
cmpl 0x4bff5(%rip), %eax     # 0x52440
setl %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x645d
jmp 0x6556
movq 0x4bb44(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
leaq 0x30d72(%rip), %rsi     # 0x371e0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x6494
movq 0x4bb21(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x54a0
movq -0x28(%rbp), %rdi
movq 0x4bb09(%rip), %rax     # 0x51fa8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movslq -0x1c(%rbp), %rsi
callq 0x7c40
movq (%rax), %rdi
callq 0x51c0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x7c40
movq (%rax), %rax
testb $0x1, 0x21(%rax)
je 0x650f
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x7c40
movq (%rax), %rax
testb $0x1, 0x20(%rax)
jne 0x650f
movq 0x4baad(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
leaq 0x30cde(%rip), %rsi     # 0x371e3
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
movq 0x4ba92(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
leaq 0x30cbe(%rip), %rsi     # 0x371de
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x6546
movq 0x4ba6f(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x54a0
jmp 0x6548
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6420
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x7c20
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x658e
movq 0x4ba2e(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
leaq 0x30c64(%rip), %rsi     # 0x371e8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
cmpl $0x0, -0x18(%rbp)
jle 0x65cd
movq 0x4ba0d(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
movl -0x14(%rbp), %esi
addl $0x2, %esi
xorl %edx, %edx
callq 0x5460
cmpl $-0x1, %eax
jne 0x65b2
jmp 0x65cd
movq 0x4b9ef(%rip), %rax     # 0x51fa8
movq (%rax), %rdi
leaq 0x30c29(%rip), %rsi     # 0x371ec
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5140
callq 0x5730
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)