// File: /workspace/github_c_makefile_star2_O1/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 0x746625(%rip), %rcx    # 0x7a2130
cmpw $0x0, (%rax,%rcx)
je 0x5bb3b
movl %edi, %ebx
callq 0x5ba97
movl %eax, 0x747045(%rip)    # 0x7a2b64
leaq 0x7470da(%rip), %rcx    # 0x7a2c00
cmpl (%rcx,%r15,4), %eax
jge 0x5bb30
movl %eax, (%rcx,%r15,4)
movl (%rcx,%r15,4), %edx
addl $0x19, %edx
cmpl %edx, %eax
jge 0x5bb4a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%rcx,%r15,4)
leaq 0x7471eb(%rip), %rax    # 0x7a2d40
movl (%rax,%r15,4), %edx
movl %edx, 0x7470e3(%rip)    # 0x7a2c42
xorps %xmm0, %xmm0
movups %xmm0, 0x7470dd(%rip)   # 0x7a2c46
movups %xmm0, 0x7470e6(%rip)   # 0x7a2c56
leal 0xff(%rdx), %esi
xorl %edi, %edi
movq %r15, %rax
shlq $0xb, %rax
leaq 0x7471fa(%rip), %r8     # 0x7a2d80
addq %rax, %r8
leaq 0x7470b0(%rip), %r14    # 0x7a2c40
movl %edx, %ecx
andl $0x1ff, %ecx            # imm = 0x1FF
cmpl $0x0, (%r8,%rcx,4)
je 0x5bbba
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 0x5bb90
leaq 0x74f1b4(%rip), %rcx    # 0x7aad80
leaq 0x74f1ed(%rip), %rdx    # 0x7aadc0
movl (%rdx,%r15,4), %r12d
movl (%rcx,%r15,4), %r13d
cmpl %r12d, %r13d
movl %ebx, 0x4(%rsp)
jge 0x5bc0c
leaq 0x74f215(%rip), %rdx    # 0x7aae00
addq %rax, %rdx
movl %r13d, %esi
andl $0x1ff, %esi            # imm = 0x1FF
cmpl $0x0, (%rdx,%rsi,4)
jne 0x5bc0c
incl %r13d
movl %r13d, (%rcx,%r15,4)
cmpl %r13d, %r12d
jne 0x5bbee
movl %r12d, %r13d
movl $0x26, %ebp
cmpl %r12d, %r13d
jge 0x5bc86
movl $0x26, %ecx
leaq 0x74f1de(%rip), %r15    # 0x7aae00
addq %rax, %r15
leaq 0x7571d4(%rip), %rbx    # 0x7b2e00
movl %r13d, %eax
andl $0x1ff, %eax            # imm = 0x1FF
movslq (%r15,%rax,4), %rax
movswl (%rax,%rbx), %esi
testl %esi, %esi
je 0x5bc78
leal (%rcx,%rsi), %ebp
addl $0x6, %ebp
cmpl $0xfc, %ebp
jg 0x5bc84
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 0x5bc7a
movl %ecx, %ebp
incl %r13d
cmpl %r13d, %r12d
jne 0x5bc2c
jmp 0x5bc86
movl %ecx, %ebp
movslq %ebp, %rdx
movw $0x0, (%rdx,%r14)
leal 0x2(%rdx), %eax
movw %ax, 0x746fa6(%rip)     # 0x7a2c40
xorl %ecx, %ecx
cmpl $-0x1, %edx
movl 0x4(%rsp), %edi
jl 0x5bcd0
movl %eax, %edx
incq %rdx
leaq 0xb5715f(%rip), %rsi    # 0xbb2e10
movzbl %ch, %ebx
shll $0x8, %ecx
movzwl %cx, %ecx
movzbl -0x2(%rdx,%r14), %r8d
xorl %ebx, %r8d
xorl (%rsi,%r8,4), %ecx
decq %rdx
cmpq $0x1, %rdx
jg 0x5bcb1
cltq
movw %cx, (%rax,%r14)
addl $0x4, %ebp
movq %r14, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5a549