// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/pstats.c
// Function: updabil
int updabil(int what,int amt,struct real *pst,int how)
{
	int *wh, *mx, *mr;
	struct real *mst, *msr;
	bool is_str = FALSE;
	int rtype;

	msr = &him->s_re;
	if (how == TRUE)				/* max real abilities */
		mst = &max_stats.s_re;
	else							/* max effective abil */
		mst = &max_stats.s_ef;
	switch (what) {
		case STR:
			is_str = TRUE;
			wh = &pst->a_str;
			mx = &mst->a_str;
			mr = &msr->a_str;
			rtype = R_ADDSTR;
		when DEX:
			wh = &pst->a_dex;
			mx = &mst->a_dex;
			mr = &msr->a_dex;
			rtype = R_DEX;
		when CON:
			wh = &pst->a_con;
			mx = &mst->a_con;
			mr = &msr->a_con;
			rtype = R_CONST;
		when WIS:
			wh = &pst->a_wis;
			mx = &mst->a_wis;
			mr = &msr->a_wis;
			rtype = R_KNOW;
		otherwise:
			return 0;
	}
	*wh += amt;						/* update by amt */
	if (amt < 0) {					/* if decrement */
		if (*wh < MINABIL)			/* minimum = 3 */
			*wh = MINABIL;
		if (how == FALSE) {
			if (*wh < *mr)			/* if less than real abil */
				*wh = *mr;			/* make equal to real */
		}
	}
	else {							/* increment */
		int themax;

		themax = MAXOTHER;				/* default maximum */
		if (is_str)
			themax = MAXSTR;			/* strength maximum */
		if (how != TRUE)
			themax += ringex(rtype);	/* get ring extra */
		if (*wh > themax) {				/* see if > max (if real) */
			*wh = themax;				/* max = 18  (24 if str) */
		}
		/*
		 * Check for updating the max player stats.
		 */
		if (*wh > *mx)
			*mx = *wh;
	}
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movb $0x0, -0x49(%rbp)
leaq 0x20820(%rip), %rax     # 0x371d0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x169ca
leaq 0x207a4(%rip), %rax     # 0x37168
movq %rax, -0x40(%rbp)
jmp 0x169d9
leaq 0x20797(%rip), %rax     # 0x37168
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movl -0x8(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x3, %eax
ja 0x16ab0
movq -0x60(%rbp), %rax
leaq 0x15620(%rip), %rcx     # 0x2c018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x1, -0x49(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x16abc
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl $0x19, -0x50(%rbp)
jmp 0x16abc
movq -0x18(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x38(%rbp)
movl $0x5, -0x50(%rbp)
jmp 0x16abc
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movl $0x18, -0x50(%rbp)
jmp 0x16abc
movl $0x0, -0x4(%rbp)
jmp 0x16b63
movl -0xc(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
cmpl $0x0, -0xc(%rbp)
jge 0x16b04
movq -0x28(%rbp), %rax
cmpl $0x3, (%rax)
jge 0x16ae0
movq -0x28(%rbp), %rax
movl $0x3, (%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0x16b02
movq -0x28(%rbp), %rax
movl (%rax), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x16b00
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x16b02
jmp 0x16b5c
movl $0x12, -0x54(%rbp)
testb $0x1, -0x49(%rbp)
je 0x16b18
movl $0x18, -0x54(%rbp)
cmpl $0x1, -0x1c(%rbp)
je 0x16b2c
movl -0x50(%rbp), %edi
callq 0x18160
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x54(%rbp), %eax
jle 0x16b40
movl -0x54(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x16b5a
movq -0x28(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
jmp 0x16b5c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)