// File: /workspace/github_c_makefile_star2_O2/cglindkamp[P]dfm/src/application.c
// Function: refresh_statusbar
static void refresh_statusbar(struct application *app)
{
	werase(app->status);
	if(listmodel_count(&app->model.listmodel) > 0) {
		size_t count = listmodel_count(&app->model.listmodel);
		size_t pos = listview_getindex(&app->view) + 1;

		size_t dsize = dirmodel_getdirsize(&app->model);
		wchar_t dirsize[INFO_SIZE_DIR_LENGTH + 1];
		filesize_to_string(dirsize, dsize);

		struct marked_stats mstats = dirmodel_getmarkedstats(&app->model);
		wchar_t markedsize[INFO_SIZE_DIR_LENGTH + 1];

		filesize_to_string(markedsize, mstats.size);

		size_t markedstatswidth = snprintf(NULL, 0, " (%zu %ls)", mstats.count, markedsize);
		char markedstats[markedstatswidth + 1];

		if(mstats.count > 0)
			sprintf(markedstats, " (%zu %ls)", mstats.count, markedsize);
		else {
			markedstats[0] = '\0';
			markedstatswidth = 0;
		}

		size_t rightwidth = snprintf(NULL, 0, " %zu/%zu %ls%s", pos, count, dirsize, markedstats);
		char right[rightwidth + 1];

		sprintf(right, " %zu/%zu %ls%s", pos, count, dirsize, markedstats);

		size_t width = getmaxx(app->status);
		if(rightwidth >= width) {
			mvwprintw(app->status, 0, 0, "%s", right + rightwidth - width);
		} else {
			const struct filedata *filedata = dirmodel_getfiledata(&app->model, listview_getindex(&app->view));
			char left [FILEDATA_FORMAT_OUTPUT_BUFFER_SIZE];

			filedata_format_output(filedata, left);
			wprintw(app->status, "%s", left);

			mvwprintw(app->status, 0, width - rightwidth, "%s", right);
		}

		if(markedstatswidth > 0) {
			int colorstart = width - markedstatswidth + 1;
			int colorwidth = markedstatswidth - 1;
			if(colorstart < 0) {
				colorwidth += colorstart;
				colorstart = 0;
			}
			mvwchgat(app->status, 0, colorstart, colorwidth, 0, 2, NULL);
		}
	}
	wrefresh(app->status);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movq 0xf0(%rdi), %rdi
callq 0x30e0
leaq 0x28(%rbx), %r15
movq %r15, %rdi
callq 0x780c
testq %rax, %rax
je 0x4ef2
movq %r15, %rdi
callq 0x780c
movq %rax, -0x50(%rbp)
movq %rbx, %rdi
callq 0x7c20
movq %rax, %r13
incq %r13
movq %r15, %rdi
callq 0x66c9
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x705e
movq %r15, %rdi
callq 0x5f9d
movq %rax, %r12
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x705e
leaq 0x43e6(%rip), %rdx      # 0x9131
xorl %edi, %edi
xorl %esi, %esi
movq %r12, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x32a0
movq %rsp, -0x58(%rbp)
movslq %eax, %rcx
leaq 0x10(%rcx), %rax
andq $-0x10, %rax
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
testq %r12, %r12
movq %r15, -0x40(%rbp)
movq %rbx, -0x48(%rbp)
je 0x4da2
movq %rcx, -0x38(%rbp)
leaq 0x43a5(%rip), %rsi      # 0x9131
leaq -0x90(%rbp), %rcx
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3680
jmp 0x4dae
movb $0x0, (%r14)
movq $0x0, -0x38(%rbp)
subq $0x8, %rsp
leaq 0x4383(%rip), %rdx      # 0x913c
leaq -0x70(%rbp), %r9
xorl %edi, %edi
xorl %esi, %esi
movq %r13, %rcx
movq -0x50(%rbp), %rbx
movq %rbx, %r8
xorl %eax, %eax
pushq %r14
callq 0x32a0
popq %rcx
popq %rdx
movl %eax, -0x2c(%rbp)
movslq %eax, %r15
leaq 0x10(%r15), %rax
andq $-0x10, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movq %r12, %rdi
leaq 0x4345(%rip), %rsi      # 0x913c
movq %r13, %rdx
movq %rbx, %rcx
leaq -0x70(%rbp), %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x3680
movq -0x48(%rbp), %rbx
movq 0xf0(%rbx), %rdi
testq %rdi, %rdi
je 0x4e25
movswq 0x6(%rdi), %r13
incq %r13
jmp 0x4e29
pushq $-0x1
popq %r13
cmpq %r15, %r13
jbe 0x4e83
movq %rbx, %rdi
callq 0x7c20
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x66c0
leaq -0x100(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x6ee0
movq 0xf0(%rbx), %rdi
leaq 0x42e6(%rip), %r15      # 0x9148
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3730
movq 0xf0(%rbx), %rdi
movl %r13d, %edx
subl -0x2c(%rbp), %edx
xorl %esi, %esi
movq %r15, %rcx
jmp 0x4e94
addq %r15, %r12
subq %r13, %r12
leaq 0x42b8(%rip), %rcx      # 0x9148
xorl %esi, %esi
xorl %edx, %edx
movq %r12, %r8
xorl %eax, %eax
callq 0x3260
movq -0x38(%rbp), %r15
testq %r15, %r15
je 0x4eee
subl %r15d, %r13d
leal 0x1(%r13), %r14d
xorl %edx, %edx
testl %r14d, %r14d
cmovgl %r14d, %edx
movq 0xf0(%rbx), %rdi
xorl %esi, %esi
callq 0x3090
cmpl $-0x1, %eax
je 0x4eee
testl %r14d, %r14d
pushq $-0x1
popq %rax
cmovnsl %eax, %r13d
addl %r13d, %r15d
movq 0xf0(%rbx), %rdi
pushq $0x2
popq %rcx
movl %r15d, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x31d0
movq -0x58(%rbp), %rsp
movq 0xf0(%rbx), %rdi
callq 0x3390
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq