// File: /workspace/github_c_makefile_star2_O3/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 0x7a7c
testq %rax, %rax
je 0x4f58
movq %r15, %rdi
callq 0x7a7c
movq %rax, -0x50(%rbp)
movq %rbx, %rdi
callq 0x7eb3
movq %rax, %r13
incq %r13
movq %r15, %rdi
callq 0x6829
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x725c
movq %r15, %rdi
callq 0x60f4
movq %rax, %r12
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x725c
leaq 0x4389(%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 0x4dff
movq %rcx, -0x38(%rbp)
leaq 0x4348(%rip), %rsi      # 0x9131
leaq -0x90(%rbp), %rcx
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3680
jmp 0x4e0b
movb $0x0, (%r14)
movq $0x0, -0x38(%rbp)
subq $0x8, %rsp
leaq 0x4326(%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
addq $0x10, %rsp
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 0x42e6(%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 0x4e84
movswq 0x6(%rdi), %r13
incq %r13
jmp 0x4e8b
movq $-0x1, %r13
cmpq %r15, %r13
jbe 0x4ee5
movq %rbx, %rdi
callq 0x7eb3
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x6820
leaq -0x100(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x70a8
movq 0xf0(%rbx), %rdi
leaq 0x4284(%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 0x4ef6
addq %r15, %r12
subq %r13, %r12
leaq 0x4256(%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 0x4f54
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 0x4f54
testl %r14d, %r14d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovnsl %eax, %r13d
addl %r13d, %r15d
movq 0xf0(%rbx), %rdi
movl %r15d, %esi
xorl %edx, %edx
movl $0x2, %ecx
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