// File: /workspace/github_c_makefile_star2_O1/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 0x1a91d(%rip), %rdi     # 0x2e020
xorl %esi, %esi
xorl %eax, %eax
callq 0x6450
movl %eax, %r13d
testl %eax, %eax
js 0x138e3
leaq 0x1f7b2(%rip), %rbx     # 0x32ed0
leaq 0x1fc5b(%rip), %r14     # 0x33380
leaq 0xe6f6(%rip), %r15      # 0x21e22
xorl %ebp, %ebp
movl %r13d, 0xc(%rsp)
leaq (%rbx,%rbp), %r12
leaq (%rbx,%rbp), %rdi
addq $0x4, %rdi
movl $0x50, %esi
movl %r13d, %edx
callq 0x15700
movq %r14, %rdi
movl $0x64, %esi
movl %r13d, %edx
callq 0x15700
leaq (%rbx,%rbp), %rcx
addq $0x54, %rcx
leaq 0x58(%rbp,%rbx), %r8
leaq 0x5c(%rbp,%rbx), %r9
leaq 0x64(%rbp,%rbx), %r10
leaq 0x68(%rbp,%rbx), %r11
leaq 0x70(%rbp,%rbx), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
pushq %r13
pushq %r11
pushq %r10
leaq 0x2c(%rsp), %r10
pushq %r10
callq 0x6360
addq $0x20, %rsp
movb 0x14(%rsp), %al
movb %al, -0x10(%r13)
movl 0xc(%rsp), %r13d
addq $0x78, %rbp
cmpq $0x4b0, %rbp            # imm = 0x4B0
jne 0x13733
movl %r13d, %edi
callq 0x6230
leaq 0xeccf(%rip), %rdi      # 0x2249a
callq 0x60f0
movl $0x1, %r14d
xorl %ebp, %ebp
movl (%rbp,%rbx), %r12d
testl %r12d, %r12d
jle 0x138cc
leaq (%rbx,%rbp), %r15
addq $0x4, %r15
leaq (%rbx,%rbp), %r13
addq $0x70, %r13
movq %r13, %rdi
callq 0x6160
movslq -0x1c(%r13), %rcx
leaq 0x19ca7(%rip), %rdx     # 0x2d4b0
movq (%rdx,%rcx,8), %r9
movl -0x18(%r13), %r10d
subq $0x8, %rsp
leaq 0xe623(%rip), %rdi      # 0x21e3f
movq %r14, %rsi
movl %r12d, %edx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
pushq %r10
callq 0x61c0
addq $0x10, %rsp
cmpl $0x0, -0x1c(%r13)
jne 0x13865
movzbl 0x60(%rbp,%rbx), %edi
callq 0x13016
movq %rax, %r15
movq %rax, %rdi
callq 0xd320
leaq 0xe609(%rip), %rdi      # 0x21e61
movq %rax, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x61c0
movl 0x64(%rbp,%rbx), %esi
movq 0x68(%rbp,%rbx), %rdx
leaq 0xe5f7(%rip), %rdi      # 0x21e6c
xorl %eax, %eax
callq 0x61c0
cmpl $0x0, 0x10(%rsp)
je 0x138a9
movl 0x5c(%rbp,%rbx), %edi
callq 0x6150
testq %rax, %rax
movl 0xc(%rsp), %r13d
je 0x138ba
movq (%rax), %rsi
leaq 0xe5e2(%rip), %rdi      # 0x21e82
xorl %eax, %eax
callq 0x61c0
jmp 0x138cc
movl $0xa, %edi
callq 0x6060
movl 0xc(%rsp), %r13d
jmp 0x138cc
movl 0x5c(%rbp,%rbx), %esi
leaq 0xe5b6(%rip), %rdi      # 0x21e7b
xorl %eax, %eax
callq 0x61c0
leaq 0x78(%rbp), %rax
incq %r14
cmpq $0x3c1, %rbp            # imm = 0x3C1
movq %rax, %rbp
jb 0x137d8
testl %r13d, %r13d
setns %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq