// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/rip.c
// Function: score
int score(int amount,int aflag,char monst)
{
	struct sc_ent *scp, *sc2;
	int i, fd, prflags = 0;
	FILE *outf;
	char *packend;

	signal(SIGINT, byebye);
	signal(SIGQUIT, byebye);
	if (aflag != WINNER) {
		if (aflag == CHICKEN)
			packend = "when you chickened out";
		else
			packend = "at your untimely demise";
		mvaddstr(LINES - 1, 0, retstr);
		refresh();
		wgetnstr(stdscr,prbuf,80);
		oldpurse = purse;
		showpack(FALSE, packend);
	}
	/*
	 * Open file and read list
	 */
	if ((fd = open(scorefile, O_RDWR | O_CREAT, 0666)) < 0)
		return 0;
	outf = (FILE *) fdopen(fd, "w");
	for (scp = top_ten; scp <= &top_ten[9]; scp++) {
		scp->sc_score = 0;
		for (i = 0; i < 80; i++)
			scp->sc_name[i] = rnd(255);
		scp->sc_flags = rnd(255);
		scp->sc_level = rnd(255);
		scp->sc_monster = rnd(255);
		scp->sc_uid = rnd(255);
		scp->sc_date = rnd(255);
	}
	mvaddstr(LINES - 1, 0, retstr);
	refresh();
	wgetnstr(stdscr,prbuf,80);
	if (author() || wizard)
		if (strcmp(prbuf, "names") == 0)
			prflags = 1;
        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;
        }
	/*
	 * Insert it in list if need be
	 */
	if (!waswizard) {
		for (scp = top_ten; scp <= &top_ten[9]; scp++)
			if (amount > scp->sc_score)
				break;
			if (scp <= &top_ten[9]) {
				for (sc2 = &top_ten[9]; sc2 > scp; sc2--)
					*sc2 = *(sc2-1);
				scp->sc_score = amount;
				strcpy(scp->sc_name, whoami);
				scp->sc_flags = aflag;
				if (aflag == WINNER)
					scp->sc_level = max_level;
				else
					scp->sc_level = level;
				scp->sc_monster = monst;
				scp->sc_uid = playuid;
				scp->sc_explvl = him->s_lvl;
				scp->sc_exppts = him->s_exp;
				time(&scp->sc_date);
		}
	}
	ignore();
	fseek(outf, 0L, 0);
        for(i = 0; i < 10; i++)
        {
            memset(scoreline,0,100);
            encwrite((char *) top_ten[i].sc_name, LINLEN, outf);
            sprintf(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,
                top_ten[i].sc_monster, top_ten[i].sc_explvl,
                top_ten[i].sc_exppts, top_ten[i].sc_date);
            encwrite((char *) scoreline, 100, outf);
        }
	fclose(outf);
	signal(SIGINT, byebye);
	signal(SIGQUIT, byebye);
	clear();
	refresh();
	endwin();
	showtop(prflags);		/* print top ten list */
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x68, %rsp
movb %dl, %al
movl %edi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb %al, -0x15(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x2, %edi
leaq -0x9777(%rip), %rsi     # 0xeef0
callq 0x6280
movl $0x3, %edi
leaq -0x9788(%rip), %rsi     # 0xeef0
callq 0x6280
cmpl $0x2, -0x14(%rbp)
je 0x18728
cmpl $0x1, -0x14(%rbp)
jne 0x1869a
leaq 0x13df4(%rip), %rax     # 0x2c488
movq %rax, -0x48(%rbp)
jmp 0x186a5
leaq 0x13dfe(%rip), %rax     # 0x2c49f
movq %rax, -0x48(%rbp)
movq 0x1a914(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movq 0x1a92a(%rip), %rax     # 0x32fe0
movl (%rax), %esi
subl $0x1, %esi
xorl %edx, %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x186c9
jmp 0x186e4
movq 0x1a8f0(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
leaq 0x1ac66(%rip), %rsi     # 0x33340
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6560
movq 0x1a8d5(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
callq 0x61f0
movq 0x1a8c6(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
leaq 0x1ebfc(%rip), %rsi     # 0x37300
movl $0x50, %edx
callq 0x63f0
leaq 0x1e5c7(%rip), %rax     # 0x36cdc
movl (%rax), %eax
movl %eax, 0x23c13(%rip)     # 0x3c330
movq -0x48(%rbp), %rsi
xorl %edi, %edi
callq 0x18d20
leaq 0x1ed61(%rip), %rdi     # 0x37490
movl $0x42, %esi
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x6450
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
jge 0x18754
movl $0x0, -0xc(%rbp)
jmp 0x18d09
movl -0x30(%rbp), %edi
leaq 0x1283c(%rip), %rsi     # 0x2af9a
callq 0x63e0
movq %rax, -0x40(%rbp)
leaq 0x23bd2(%rip), %rax     # 0x3c340
movq %rax, -0x20(%rbp)
leaq 0x23bc7(%rip), %rax     # 0x3c340
addq $0x438, %rax            # imm = 0x438
cmpq %rax, -0x20(%rbp)
ja 0x18841
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x2c(%rbp)
cmpl $0x50, -0x2c(%rbp)
jge 0x187c5
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movb %al, %dl
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, 0x4(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1879a
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x54(%rax)
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x60(%rax)
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x5c(%rax)
movl $0xff, %edi
movb $0x0, %al
callq 0xef20
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x20(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x20(%rbp)
jmp 0x18772
movq 0x1a778(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
movq 0x1a78e(%rip), %rax     # 0x32fe0
movl (%rax), %esi
subl $0x1, %esi
xorl %edx, %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x18865
jmp 0x18880
movq 0x1a754(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
leaq 0x1aaca(%rip), %rsi     # 0x33340
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6560
movq 0x1a739(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
callq 0x61f0
movq 0x1a72a(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
leaq 0x1ea60(%rip), %rsi     # 0x37300
movl $0x50, %edx
callq 0x63f0
movb $0x0, %al
callq 0xf130
testb $0x1, %al
jne 0x188c1
leaq 0x1e451(%rip), %rax     # 0x36d0d
testb $0x1, (%rax)
je 0x188e2
leaq 0x1ea38(%rip), %rdi     # 0x37300
leaq 0x13be8(%rip), %rsi     # 0x2c4b7
callq 0x6250
cmpl $0x0, %eax
jne 0x188e0
movl $0x1, -0x34(%rbp)
jmp 0x188e2
movl $0x0, -0x2c(%rbp)
cmpl $0xa, -0x2c(%rbp)
jge 0x18a14
movslq -0x2c(%rbp), %rax
leaq 0x23a42(%rip), %rdi     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movl -0x30(%rbp), %edx
movl $0x50, %esi
callq 0x1bc90
movl -0x30(%rbp), %edx
leaq 0x23ed0(%rip), %rdi     # 0x3c7f0
movl $0x64, %esi
callq 0x1bc90
movslq -0x2c(%rbp), %rax
leaq 0x23a0b(%rip), %rdx     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %rdx
movslq -0x2c(%rbp), %rax
leaq 0x239f9(%rip), %rcx     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %rcx
addq $0x54, %rcx
movslq -0x2c(%rbp), %rax
leaq 0x239e3(%rip), %r8      # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %r8
addq $0x58, %r8
movslq -0x2c(%rbp), %rax
leaq 0x239cd(%rip), %r9      # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %r9
addq $0x5c, %r9
movslq -0x2c(%rbp), %rax
leaq 0x239b7(%rip), %r11     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %r11
addq $0x64, %r11
movslq -0x2c(%rbp), %rax
leaq 0x239a1(%rip), %r10     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %r10
addq $0x68, %r10
movslq -0x2c(%rbp), %rsi
leaq 0x2398b(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
addq $0x70, %rax
leaq 0x23e29(%rip), %rdi     # 0x3c7f0
leaq 0x13aef(%rip), %rsi     # 0x2c4bd
leaq -0x4c(%rbp), %rbx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x6370
movl -0x4c(%rbp), %eax
movb %al, %cl
movslq -0x2c(%rbp), %rdx
leaq 0x23944(%rip), %rax     # 0x3c340
imulq $0x78, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x60(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x188e9
leaq 0x1e2f5(%rip), %rax     # 0x36d10
testb $0x1, (%rax)
jne 0x18b57
leaq 0x23915(%rip), %rax     # 0x3c340
movq %rax, -0x20(%rbp)
leaq 0x2390a(%rip), %rax     # 0x3c340
addq $0x438, %rax            # imm = 0x438
cmpq %rax, -0x20(%rbp)
ja 0x18a5f
movl -0x10(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x18a4f
jmp 0x18a5f
jmp 0x18a51
movq -0x20(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x20(%rbp)
jmp 0x18a2f
leaq 0x238da(%rip), %rax     # 0x3c340
addq $0x438, %rax            # imm = 0x438
cmpq %rax, -0x20(%rbp)
ja 0x18b55
leaq 0x238c3(%rip), %rax     # 0x3c340
addq $0x438, %rax            # imm = 0x438
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0x18ab5
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $-0x78, %rsi
movl $0x78, %edx
callq 0x62c0
movq -0x28(%rbp), %rax
addq $-0x78, %rax
movq %rax, -0x28(%rbp)
jmp 0x18a87
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
addq $0x4, %rdi
leaq 0x1e883(%rip), %rsi     # 0x37350
callq 0x60d0
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x54(%rax)
cmpl $0x2, -0x14(%rbp)
jne 0x18af4
leaq 0x1a813(%rip), %rax     # 0x332fc
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
jmp 0x18b04
leaq 0x1a7f5(%rip), %rax     # 0x332f0
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
movb -0x15(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x60(%rax)
leaq 0x1e7bb(%rip), %rax     # 0x372d0
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x5c(%rax)
leaq 0x1e6ab(%rip), %rax     # 0x371d0
movq (%rax), %rax
movl 0x28(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x64(%rax)
leaq 0x1e697(%rip), %rax     # 0x371d0
movq (%rax), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rdi
addq $0x70, %rdi
callq 0x62f0
jmp 0x18b57
movb $0x0, %al
callq 0x19dc0
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x63b0
movl $0x0, -0x2c(%rbp)
cmpl $0xa, -0x2c(%rbp)
jge 0x18cac
leaq 0x23c6b(%rip), %rdi     # 0x3c7f0
xorl %esi, %esi
movl $0x64, %edx
callq 0x6220
movslq -0x2c(%rbp), %rax
leaq 0x237a4(%rip), %rdi     # 0x3c340
imulq $0x78, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
movq -0x40(%rbp), %rdx
movl $0x50, %esi
callq 0x1bc00
movslq -0x2c(%rbp), %rcx
leaq 0x23780(%rip), %rax     # 0x3c340
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
movslq -0x2c(%rbp), %rcx
leaq 0x2376c(%rip), %rax     # 0x3c340
imulq $0x78, %rcx, %rcx
addq %rcx, %rax
movl 0x54(%rax), %ecx
movslq -0x2c(%rbp), %rsi
leaq 0x23757(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movl 0x58(%rax), %r8d
movslq -0x2c(%rbp), %rsi
leaq 0x23741(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movl 0x5c(%rax), %r9d
movslq -0x2c(%rbp), %rsi
leaq 0x2372b(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movzbl 0x60(%rax), %ebx
movslq -0x2c(%rbp), %rsi
leaq 0x23715(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movl 0x64(%rax), %r11d
movslq -0x2c(%rbp), %rsi
leaq 0x236ff(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movq 0x68(%rax), %r10
movslq -0x2c(%rbp), %rsi
leaq 0x236e9(%rip), %rax     # 0x3c340
imulq $0x78, %rsi, %rsi
addq %rsi, %rax
movq 0x70(%rax), %rax
leaq 0x23b87(%rip), %rdi     # 0x3c7f0
leaq 0x1384d(%rip), %rsi     # 0x2c4bd
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x64f0
movq -0x40(%rbp), %rdx
leaq 0x23b5c(%rip), %rdi     # 0x3c7f0
movl $0x64, %esi
callq 0x1bc00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x18b74
movq -0x40(%rbp), %rdi
callq 0x6130
movl $0x2, %edi
leaq -0x9dd1(%rip), %rsi     # 0xeef0
callq 0x6280
movl $0x3, %edi
leaq -0x9de2(%rip), %rsi     # 0xeef0
callq 0x6280
movq 0x1a2e2(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
callq 0x6110
movq 0x1a2d3(%rip), %rax     # 0x32fc0
movq (%rax), %rdi
callq 0x61f0
callq 0x6530
movl -0x34(%rbp), %edi
callq 0x18f40
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x68, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)