// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movzbl (%rdi), %ebx
movzbl 0x1(%rdi), %r15d
movq %rdi, -0x40(%rbp)
movq 0x8(%rdi), %rdi
callq 0x2080
movq %rax, %r14
callq 0x2d71
movl %ebx, -0x2c(%rbp)
movl %ebx, %edi
movq %r15, -0x38(%rbp)
movl %r15d, %esi
callq 0x2d05
leaq 0x20e2(%rip), %rdi      # 0x5747
xorl %eax, %eax
callq 0x20b0
testl %r14d, %r14d
movl $0x0, %r15d
cmovgl %r14d, %r15d
leaq 0x20cb(%rip), %rbx      # 0x574b
subl $0x1, %r15d
jb 0x3692
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20b0
jmp 0x3680
cmpl $0x8, %r14d
pushq $0x7
popq %r12
cmovgel %r14d, %r12d
leaq 0x20aa(%rip), %rdi      # 0x574f
xorl %eax, %eax
callq 0x20b0
movq -0x38(%rbp), %rax
leal 0x1(%rax), %esi
movl -0x2c(%rbp), %edi
callq 0x2d05
leaq 0x2091(%rip), %rdi      # 0x5753
xorl %eax, %eax
callq 0x20b0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x262e(%rip), %rdi      # 0x5d06
xorl %eax, %eax
callq 0x20b0
movl %r12d, %r15d
subl %r14d, %r15d
pushq $0x20
popq %rbx
testl %r15d, %r15d
jle 0x36f9
movl %ebx, %edi
callq 0x2040
decl %r15d
jmp 0x36e8
leaq 0x2053(%rip), %rdi      # 0x5753
xorl %eax, %eax
callq 0x20b0
movq -0x38(%rbp), %rax
leal 0x2(%rax), %esi
movl -0x2c(%rbp), %edi
callq 0x2d05
leaq 0x2064(%rip), %rdi      # 0x5781
xorl %eax, %eax
callq 0x20b0
leaq 0x2020(%rip), %rbx      # 0x574b
movl %r12d, %r14d
subl $0x1, %r14d
jb 0x3740
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20b0
jmp 0x372e
leaq 0x203e(%rip), %rdi      # 0x5785
xorl %eax, %eax
callq 0x20b0
addq $0x10, -0x40(%rbp)
movq -0x38(%rbp), %rax
addl $0x3, %eax
movq %rax, -0x50(%rbp)
leaq 0x1fee(%rip), %r15      # 0x5753
pushq $0x20
popq %r14
xorl %r13d, %r13d
cmpq $0x5, %r13
je 0x3834
imulq $0x7, %r13, %rdi
addq -0x40(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0x2080
movq %rax, %rbx
movq -0x50(%rbp), %rax
movq %r13, -0x48(%rbp)
leal (%rax,%r13), %esi
movl -0x2c(%rbp), %edi
callq 0x2d05
movq %r15, %rdi
xorl %eax, %eax
callq 0x20b0
movl %r12d, %eax
movq %rbx, -0x60(%rbp)
subl %ebx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r15d
testl %eax, %eax
movl $0x0, %eax
cmovlel %eax, %r15d
movl %r15d, %r13d
subl $0x1, %r13d
jb 0x37d8
movl %r14d, %edi
callq 0x2040
jmp 0x37c8
movq -0x60(%rbp), %rbx
testl %ebx, %ebx
jle 0x37f7
leaq 0x251f(%rip), %rdi      # 0x5d06
movq -0x58(%rbp), %rsi
xorl %eax, %eax
callq 0x20b0
addl %ebx, %r15d
jmp 0x3805
leaq 0x1f8b(%rip), %rdi      # 0x5789
xorl %eax, %eax
callq 0x20b0
movq -0x48(%rbp), %r13
cmpl %r12d, %r15d
jge 0x381b
movl %r14d, %edi
callq 0x2040
incl %r15d
jmp 0x3809
leaq 0x1f31(%rip), %r15      # 0x5753
movq %r15, %rdi
xorl %eax, %eax
callq 0x20b0
incq %r13
jmp 0x376c
movq -0x38(%rbp), %rsi
addl $0x8, %esi
movl -0x2c(%rbp), %edi
callq 0x2d05
leaq 0x1f0d(%rip), %rdi      # 0x5757
xorl %eax, %eax
callq 0x20b0
leaq 0x1ef3(%rip), %rbx      # 0x574b
subl $0x1, %r12d
jb 0x386a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x20b0
jmp 0x3858
leaq 0x1eea(%rip), %rdi      # 0x575b
xorl %eax, %eax
callq 0x20b0
movq 0x5749(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x2160
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d82