// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_view.c
// Function: P_DamageFeedback
void P_DamageFeedback (edict_t *player)
{
	gclient_t	*client;
	float	side;
	float	realcount, count, kick;
	vec3_t	v;
	int		r, l;
	static	vec3_t	power_color = {0.0, 1.0, 0.0};
	static	vec3_t	acolor = {1.0, 1.0, 1.0};
	static	vec3_t	bcolor = {1.0, 0.0, 0.0};

	client = player->client;

	// flash the backgrounds behind the status numbers
	client->ps.stats[STAT_FLASHES] = 0;
	if (client->damage_blood)
		client->ps.stats[STAT_FLASHES] |= 1;
	if (client->damage_armor && !(player->flags & FL_GODMODE) && (client->invincible_framenum <= level.framenum))
		client->ps.stats[STAT_FLASHES] |= 2;

	// total points of damage shot at the player this frame
	count = (client->damage_blood + client->damage_armor + client->damage_parmor);
	if (count == 0)
		return;		// didn't take any damage

	// start a pain animation if still in the player model
	if (client->anim_priority < ANIM_PAIN && player->s.modelindex == 255)
	{
		static int		i;

		client->anim_priority = ANIM_PAIN;
		if (client->ps.pmove.pm_flags & PMF_DUCKED)
		{
			player->s.frame = FRAME_crpain1-1;
			client->anim_end = FRAME_crpain4;
		}
		else
		{
			i = (i+1)%3;
			switch (i)
			{
			case 0:
				player->s.frame = FRAME_pain101-1;
				client->anim_end = FRAME_pain104;
				break;
			case 1:
				player->s.frame = FRAME_pain201-1;
				client->anim_end = FRAME_pain204;
				break;
			case 2:
				player->s.frame = FRAME_pain301-1;
				client->anim_end = FRAME_pain304;
				break;
			}
		}
	}

	realcount = count;
	if (count < 10)
		count = 10;	// always make a visible effect

	// play an apropriate pain sound
	if ((level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) && (client->invincible_framenum <= level.framenum))
	{
		r = 1 + (rand()&1);
		player->pain_debounce_time = level.time + 0.7;
		if (player->health < 25)
			l = 25;
		else if (player->health < 50)
			l = 50;
		else if (player->health < 75)
			l = 75;
		else
			l = 100;
		gi.sound (player, CHAN_VOICE, gi.soundindex(va("*pain%i_%i.wav", l, r)), 1, ATTN_NORM, 0);
	}

	// the total alpha of the blend is always proportional to count
	if (client->damage_alpha < 0)
		client->damage_alpha = 0;
	client->damage_alpha += count*0.01;
	if (client->damage_alpha < 0.2)
		client->damage_alpha = 0.2f;
	if (client->damage_alpha > 0.6)
		client->damage_alpha = 0.6f;		// don't go too saturated

	// the color of the blend will vary based on how much was absorbed
	// by different armors
	VectorClear (v);
	if (client->damage_parmor)
		VectorMA (v, (float)client->damage_parmor/realcount, power_color, v);
	if (client->damage_armor)
		VectorMA (v, (float)client->damage_armor/realcount,  acolor, v);
	if (client->damage_blood)
		VectorMA (v, (float)client->damage_blood/realcount,  bcolor, v);
	VectorCopy (v, client->damage_blend);


	//
	// calculate view angle kicks
	//
	kick = abs(client->damage_knockback);
	if (kick && player->health > 0)	// kick of 0 means no view adjust at all
	{
		kick = kick * 100 / player->health;

		if (kick < count*0.5)
			kick = count*0.5;
		if (kick > 50)
			kick = 50;

		VectorSubtract (client->damage_from, player->s.origin, v);
		VectorNormalize (v);
		
		side = DotProduct (v, right);
		client->v_dmg_roll = kick*side*0.3;
		
		side = -DotProduct (v, forward);
		client->v_dmg_pitch = kick*side*0.3;

		client->v_dmg_time = level.time + DAMAGE_TIME;
	}

	//
	// clear totals
	//
	client->damage_blood = 0;
	client->damage_armor = 0;
	client->damage_parmor = 0;
	client->damage_knockback = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movw $0x0, 0x96(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xe60(%rax)
je 0x61e77
movq -0x10(%rbp), %rax
movswl 0x96(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0x96(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xe58(%rax)
je 0x61ec7
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x61ec7
movq -0x10(%rbp), %rax
movss 0xf08(%rax), %xmm1
movq 0x20ef7(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x61ec7
movq -0x10(%rbp), %rax
movswl 0x96(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x96(%rax)
movq -0x10(%rbp), %rax
movl 0xe60(%rax), %eax
movq -0x10(%rbp), %rcx
addl 0xe58(%rcx), %eax
movq -0x10(%rbp), %rcx
addl 0xe5c(%rcx), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x61f02
jp 0x61f02
jmp 0x62550
movq -0x10(%rbp), %rax
cmpl $0x3, 0xef8(%rax)
jge 0x6200c
movq -0x8(%rbp), %rax
cmpl $0xff, 0x28(%rax)
jne 0x6200c
movq -0x10(%rbp), %rax
movl $0x3, 0xef8(%rax)
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x61f60
movq -0x8(%rbp), %rax
movl $0xa8, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0xac, 0xef4(%rax)
jmp 0x6200a
movl 0x512be(%rip), %edx     # 0xb3224
movl %edx, %ecx
incl %ecx
movl %edx, %eax
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %rdx # imm = 0x55555556
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %edx
negl %edx
movl %edx, %ecx
leal 0x1(%rax,%rcx), %eax
movl %eax, 0x5128e(%rip)     # 0xb3224
movl 0x51288(%rip), %eax     # 0xb3224
movl %eax, -0x38(%rbp)
testl %eax, %eax
je 0x61fb9
jmp 0x61fa5
movl -0x38(%rbp), %eax
subl $0x1, %eax
je 0x61fd4
jmp 0x61faf
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x61fef
jmp 0x62008
movq -0x8(%rbp), %rax
movl $0x35, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0x39, 0xef4(%rax)
jmp 0x62008
movq -0x8(%rbp), %rax
movl $0x39, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0x3d, 0xef4(%rax)
jmp 0x62008
movq -0x8(%rbp), %rax
movl $0x3d, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0x41, 0xef4(%rax)
jmp 0x6200a
jmp 0x6200c
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x18(%rbp)
movss 0xded2(%rip), %xmm0     # 0x6fef0
ucomiss -0x1c(%rbp), %xmm0
jbe 0x62031
movss 0xdec4(%rip), %xmm0     # 0x6fef0
movss %xmm0, -0x1c(%rbp)
movq 0x20d68(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x244(%rax), %xmm0
jbe 0x6216d
movq -0x8(%rbp), %rax
movl 0x11c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x6216d
movq -0x10(%rbp), %rax
movss 0xf08(%rax), %xmm1
movq 0x20d29(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x6216d
callq 0x19c80
andl $0x1, %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq 0x20d07(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1263e(%rip), %xmm1    # 0x746e8
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x244(%rax)
movq -0x8(%rbp), %rax
cmpl $0x19, 0x254(%rax)
jge 0x620d4
movl $0x19, -0x34(%rbp)
jmp 0x6210b
movq -0x8(%rbp), %rax
cmpl $0x32, 0x254(%rax)
jge 0x620ea
movl $0x32, -0x34(%rbp)
jmp 0x62109
movq -0x8(%rbp), %rax
cmpl $0x4b, 0x254(%rax)
jge 0x62100
movl $0x4b, -0x34(%rbp)
jmp 0x62107
movl $0x64, -0x34(%rbp)
jmp 0x62109
jmp 0x6210b
movq 0x204ee(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x204d7(%rip), %rax     # 0x82600
movq 0x48(%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
leaq 0x15742(%rip), %rdi     # 0x77880
movb $0x0, %al
callq 0x19560
movq %rax, %rdi
movq -0x50(%rbp), %rax
callq *%rax
movq -0x48(%rbp), %rdi
movl %eax, %edx
movq -0x40(%rbp), %rax
movl $0x2, %esi
movss 0xdd87(%rip), %xmm1     # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss 0xea8(%rax), %xmm0
jbe 0x6218c
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0xea8(%rax)
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss 0xea8(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x156b3(%rip), %xmm2    # 0x77860
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xea8(%rax)
movq -0x10(%rbp), %rax
movss 0xea8(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x10967(%rip), %xmm0    # 0x72b40
ucomisd %xmm1, %xmm0
jbe 0x621f3
movq -0x10(%rbp), %rax
movss 0x10c71(%rip), %xmm0    # 0x72e5c
movss %xmm0, 0xea8(%rax)
movq -0x10(%rbp), %rax
movss 0xea8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1565d(%rip), %xmm1    # 0x77868
ucomisd %xmm1, %xmm0
jbe 0x62225
movq -0x10(%rbp), %rax
movss 0x155ef(%rip), %xmm0    # 0x7780c
movss %xmm0, 0xea8(%rax)
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xe5c(%rax)
je 0x6226f
leaq -0x2c(%rbp), %rdi
movq -0x10(%rbp), %rax
cvtsi2ssl 0xe5c(%rax), %xmm0
divss -0x18(%rbp), %xmm0
leaq -0x2c(%rbp), %rdx
leaq 0x25d7e(%rip), %rsi     # 0x87fe8
callq 0x199c0
movq -0x10(%rbp), %rax
cmpl $0x0, 0xe58(%rax)
je 0x622a1
leaq -0x2c(%rbp), %rdi
movq -0x10(%rbp), %rax
cvtsi2ssl 0xe58(%rax), %xmm0
divss -0x18(%rbp), %xmm0
leaq -0x2c(%rbp), %rdx
leaq 0x25d58(%rip), %rsi     # 0x87ff4
callq 0x199c0
movq -0x10(%rbp), %rax
cmpl $0x0, 0xe60(%rax)
je 0x622d3
leaq -0x2c(%rbp), %rdi
movq -0x10(%rbp), %rax
cvtsi2ssl 0xe60(%rax), %xmm0
divss -0x18(%rbp), %xmm0
leaq -0x2c(%rbp), %rdx
leaq 0x25d32(%rip), %rsi     # 0x88000
callq 0x199c0
movss -0x2c(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xeb0(%rax)
movss -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xeb4(%rax)
movss -0x24(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xeb8(%rax)
movq -0x10(%rbp), %rax
movl 0xe64(%rax), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x62334
jp 0x62334
jmp 0x62518
movq -0x8(%rbp), %rax
cmpl $0x0, 0x254(%rax)
jle 0x62518
movss 0x10833(%rip), %xmm0    # 0x72b80
mulss -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2ssl 0x254(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xf0a7(%rip), %xmm2     # 0x71428
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x623a9
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xf08c(%rip), %xmm1     # 0x71428
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
movss 0x1079e(%rip), %xmm1    # 0x72b54
ucomiss %xmm1, %xmm0
jbe 0x623c8
movss 0x10791(%rip), %xmm0    # 0x72b54
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movss 0xe68(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movss 0xe6c(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movss 0xe70(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, -0x24(%rbp)
leaq -0x2c(%rbp), %rdi
callq 0x183d0
movss -0x2c(%rbp), %xmm1
movss 0x50dec(%rip), %xmm2    # 0xb3218
movss -0x28(%rbp), %xmm0
mulss 0x50de3(%rip), %xmm0    # 0xb321c
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss -0x24(%rbp), %xmm0
movss 0x50dd2(%rip), %xmm2    # 0xb3220
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x14(%rbp)
movss -0x20(%rbp), %xmm0
mulss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x106c7(%rip), %xmm1    # 0x72b38
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xe94(%rax)
movss -0x2c(%rbp), %xmm1
movss 0x50d96(%rip), %xmm2    # 0xb3228
movss -0x28(%rbp), %xmm0
mulss 0x50d8d(%rip), %xmm0    # 0xb322c
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss -0x24(%rbp), %xmm0
movss 0x50d7c(%rip), %xmm2    # 0xb3230
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x14(%rbp)
movss -0x20(%rbp), %xmm0
mulss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x10654(%rip), %xmm1    # 0x72b38
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xe98(%rax)
movss 0x10650(%rip), %xmm0    # 0x72b50
movq 0x20899(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xe9c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xe60(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xe58(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xe5c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xe64(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)