// File: /workspace/github_c_makefile_star2_O2/ajpaulson[P]srogue11/rip.c
// Function: showtop
bool showtop(int showname)
{
	int fd, i;
	char *killer;
	struct sc_ent *scp;

	if ((fd = open(scorefile, O_RDONLY)) < 0)
		return FALSE;
       
        for(i = 0; i < 10; i++)
        {
            unsigned int mon;
            encread((char *) &top_ten[i].sc_name, LINLEN, fd);
            encread((char *) scoreline, 100, fd);
            sscanf(scoreline, " %d %d %d %d %u %d %ld %lx \n",
                &top_ten[i].sc_score,   &top_ten[i].sc_flags,
                &top_ten[i].sc_level,   &top_ten[i].sc_uid,
                &mon,                   &top_ten[i].sc_explvl,
                &top_ten[i].sc_exppts,  &top_ten[i].sc_date);
            top_ten[i].sc_monster = mon;
        }
	close(fd);
	printf("Top Ten Adventurers:\nRank\tScore\tName\n");
	for (scp = top_ten; scp <= &top_ten[9]; scp++) {
		if (scp->sc_score > 0) {
			printf("%ld\t%d\t%s: %s\t\t--> %s on level %d",
			  scp - top_ten + 1, scp->sc_score, scp->sc_name,
			  ctime(&scp->sc_date), reason[scp->sc_flags],
			  scp->sc_level);
			if (scp->sc_flags == KILLED) {
				killer = killname(scp->sc_monster);
				printf(" by a%s %s",vowelstr(killer), killer);
			}
			printf(" [Exp: %d/%ld]",scp->sc_explvl,scp->sc_exppts);
			if (showname) {
				struct passwd *pp, *getpwuid();

				if ((pp = getpwuid(scp->sc_uid)) == NULL)
					printf(" (%d)\n", scp->sc_uid);
				else
					printf(" (%s)\n", pp->pw_name);
			}
			else
				printf("\n");
		}
	}
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, 0x10(%rsp)
leaq 0x1b770(%rip), %rdi     # 0x2e010
xorl %esi, %esi
xorl %eax, %eax
callq 0x6430
movl %eax, 0xc(%rsp)
testl %eax, %eax
js 0x12a6f
leaq 0x20604(%rip), %r13     # 0x32ec0
leaq 0x20aad(%rip), %r15     # 0x33370
leaq 0xd5d0(%rip), %r14      # 0x1fe9a
xorl %r12d, %r12d
cmpq $0x4b0, %r12            # imm = 0x4B0
je 0x1294b
leaq (%r12,%r13), %rbx
leaq (%r12,%r13), %rdi
addq $0x4, %rdi
pushq $0x50
popq %rsi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
callq 0x146da
movq %r15, %rdi
pushq $0x64
popq %rsi
movl %ebp, %edx
callq 0x146da
leaq (%r12,%r13), %rcx
addq $0x54, %rcx
leaq 0x58(%r12,%r13), %r8
leaq 0x5c(%r12,%r13), %r9
leaq 0x64(%r12,%r13), %r10
leaq 0x68(%r12,%r13), %r11
leaq 0x70(%r12,%r13), %rbp
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
pushq %rbp
pushq %r11
pushq %r10
leaq 0x2c(%rsp), %r10
pushq %r10
callq 0x6350
addq $0x20, %rsp
movb 0x14(%rsp), %al
movb %al, -0x10(%rbp)
addq $0x78, %r12
jmp 0x128cd
movl 0xc(%rsp), %edi
callq 0x6220
leaq 0xdbb7(%rip), %rdi      # 0x20512
callq 0x60f0
pushq $0x1
popq %r14
xorl %ebp, %ebp
cmpq $0x438, %rbp            # imm = 0x438
ja 0x12a6f
movl (%rbp,%r13), %r12d
testl %r12d, %r12d
jle 0x12a63
leaq 0x4(,%r13), %rbx
addq %rbp, %rbx
leaq 0x70(,%r13), %r15
addq %rbp, %r15
movq %r15, %rdi
callq 0x6160
movslq -0x1c(%r15), %rcx
leaq 0x1aaf6(%rip), %rdx     # 0x2d4a0
movq (%rdx,%rcx,8), %r9
movl -0x18(%r15), %r10d
subq $0x8, %rsp
leaq 0xd4fa(%rip), %rdi      # 0x1feb7
movq %r14, %rsi
movl %r12d, %edx
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
pushq %r10
callq 0x61c0
popq %rcx
popq %rdx
cmpl $0x0, -0x1c(%r15)
jne 0x12a05
movzbl 0x60(%rbp,%r13), %edi
callq 0x121ef
movq %rax, %rbx
movq %rax, %rdi
callq 0xcb3d
leaq 0xd4e1(%rip), %rdi      # 0x1fed9
movq %rax, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x61c0
movl 0x64(%rbp,%r13), %esi
movq 0x68(%rbp,%r13), %rdx
leaq 0xd4ce(%rip), %rdi      # 0x1fee4
xorl %eax, %eax
callq 0x61c0
cmpl $0x0, 0x10(%rsp)
je 0x12a46
movl 0x5c(%rbp,%r13), %edi
callq 0x6150
testq %rax, %rax
je 0x12a50
movq (%rax), %rsi
leaq 0xd4bd(%rip), %rdi      # 0x1fefa
xorl %eax, %eax
callq 0x61c0
jmp 0x12a63
pushq $0xa
popq %rdi
callq 0x6060
jmp 0x12a63
movl 0x5c(%rbp,%r13), %esi
leaq 0xd497(%rip), %rdi      # 0x1fef3
xorl %eax, %eax
callq 0x61c0
addq $0x78, %rbp
incq %r14
jmp 0x12966
cmpl $0x0, 0xc(%rsp)
setns %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq