// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/fight.c
// Function: roll_em
bool roll_em(struct stats *att,struct stats *def,struct object *weap,bool hurl)
{
	char *cp;
	int ndice, nsides, def_arm, prop_hplus, prop_dplus;
	bool did_hit = FALSE;
	char *mindex(char *cp,char c);

	prop_hplus = prop_dplus = 0;
	if (weap == NULL) {
		cp = att->s_dmg;
	}
	else if (hurl) {
		if (o_on(weap,ISMISL) && cur_weapon != NULL &&
		  cur_weapon->o_which == weap->o_launch) {
			cp = weap->o_hurldmg;
			prop_hplus = cur_weapon->o_hplus;
			prop_dplus = cur_weapon->o_dplus;
		}
		else
			cp = (o_on(weap,ISMISL) ? weap->o_damage : weap->o_hurldmg);
	}
	else {
		cp = weap->o_damage;
		/*
		 * Drain a staff of striking
		 */
		if (weap->o_type == STICK && weap->o_which == WS_HIT
		  && weap->o_charges == 0) {
			strcpy(weap->o_damage, "0d0");
			weap->o_hplus = weap->o_dplus = 0;
		}
    }
	while(1) {
		int damage;
		int hplus = prop_hplus + (weap == NULL ? 0 : weap->o_hplus);
		int dplus = prop_dplus + (weap == NULL ? 0 : weap->o_dplus);

		if (att == him && weap == cur_weapon) {
			if (isring(LEFT, R_ADDDAM))
				dplus += cur_ring[LEFT]->o_ac;
			else if (isring(LEFT, R_ADDHIT))
				hplus += cur_ring[LEFT]->o_ac;
			if (isring(RIGHT, R_ADDDAM))
				dplus += cur_ring[RIGHT]->o_ac;
			else if (isring(RIGHT, R_ADDHIT))
				hplus += cur_ring[RIGHT]->o_ac;
		}
		ndice = atoi(cp);
		if ((cp = mindex(cp, 'd')) == NULL)
			break;
		nsides = atoi(++cp);

		if (def == him) {			/* defender is hero */
			if (cur_armor != NULL)
				def_arm = cur_armor->o_ac;
			else
				def_arm = def->s_arm;
			if (isring(LEFT, R_PROTECT))
				def_arm -= cur_ring[LEFT]->o_ac;
			if (isring(RIGHT, R_PROTECT))
				def_arm -= cur_ring[RIGHT]->o_ac;
		}
		else						/* defender is monster */
			def_arm = def->s_arm;
		if (hurl)
			hplus += getpdex(att,TRUE);
		if (swing(att->s_lvl, def_arm + getpdex(def, FALSE),
		  hplus + str_plus(att))) {
			int proll;

			proll = roll(ndice, nsides);
			damage = dplus + proll + add_dam(att);
			if (pl_off(ISINVINC) || def != him)
				def->s_hpt -= max(0, damage);
			did_hit = TRUE;
		}
		if ((cp = mindex(cp, '/')) == NULL)
			break;
		cp++;
	}
	return did_hit;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movb $0x0, -0x3d(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb648
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%rbp)
jmp 0xb74a
testb $0x1, -0x19(%rbp)
je 0xb6f2
movq -0x18(%rbp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0xaac0
testb $0x1, %al
jne 0xb666
jmp 0xb6ba
leaq 0x2b653(%rip), %rax     # 0x36cc0
cmpq $0x0, (%rax)
je 0xb6ba
leaq 0x2b646(%rip), %rax     # 0x36cc0
movq (%rax), %rax
movl 0x28(%rax), %eax
movq -0x18(%rbp), %rcx
movsbl 0x48(%rcx), %ecx
cmpl %ecx, %eax
jne 0xb6ba
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
leaq 0x2b621(%rip), %rax     # 0x36cc0
movq (%rax), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0x2b611(%rip), %rax     # 0x36cc0
movq (%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0xb6f0
movq -0x18(%rbp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0xaac0
testb $0x1, %al
jne 0xb6ce
jmp 0xb6dc
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
jmp 0xb6e8
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xb748
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2f, 0x20(%rax)
jne 0xb746
movq -0x18(%rbp), %rax
cmpl $0x1, 0x28(%rax)
jne 0xb746
movq -0x18(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jne 0xb746
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x1ff2f(%rip), %rsi     # 0x2b65a
callq 0x60d0
movq -0x18(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x2c(%rax)
jmp 0xb748
jmp 0xb74a
jmp 0xb74c
movl -0x38(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb760
xorl %eax, %eax
movl %eax, -0x60(%rbp)
jmp 0xb76a
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x64(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb789
xorl %eax, %eax
movl %eax, -0x68(%rbp)
jmp 0xb793
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
movl -0x68(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
leaq 0x2ba27(%rip), %rcx     # 0x371d0
cmpq (%rcx), %rax
jne 0xb86c
movq -0x18(%rbp), %rax
leaq 0x2b503(%rip), %rcx     # 0x36cc0
cmpq (%rcx), %rax
jne 0xb86c
xorl %edi, %edi
movl $0x8, %esi
callq 0x181d0
testb $0x1, %al
jne 0xb7d8
jmp 0xb7ed
leaq 0x2b9e1(%rip), %rax     # 0x371c0
movq (%rax), %rax
movl 0x34(%rax), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xb814
xorl %edi, %edi
movl $0x7, %esi
callq 0x181d0
testb $0x1, %al
jne 0xb7ff
jmp 0xb812
leaq 0x2b9ba(%rip), %rax     # 0x371c0
movq (%rax), %rax
movl 0x34(%rax), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0xb814
movl $0x1, %edi
movl $0x8, %esi
callq 0x181d0
testb $0x1, %al
jne 0xb829
jmp 0xb83f
leaq 0x2b990(%rip), %rax     # 0x371c0
movq 0x8(%rax), %rax
movl 0x34(%rax), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xb86a
movl $0x1, %edi
movl $0x7, %esi
callq 0x181d0
testb $0x1, %al
jne 0xb854
jmp 0xb868
leaq 0x2b965(%rip), %rax     # 0x371c0
movq 0x8(%rax), %rax
movl 0x34(%rax), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0xb86a
jmp 0xb86c
movq -0x28(%rbp), %rdi
callq 0x64b0
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
movl $0x64, %esi
callq 0xcd10
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xb895
jmp 0xba37
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x28(%rbp)
callq 0x64b0
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
leaq 0x2b91c(%rip), %rcx     # 0x371d0
cmpq (%rcx), %rax
jne 0xb930
leaq 0x2b408(%rip), %rax     # 0x36cc8
cmpq $0x0, (%rax)
je 0xb8d8
leaq 0x2b3fb(%rip), %rax     # 0x36cc8
movq (%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0xb8e2
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x34(%rbp)
xorl %esi, %esi
movl %esi, %edi
callq 0x181d0
testb $0x1, %al
jne 0xb8f1
jmp 0xb906
leaq 0x2b8c8(%rip), %rax     # 0x371c0
movq (%rax), %rax
movl 0x34(%rax), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl $0x1, %edi
xorl %esi, %esi
callq 0x181d0
testb $0x1, %al
jne 0xb918
jmp 0xb92e
leaq 0x2b8a1(%rip), %rax     # 0x371c0
movq 0x8(%rax), %rax
movl 0x34(%rax), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
jmp 0xb93a
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x34(%rbp)
testb $0x1, -0x19(%rbp)
je 0xb954
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x16c60
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x16c60
movl %eax, %ecx
movl -0x78(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x6c(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x8(%rbp), %rdi
callq 0x16ed0
movl -0x74(%rbp), %edx
movl -0x70(%rbp), %edi
movl -0x6c(%rbp), %esi
addl %eax, %edx
callq 0xcb90
cmpl $0x0, %eax
je 0xba0c
movl -0x2c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0xef70
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x16fa0
movl %eax, %ecx
movl -0x7c(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movl $0x8, %edi
callq 0xaa90
testb $0x1, %al
jne 0xb9e5
movq -0x10(%rbp), %rax
leaq 0x2b7f0(%rip), %rcx     # 0x371d0
cmpq (%rcx), %rax
je 0xba08
xorl %eax, %eax
cmpl -0x44(%rbp), %eax
jle 0xb9f3
xorl %eax, %eax
movl %eax, -0x80(%rbp)
jmp 0xb9f9
movl -0x44(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x30(%rax)
movb $0x1, -0x3d(%rbp)
movq -0x28(%rbp), %rdi
movl $0x2f, %esi
callq 0xcd10
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xba26
jmp 0xba37
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xb74c
movb -0x3d(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)