// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mmulti.c
// Function: dosendpackets
void dosendpackets (int other)
{
	int i, j, k;

	if (otherhost[other].ss_family == AF_UNSPEC) return;

		//Packet format:
		//   short crc16ofs;       //offset of crc16
		//   int icnt0;           //earliest unacked packet
		//   char ibits[32];       //ack status of packets icnt0<=i<icnt0+256
		//   while (short leng)    //leng: !=0 for packet, 0 for no more packets
		//   {
		//      int ocnt;         //index of following packet data
		//      char pak[leng];    //actual packet data :)
		//   }
		//   unsigned short crc16; //CRC16 of everything except crc16


	tims = GetTickCount();
	if (tims < lastsendtims[other]) lastsendtims[other] = tims;
	if (tims < lastsendtims[other]+1000/PAKRATE) return;
	lastsendtims[other] = tims;

	k = 2;
	*(int *)&pakbuf[k] = icnt0[other]; k += 4;
	memset(&pakbuf[k],0,32);
	for(i=icnt0[other];i<icnt0[other]+256;i++)
		if (ipak[other][i&(FIFSIZ-1)])
			pakbuf[((i-icnt0[other])>>3)+k] |= (1<<((i-icnt0[other])&7));
	k += 32;

	while ((ocnt0[other] < ocnt1[other]) && (!opak[other][ocnt0[other]&(FIFSIZ-1)])) ocnt0[other]++;
	for(i=ocnt0[other];i<ocnt1[other];i++)
	{
		j = *(short *)&pakmem[opak[other][i&(FIFSIZ-1)]]; if (!j) continue; //packet already acked
		if (k+6+j+4 > (int)sizeof(pakbuf)) break;

		*(unsigned short *)&pakbuf[k] = (unsigned short)j; k += 2;
		*(int *)&pakbuf[k] = i; k += 4;
		memcpy(&pakbuf[k],&pakmem[opak[other][i&(FIFSIZ-1)]+2],j); k += j;
	}
	*(unsigned short *)&pakbuf[k] = 0; k += 2;
	*(unsigned short *)&pakbuf[0] = (unsigned short)k;
	*(unsigned short *)&pakbuf[k] = getcrc16(pakbuf,k); k += 2;
	netsend(other,pakbuf,k);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq %edi, %r15
movq %r15, %rax
shlq $0x7, %rax
leaq 0x746300(%rip), %rcx    # 0x79b150
cmpw $0x0, (%rax,%rcx)
je 0x54e80
movl %edi, %ebx
callq 0x54db7
movl %eax, 0x746d20(%rip)    # 0x79bb84
leaq 0x746db5(%rip), %rcx    # 0x79bc20
movl (%rcx,%r15,4), %edx
cmpl %edx, %eax
jge 0x54e79
movl %eax, (%rcx,%r15,4)
movl %eax, %edx
addl $0x19, %edx
cmpl %edx, %eax
jge 0x54e8f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%rcx,%r15,4)
leaq 0x746ec6(%rip), %rax    # 0x79bd60
movl (%rax,%r15,4), %edx
movl %edx, 0x746dbe(%rip)    # 0x79bc62
xorps %xmm0, %xmm0
movups %xmm0, 0x746db8(%rip)   # 0x79bc66
movups %xmm0, 0x746dc1(%rip)   # 0x79bc76
xorl %esi, %esi
movq %r15, %rax
shlq $0xb, %rax
leaq 0x746edb(%rip), %rdi    # 0x79bda0
addq %rax, %rdi
pushq $0x1
popq %r8
leaq 0x746d8d(%rip), %r10    # 0x79bc60
cmpl $0x100, %esi            # imm = 0x100
je 0x54f06
leal (%rdx,%rsi), %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
cmpl $0x0, (%rdi,%rcx,4)
je 0x54f02
movl %esi, %ecx
andb $0x7, %cl
movl %r8d, %r9d
shll %cl, %r9d
movl %esi, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
orb %r9b, 0x6(%rcx,%r10)
incl %esi
jmp 0x54ed3
leaq 0x74ee93(%rip), %rcx    # 0x7a3da0
leaq 0x74eecc(%rip), %rdx    # 0x7a3de0
movl (%rdx,%r15,4), %ebp
movl (%rcx,%r15,4), %r12d
leaq 0x74eefd(%rip), %r13    # 0x7a3e20
addq %rax, %r13
cmpl %ebp, %r12d
jge 0x54f44
movl %r12d, %eax
andl $0x1ff, %eax            # imm = 0x1FF
cmpl $0x0, (%r13,%rax,4)
jne 0x54f44
incl %r12d
movl %r12d, (%rcx,%r15,4)
jmp 0x54f26
movl %ebx, 0x4(%rsp)
pushq $0x26
popq %r15
leaq 0x756ecd(%rip), %r8     # 0x7abe20
movslq %r15d, %r14
cmpl %ebp, %r12d
jge 0x54fbd
movl %r12d, %eax
andl $0x1ff, %eax            # imm = 0x1FF
movslq (%r13,%rax,4), %rax
movswl (%rax,%r8), %ecx
testl %ecx, %ecx
je 0x54fb2
leal (%r15,%rcx), %ebx
addl $0x6, %ebx
cmpl $0xfc, %ebx
jg 0x54fbd
movslq %ecx, %rdx
leal 0x6(%r14), %esi
movw %cx, (%r14,%r10)
movl %r12d, 0x2(%r14,%r10)
movslq %esi, %rdi
addq %r10, %rdi
leaq (%rax,%r8), %rsi
addq $0x2, %rsi
movq %r10, %r14
movq %r8, %r15
callq 0x80e0
movq %r15, %r8
movq %r14, %r10
jmp 0x54fb5
movl %r15d, %ebx
incl %r12d
movl %ebx, %r15d
jmp 0x54f53
andw $0x0, (%r14,%r10)
leaq 0x2(%r14), %rdi
movw %di, 0x746c92(%rip)     # 0x79bc60
movq %r10, %rbx
callq 0x54def
movw %ax, 0x2(%r14,%rbx)
addl $0x4, %r15d
movl 0x4(%rsp), %edi
movq %rbx, %rsi
movl %r15d, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x53ab2