// File: /workspace/github_c_makefile_star2_O3/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 0x7462c7(%rip), %rcx    # 0x7a5150
cmpw $0x0, (%rax,%rcx)
je 0x5eeb9
movl %edi, %ebx
callq 0x5ee15
movl %eax, 0x746ce7(%rip)    # 0x7a5b84
leaq 0x746d7c(%rip), %rcx    # 0x7a5c20
movl (%rcx,%r15,4), %edx
cmpl %edx, %eax
jge 0x5eeb2
movl %eax, (%rcx,%r15,4)
movl %eax, %edx
addl $0x19, %edx
cmpl %edx, %eax
jge 0x5eec8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%rcx,%r15,4)
leaq 0x746e8d(%rip), %rax    # 0x7a5d60
movl (%rax,%r15,4), %edx
movl %edx, 0x746d85(%rip)    # 0x7a5c62
xorps %xmm0, %xmm0
movups %xmm0, 0x746d7f(%rip)   # 0x7a5c66
movups %xmm0, 0x746d88(%rip)   # 0x7a5c76
leal 0xff(%rdx), %esi
xorl %edi, %edi
movq %r15, %rax
shlq $0xb, %rax
leaq 0x746e9c(%rip), %r8     # 0x7a5da0
addq %rax, %r8
leaq 0x746d52(%rip), %r14    # 0x7a5c60
movl %edx, %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
cmpl $0x0, (%r8,%rcx,4)
je 0x5ef38
movl %edi, %ecx
andb $0x7, %cl
movl $0x1, %r9d
shll %cl, %r9d
movl %edi, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
orb %r9b, 0x6(%rcx,%r14)
leal 0x1(%rdx), %ecx
incl %edi
cmpl %esi, %edx
movl %ecx, %edx
jl 0x5ef0e
leaq 0x74ee56(%rip), %rcx    # 0x7adda0
leaq 0x74ee8f(%rip), %rdx    # 0x7adde0
movl (%rdx,%r15,4), %r12d
movl (%rcx,%r15,4), %r13d
cmpl %r12d, %r13d
jge 0x5ef85
leaq 0x74eebb(%rip), %rdx    # 0x7ade20
addq %rax, %rdx
movl %r13d, %esi
andl $0x1ff, %esi            # imm = 0x1FF
cmpl $0x0, (%rdx,%rsi,4)
jne 0x5ef85
incl %r13d
movl %r13d, (%rcx,%r15,4)
cmpl %r13d, %r12d
jne 0x5ef68
jmp 0x5effc
cmpl %r12d, %r13d
jge 0x5effc
movl %ebx, 0x4(%rsp)
movl $0x26, %ecx
leaq 0x74ee86(%rip), %r15    # 0x7ade20
addq %rax, %r15
leaq 0x756e7c(%rip), %rbx    # 0x7b5e20
movl %r13d, %eax
andl $0x1ff, %eax            # imm = 0x1FF
movslq (%r15,%rax,4), %rax
movswl (%rax,%rbx), %esi
testl %esi, %esi
je 0x5eff0
leal (%rcx,%rsi), %ebp
addl $0x6, %ebp
cmpl $0xfc, %ebp
jg 0x5f01a
movslq %esi, %rdx
movslq %ecx, %rdi
addl $0x6, %ecx
movw %si, (%rdi,%r14)
movl %r13d, 0x2(%rdi,%r14)
movslq %ecx, %rdi
addq %r14, %rdi
leaq (%rax,%rbx), %rsi
addq $0x2, %rsi
callq 0x80e0
movl %ebp, %ecx
jmp 0x5eff2
movl %ecx, %ebp
incl %r13d
cmpl %r13d, %r12d
jne 0x5efa4
jmp 0x5f01c
movw $0x0, 0x746c81(%rip)    # 0x7a5c86
movw $0x28, 0x746c52(%rip)   # 0x7a5c60
movl $0x26, %ebp
movl $0x28, %eax
jmp 0x5f039
movl %ecx, %ebp
movslq %ebp, %rcx
movw $0x0, (%rcx,%r14)
leal 0x2(%rcx), %eax
movw %ax, 0x746c30(%rip)     # 0x7a5c60
cmpl $-0x1, %ecx
jl 0x5f08a
movl 0x4(%rsp), %ebx
movl %eax, %edx
incq %rdx
xorl %ecx, %ecx
leaq 0xb56de9(%rip), %rsi    # 0xbb5e30
movzbl %ch, %edi
shll $0x8, %ecx
movzwl %cx, %ecx
movzbl -0x2(%rdx,%r14), %r8d
xorl %edi, %r8d
xorl (%rsi,%r8,4), %ecx
decq %rdx
cmpq $0x1, %rdx
ja 0x5f047
cltq
movw %cx, (%rax,%r14)
addl $0x4, %ebp
movl %ebx, %edi
movq %r14, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5d727
xorl %ecx, %ecx
movl 0x4(%rsp), %ebx
jmp 0x5f066