// File: Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::birds::draw(image&, image const&, int)
void draw(image& out, const image& birdsmap, int tileset)
	{
		if (tileset == 2) return; // no birds in the snow region
		
		image bird;
		int animframe = frame/10 & 1;
		bird.init_ref_sub(birdsmap, animframe*8, tileset*6, 8, 6);
		
		int x = xmid + cosf(angle)*spd*frame;
		int y = ymid + sinf(angle)*spd*frame;
		
		for (int n=0;n<5;n++)
		{
			out.insert(x + cosf(angle + flock_angle_rad)*n*flock_dist, y + sinf(angle + flock_angle_rad)*n*flock_dist, bird);
			out.insert(x + cosf(angle - flock_angle_rad)*n*flock_dist, y + sinf(angle - flock_angle_rad)*n*flock_dist, bird);
		}
		
		frame++;
		
		//if outside the screen and distance increasing, reset them
		if (frame > 800/spd)
			reset(false);
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $0x2, -0x1c(%rbp)
jne 0x4cb9d
jmp 0x4cde4
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
movl $0xa, %ecx
cltd
idivl %ecx
andl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rsi
movl -0x3c(%rbp), %edx
shll $0x3, %edx
imull $0x6, -0x1c(%rbp), %ecx
leaq -0x38(%rbp), %rdi
movl $0x8, %r8d
movl $0x6, %r9d
callq 0x1afe0
movq -0x50(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x58(%rbp)
movss 0x8(%rax), %xmm0
callq 0x4240
movss -0x58(%rbp), %xmm1
movq -0x50(%rbp), %rax
movss 0x1936b(%rip), %xmm2    # 0x65f68
mulss %xmm2, %xmm0
cvtsi2ssl 0xc(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, -0x40(%rbp)
movss 0x4(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movss 0x8(%rax), %xmm0
callq 0x42a0
movq -0x50(%rbp), %rax
movss -0x54(%rbp), %xmm1
movss 0x1932e(%rip), %xmm2    # 0x65f68
mulss %xmm2, %xmm0
cvtsi2ssl 0xc(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
cmpl $0x5, -0x48(%rbp)
jge 0x4cdc3
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x80(%rbp)
cvtsi2ssl -0x40(%rbp), %xmm0
movss %xmm0, -0x88(%rbp)
movss 0x192ec(%rip), %xmm0    # 0x65f70
addss 0x8(%rax), %xmm0
callq 0x4240
movss -0x88(%rbp), %xmm1
movq -0x50(%rbp), %rax
cvtsi2ssl -0x48(%rbp), %xmm2
mulss %xmm2, %xmm0
movss 0x192c1(%rip), %xmm2    # 0x65f6c
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, -0x74(%rbp)
cvtsi2ssl -0x44(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
movss 0x192a1(%rip), %xmm0    # 0x65f70
addss 0x8(%rax), %xmm0
callq 0x42a0
movss -0x84(%rbp), %xmm1
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %esi
cvtsi2ssl -0x48(%rbp), %xmm2
mulss %xmm2, %xmm0
movss 0x19273(%rip), %xmm2    # 0x65f6c
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %edx
leaq -0x38(%rbp), %rcx
callq 0x183f0
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x68(%rbp)
cvtsi2ssl -0x40(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss 0x8(%rax), %xmm0
movss 0x1923f(%rip), %xmm1    # 0x65f70
subss %xmm1, %xmm0
callq 0x4240
movss -0x70(%rbp), %xmm1
movq -0x50(%rbp), %rax
cvtsi2ssl -0x48(%rbp), %xmm2
mulss %xmm2, %xmm0
movss 0x19218(%rip), %xmm2    # 0x65f6c
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, -0x5c(%rbp)
cvtsi2ssl -0x44(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movss 0x8(%rax), %xmm0
movss 0x191f6(%rip), %xmm1    # 0x65f70
subss %xmm1, %xmm0
callq 0x42a0
movss -0x6c(%rbp), %xmm1
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %esi
cvtsi2ssl -0x48(%rbp), %xmm2
mulss %xmm2, %xmm0
movss 0x191cc(%rip), %xmm2    # 0x65f6c
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %edx
leaq -0x38(%rbp), %rcx
callq 0x183f0
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x4cc59
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
cmpl $0xc8, 0xc(%rax)
jle 0x4cde4
movq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4c910
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)