// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: NewTextures_Write()
void NewTextures_Write ()
{
	if (!g_newtextures_num)
	{
		return;
	}

	int i;
	dmiptexlump_t *texdata = (dmiptexlump_t *)g_dtexdata;

	byte *dataaddr = (byte *)&texdata->dataofs[texdata->nummiptex];
	int datasize = (g_dtexdata + g_texdatasize) - dataaddr;
	byte *newdataaddr = (byte *)&texdata->dataofs[texdata->nummiptex + g_newtextures_num];
	hlassume (g_texdatasize + (newdataaddr - dataaddr) <= g_max_map_miptex, assume_MAX_MAP_MIPTEX);
	memmove (newdataaddr, dataaddr, datasize);
	g_texdatasize += newdataaddr - dataaddr;
	for (i = 0; i < texdata->nummiptex; i++)
	{
		if (texdata->dataofs[i] < 0) // bad texture
		{
			continue;
		}
		texdata->dataofs[i] += newdataaddr - dataaddr;
	}

	hlassume (texdata->nummiptex + g_newtextures_num < MAX_MAP_TEXTURES, assume_MAX_MAP_TEXTURES);
	for (i = 0; i < g_newtextures_num; i++)
	{
		hlassume (g_texdatasize + g_newtextures_size[i] <= g_max_map_miptex, assume_MAX_MAP_MIPTEX);
		memcpy (g_dtexdata + g_texdatasize, g_newtextures_data[i], g_newtextures_size[i]);
		texdata->dataofs[texdata->nummiptex + i] = g_texdatasize;
		g_texdatasize += g_newtextures_size[i];
	}
	texdata->nummiptex += g_newtextures_num;

	for (int i = 0; i < g_newtextures_num; i++)
	{
		free (g_newtextures_data[i]);
	}
	g_newtextures_num = 0;
}

// Assembly:
movslq 0x524f753(%rip), %rax   # 0x52729c4
testq %rax, %rax
je 0x233ff
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x82e20c(%rip), %rcx    # 0x851498
movq (%rcx), %r15
movslq (%r15), %rcx
leaq (,%rcx,4), %rdx
leaq 0x4(%r15,%rcx,4), %rbx
leaq 0x82e1ee(%rip), %r13    # 0x851494
movslq (%r13), %rsi
leal (%r15,%rsi), %ebp
subl %ebx, %ebp
addq %rcx, %rax
leaq (,%rax,4), %r12
subq %rdx, %r12
leaq (%r15,%rax,4), %r14
addq $0x4, %r14
addq %r12, %rsi
leaq 0x25060(%rip), %rax     # 0x48330
movslq (%rax), %rax
xorl %edi, %edi
cmpq %rax, %rsi
setle %dil
movl $0x25, %esi
callq 0xa7c9
movslq %ebp, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4550
addl %r12d, (%r13)
movl (%r15), %ecx
testl %ecx, %ecx
jle 0x2331d
xorl %eax, %eax
movl 0x4(%r15,%rax,4), %ecx
testl %ecx, %ecx
js 0x23312
addl %r12d, %ecx
movl %ecx, 0x4(%r15,%rax,4)
incq %rax
movslq (%r15), %rcx
cmpq %rcx, %rax
jl 0x23301
addl 0x524f6a1(%rip), %ecx   # 0x52729c4
xorl %edi, %edi
cmpl $0x1000, %ecx           # imm = 0x1000
setl %dil
movl $0x24, %esi
callq 0xa7c9
movl 0x524f685(%rip), %eax   # 0x52729c4
leaq 0x524f68a(%rip), %r12   # 0x52729d0
testl %eax, %eax
jle 0x233c5
movq %r12, %r14
leaq 0x525367c(%rip), %r12   # 0x52769d0
xorl %ebp, %ebp
movl (%r12), %eax
addl (%r13), %eax
xorl %edi, %edi
leaq 0x24fc9(%rip), %rcx     # 0x48330
cmpl (%rcx), %eax
setle %dil
movl $0x25, %esi
callq 0xa7c9
movslq (%r13), %rdi
leaq 0x82e116(%rip), %rax    # 0x851498
addq (%rax), %rdi
movq (%r14), %rsi
movslq (%r12), %rbx
movq %rbx, %rdx
callq 0x4250
movl (%r13), %eax
movslq (%r15), %rcx
addq %rbp, %rcx
movl %eax, 0x4(%r15,%rcx,4)
addl %ebx, (%r13)
incq %rbp
movslq 0x524f613(%rip), %rax   # 0x52729c4
addq $0x8, %r14
addq $0x4, %r12
cmpq %rax, %rbp
jl 0x23356
leaq 0x524f60b(%rip), %r12   # 0x52729d0
addl %eax, (%r15)
testl %eax, %eax
jle 0x233e7
movl %eax, %ebx
shlq $0x3, %rbx
xorl %r14d, %r14d
movq (%r14,%r12), %rdi
callq 0x4380
addq $0x8, %r14
cmpq %r14, %rbx
jne 0x233d5
movl $0x0, 0x524f5d3(%rip)   # 0x52729c4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq