// File: /workspace/github_c_makefile_star2_O3/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 0x67c7(%rip), %rdi      # 0xa230
callq 0x2200
movq %rbx, -0x40(%rbp)
leal 0x1(%rbx), %esi
incl %r12d
leaq 0x29ab(%rip), %rdi      # 0x642a
movl %r12d, -0x2c(%rbp)
movl %r12d, %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2cb3(%rip), %rdi      # 0x6747
xorl %eax, %eax
callq 0x20b0
testl %r14d, %r14d
jle 0x3ab8
leaq 0x2ca4(%rip), %r12      # 0x674b
movl %r14d, %ebx
movq %r12, %rdi
xorl %eax, %eax
callq 0x20b0
decl %ebx
jne 0x3aaa
leaq 0x2c90(%rip), %rdi      # 0x674f
xorl %eax, %eax
callq 0x20b0
movq -0x40(%rbp), %r12
leal 0x2(%r12), %esi
leaq 0x2954(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2c6c(%rip), %rdi      # 0x6753
xorl %eax, %eax
callq 0x20b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x3209(%rip), %rdi      # 0x6d06
xorl %eax, %eax
callq 0x20b0
movl %r15d, %ebx
subl %r14d, %ebx
jle 0x3b1f
incl %ebx
movl $0x20, %edi
callq 0x2040
decl %ebx
cmpl $0x1, %ebx
ja 0x3b0e
leaq 0x2c2d(%rip), %rdi      # 0x6753
xorl %eax, %eax
callq 0x20b0
leal 0x3(%r12), %esi
leaq 0x28f1(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2c37(%rip), %rdi      # 0x6781
xorl %eax, %eax
callq 0x20b0
leaq 0x2bf3(%rip), %r14      # 0x674b
movl %r15d, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x20b0
decl %ebx
jne 0x3b5b
leaq 0x2c15(%rip), %rdi      # 0x6785
xorl %eax, %eax
callq 0x20b0
addq $0x10, -0x38(%rbp)
leal 0x4(%r12), %eax
movq %rax, -0x48(%rbp)
leaq 0x2bc7(%rip), %r12      # 0x6753
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 0x2874(%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 0x3bfe
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
movl %r12d, %r13d
movl $0x20, %edi
callq 0x2040
decl %r13d
jne 0x3bef
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0x3c1f
leaq 0x30f9(%rip), %rdi      # 0x6d06
movq %r14, %rsi
movq %rax, %r14
xorl %eax, %eax
callq 0x20b0
addl %r14d, %r12d
jmp 0x3c3c
leaq 0x2b63(%rip), %rdi      # 0x6789
xorl %eax, %eax
callq 0x20b0
jmp 0x3c3c
movl $0x20, %edi
callq 0x2040
incl %r12d
cmpl %r15d, %r12d
jl 0x3c2f
leaq 0x2b0b(%rip), %r12      # 0x6753
movq %r12, %rdi
xorl %eax, %eax
callq 0x20b0
incq %rbx
cmpq $0x5, %rbx
jne 0x3b8e
movq -0x40(%rbp), %rsi
addl $0x9, %esi
leaq 0x27bd(%rip), %rdi      # 0x642a
movl -0x2c(%rbp), %edx
xorl %eax, %eax
callq 0x20b0
leaq 0x2ad9(%rip), %rdi      # 0x6757
xorl %eax, %eax
callq 0x20b0
leaq 0x2abf(%rip), %rbx      # 0x674b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20b0
decl %r15d
jne 0x3c8c
leaq 0x2ab9(%rip), %rdi      # 0x675b
xorl %eax, %eax
callq 0x20b0
movq 0x6318(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x2160
leaq 0x6571(%rip), %rdi      # 0xa230
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150