// File: /workspace/github_cpp_makefile_star2_O2/XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::defend(Character&, int&, Generator&)
bool Character::defend(Character& attacker,
	int& incomingDamage, Generator& rng) {

	// modifies damage and hit chance if necessary
	if(this->takeDamageFrom(attacker, incomingDamage, rng)) {
		// if is attack hits or is not player
		if (rng.genHitMiss() || !(this->getPlayerState())) {
		// deduct HP
		this->HP -= incomingDamage;
		if (this->HP < 0) {
			this->HP = 0;	
		}
		// reports damage taken
		this->addAction(makeMsg(attacker.getName(), WORD_DEAL_PAST_TENSE + " "
		+ to_string(incomingDamage) + " " + WORD_DAMAGE_NOUN + " "
		+ WORD_TO_PREPOSITION, this->name));

		return true;
		}

	}

	// reports dodge
	this->addAction(makeMsg(this->name, WORD_DODGE_PAST_TENSE + " "
		+ WORD_ATTACK_NOUN + " (" + to_string(incomingDamage) + " "
		+ WORD_DAMAGE_NOUN + ") " + WORD_FROM_PREPOSITION,
		attacker.getName()));

	return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rax
callq *0x40(%rax)
testb %al, %al
je 0x1122b
movq %rbx, %rdi
callq 0x13c02
testb %al, %al
jne 0x113f8
cmpb $0x0, 0x49(%r14)
je 0x113f8
leaq 0x88(%r14), %rsi
leaq 0x1c8(%rsp), %rbx
movq %rbx, %rdi
callq 0x52e0
leaq 0x14faf(%rip), %rsi     # 0x261f8
leaq 0x794b(%rip), %rdx      # 0x18b9b
leaq 0x108(%rsp), %rdi
callq 0x12c08
leaq 0x14f14(%rip), %rdx     # 0x26178
leaq 0x8(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x12b82
leaq 0x7ed3(%rip), %rdx      # 0x19150
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xcdf7
movl (%r12), %esi
leaq 0xe8(%rsp), %rdi
callq 0x12c40
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x12ba1
leaq 0x78e0(%rip), %rdx      # 0x18b9b
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xcdf7
leaq 0x14ee7(%rip), %rdx     # 0x261b8
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x12b82
leaq 0x7e69(%rip), %rdx      # 0x19153
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xcdf7
leaq 0x14f12(%rip), %rdx     # 0x26218
leaq 0x128(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x12b82
addq $0x88, %r15
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x52e0
leaq 0x148(%rsp), %rdi
leaq 0x1c8(%rsp), %r15
leaq 0x128(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
movq %r15, %rsi
callq 0x13ce8
addq $0x68, %r14
leaq 0x148(%rsp), %rsi
movq %r14, %rdi
callq 0x5410
leaq 0x148(%rsp), %rdi
callq 0x5428
leaq 0xc8(%rsp), %rdi
callq 0x5428
leaq 0x128(%rsp), %rdi
callq 0x5428
leaq 0xa8(%rsp), %rdi
callq 0x5428
leaq 0x88(%rsp), %rdi
callq 0x5428
leaq 0x68(%rsp), %rdi
callq 0x5428
leaq 0x48(%rsp), %rdi
callq 0x5428
leaq 0xe8(%rsp), %rdi
callq 0x5428
leaq 0x28(%rsp), %rdi
callq 0x5428
leaq 0x8(%rsp), %rdi
callq 0x5428
leaq 0x108(%rsp), %rdi
callq 0x5428
xorl %ebx, %ebx
jmp 0x11581
movl 0x34(%r14), %eax
subl (%r12), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x34(%r14)
addq $0x88, %r15
leaq 0x1e8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x52e0
leaq 0x14dac(%rip), %rsi     # 0x261d8
leaq 0x7768(%rip), %rdx      # 0x18b9b
leaq 0x28(%rsp), %rdi
callq 0x12c08
movl (%r12), %esi
leaq 0x8(%rsp), %rdi
callq 0x12c40
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x12ba1
leaq 0x7735(%rip), %rdx      # 0x18b9b
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xcdf7
leaq 0x14d3c(%rip), %rdx     # 0x261b8
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x12b82
leaq 0x7706(%rip), %rdx      # 0x18b9b
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xcdf7
leaq 0x14ea7(%rip), %rdx     # 0x26358
leaq 0x188(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x12b82
leaq 0x88(%r14), %rsi
leaq 0x168(%rsp), %rdi
callq 0x52e0
leaq 0x1a8(%rsp), %rdi
leaq 0x1e8(%rsp), %r15
leaq 0x188(%rsp), %rdx
leaq 0x168(%rsp), %rcx
movq %r15, %rsi
callq 0x13ce8
addq $0x68, %r14
leaq 0x1a8(%rsp), %rsi
movq %r14, %rdi
callq 0x5410
leaq 0x1a8(%rsp), %rdi
callq 0x5428
leaq 0x168(%rsp), %rdi
callq 0x5428
leaq 0x188(%rsp), %rdi
callq 0x5428
leaq 0xa8(%rsp), %rdi
callq 0x5428
leaq 0x88(%rsp), %rdi
callq 0x5428
leaq 0x68(%rsp), %rdi
callq 0x5428
leaq 0x48(%rsp), %rdi
callq 0x5428
leaq 0x8(%rsp), %rdi
callq 0x5428
leaq 0x28(%rsp), %rdi
callq 0x5428
movb $0x1, %bl
movq %r15, %rdi
callq 0x5428
movl %ebx, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
leaq 0x1a8(%rsp), %rdi
callq 0x5428
jmp 0x115af
movq %rax, %r14
leaq 0x168(%rsp), %rdi
callq 0x5428
jmp 0x115c1
movq %rax, %r14
leaq 0x188(%rsp), %rdi
callq 0x5428
jmp 0x115d3
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0x5428
jmp 0x115e5
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x5428
leaq 0x68(%rsp), %rdi
callq 0x5428
leaq 0x48(%rsp), %rdi
callq 0x5428
leaq 0x8(%rsp), %rdi
callq 0x5428
leaq 0x28(%rsp), %rdi
jmp 0x116c8
movq %rax, %r14
jmp 0x115f2
movq %rax, %r14
jmp 0x115fc
movq %rax, %r14
jmp 0x11606
movq %rax, %r14
jmp 0x11610
jmp 0x116fb
movq %rax, %r14
leaq 0x148(%rsp), %rdi
callq 0x5428
jmp 0x11648
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x5428
jmp 0x1165a
movq %rax, %r14
leaq 0x128(%rsp), %rdi
callq 0x5428
jmp 0x1166c
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0x5428
jmp 0x1167e
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x5428
leaq 0x68(%rsp), %rdi
callq 0x5428
leaq 0x48(%rsp), %rdi
callq 0x5428
leaq 0xe8(%rsp), %rdi
callq 0x5428
leaq 0x28(%rsp), %rdi
callq 0x5428
leaq 0x8(%rsp), %rdi
callq 0x5428
leaq 0x108(%rsp), %rdi
callq 0x5428
movq %rbx, %rdi
callq 0x5428
movq %r14, %rdi
callq 0x53c0
movq %rax, %r14
jmp 0x1168b
movq %rax, %r14
jmp 0x11695
movq %rax, %r14
jmp 0x1169f
movq %rax, %r14
jmp 0x116ac
movq %rax, %r14
jmp 0x116b6
movq %rax, %r14
jmp 0x116c0
movq %rax, %r14
jmp 0x116cd