// File: /workspace/github_c_makefile_star2_O1/wierton[P]socket-based-naive-game/client.c
// Function: draw_catalog
void draw_catalog(catalog_t *pcl) {
	int x = pcl->pos.x;
	int y = pcl->pos.y;
	int len = strlen(pcl->title);
	int w = len;
	if(len < USERNAME_SIZE) w = USERNAME_SIZE;

	lock_cursor();
	set_cursor(x, y);
	printf("┌");
	for(int i = 0; i < len; i++)
		printf("─");
	printf("┐");
	set_cursor(x, y + 1);
	printf("│");
	printf("%s", pcl->title);
	for(int i = w - len; i > 0; i--)
		printf(" ");
	printf("│");

	set_cursor(x, y + 2);
	printf("├");
	for(int i = 0; i < w; i++)
		printf("─");
	printf("┤");

	for(int i = 0; i < USER_CNT; i++) {
		int j = 0;
		int ulen = strlen(pcl->records[i]);
		set_cursor(x, y + i + 3);
		printf("│");
		for(; j < (w - ulen) / 2; j++)
			printf(" ");
		if(ulen > 0) {
			printf("%s", pcl->records[i]);
			j += ulen;
		}else{
			printf("\b*");
		}
		for(; j < w; j++)
			printf(" ");
		printf("│");
	}

	set_cursor(x, y + USER_CNT + 3);
	printf("└");
	for(int i = 0; i < w; i++)
		printf("─");
	printf("┘");

	fflush(stdout);

	unlock_cursor();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movzbl (%rdi), %r12d
movzbl 0x1(%rdi), %ebx
movq %rdi, -0x38(%rbp)
movq 0x8(%rdi), %rdi
callq 0x2080
movq %rax, %r14
cmpl $0x8, %r14d
movl $0x7, %r15d
cmovgel %r14d, %r15d
leaq 0x68a7(%rip), %rdi      # 0xa230
callq 0x2200
movq %rbx, -0x40(%rbp)
leal 0x1(%rbx), %esi
incl %r12d
leaq 0x2a8b(%rip), %rdi      # 0x642a
movl %r12d, -0x2c(%rbp)
movl %r12d, %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2d96(%rip), %rdi      # 0x674a
xorl %eax, %eax
callq 0x20b0
testl %r14d, %r14d
jle 0x39d8
leaq 0x2d87(%rip), %r12      # 0x674e
movl %r14d, %ebx
movq %r12, %rdi
xorl %eax, %eax
callq 0x20b0
decl %ebx
jne 0x39ca
leaq 0x2d73(%rip), %rdi      # 0x6752
xorl %eax, %eax
callq 0x20b0
movq -0x40(%rbp), %r12
leal 0x2(%r12), %esi
leaq 0x2a34(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2d4f(%rip), %rdi      # 0x6756
xorl %eax, %eax
callq 0x20b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x32ec(%rip), %rdi      # 0x6d09
xorl %eax, %eax
callq 0x20b0
movl %r15d, %ebx
subl %r14d, %ebx
jle 0x3a3f
incl %ebx
movl $0x20, %edi
callq 0x2040
decl %ebx
cmpl $0x1, %ebx
jg 0x3a2e
leaq 0x2d10(%rip), %rdi      # 0x6756
xorl %eax, %eax
callq 0x20b0
leal 0x3(%r12), %esi
leaq 0x29d1(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2d1a(%rip), %rdi      # 0x6784
xorl %eax, %eax
callq 0x20b0
leaq 0x2cd6(%rip), %r14      # 0x674e
movl %r15d, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x20b0
decl %ebx
jne 0x3a7b
leaq 0x2cf8(%rip), %rdi      # 0x6788
xorl %eax, %eax
callq 0x20b0
addq $0x10, -0x38(%rbp)
leal 0x4(%r12), %eax
movq %rax, -0x48(%rbp)
leaq 0x2caa(%rip), %r12      # 0x6756
xorl %ebx, %ebx
leaq (,%rbx,8), %r14
subq %rbx, %r14
addq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x2080
movq %rax, %r13
movq -0x48(%rbp), %rax
leal (%rax,%rbx), %esi
leaq 0x2954(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
movq %r12, %rdi
xorl %eax, %eax
callq 0x20b0
movl %r15d, %eax
movq %r13, -0x50(%rbp)
subl %r13d, %eax
movl $0x0, %r12d
cmpl $0x2, %eax
jl 0x3b1e
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
movl %r12d, %r13d
movl $0x20, %edi
callq 0x2040
decl %r13d
jne 0x3b0f
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0x3b3f
leaq 0x31dc(%rip), %rdi      # 0x6d09
movq %r14, %rsi
movq %rax, %r14
xorl %eax, %eax
callq 0x20b0
addl %r14d, %r12d
jmp 0x3b5c
leaq 0x2c46(%rip), %rdi      # 0x678c
xorl %eax, %eax
callq 0x20b0
jmp 0x3b5c
movl $0x20, %edi
callq 0x2040
incl %r12d
cmpl %r15d, %r12d
jl 0x3b4f
leaq 0x2bee(%rip), %r12      # 0x6756
movq %r12, %rdi
xorl %eax, %eax
callq 0x20b0
incq %rbx
cmpq $0x5, %rbx
jne 0x3aae
movq -0x40(%rbp), %rsi
addl $0x9, %esi
leaq 0x289d(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2bbc(%rip), %rdi      # 0x675a
xorl %eax, %eax
callq 0x20b0
leaq 0x2ba2(%rip), %rbx      # 0x674e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20b0
decl %r15d
jne 0x3bac
leaq 0x2b9c(%rip), %rdi      # 0x675e
xorl %eax, %eax
callq 0x20b0
movq 0x63f8(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x2160
leaq 0x6651(%rip), %rdi      # 0xa230
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150