// File: FreeSlave[P]vhlt/hlcsg/brush.cpp
// Function: CopyHullBrush(hullbrush_t const*)
hullbrush_t *CopyHullBrush (const hullbrush_t *hb)
{
	hullbrush_t *hb2;
	hb2 = (hullbrush_t *)malloc (sizeof (hullbrush_t));
	hlassume (hb2 != NULL, assume_NoMemory);
	memcpy (hb2, hb, sizeof (hullbrush_t));
	hb2->faces = (hullbrushface_t *)malloc (hb->numfaces * sizeof (hullbrushface_t));
	hlassume (hb2->faces != NULL, assume_NoMemory);
	memcpy (hb2->faces, hb->faces, hb->numfaces * sizeof (hullbrushface_t));
	hb2->edges = (hullbrushedge_t *)malloc (hb->numedges * sizeof (hullbrushedge_t));
	hlassume (hb2->edges != NULL, assume_NoMemory);
	memcpy (hb2->edges, hb->edges, hb->numedges * sizeof (hullbrushedge_t));
	hb2->vertexes = (hullbrushvertex_t *)malloc (hb->numvertexes * sizeof (hullbrushvertex_t));
	hlassume (hb2->vertexes != NULL, assume_NoMemory);
	memcpy (hb2->vertexes, hb->vertexes, hb->numvertexes * sizeof (hullbrushvertex_t));
	for (int i = 0; i < hb->numfaces; i++)
	{
		hullbrushface_t *f2 = &hb2->faces[i];
		const hullbrushface_t *f = &hb->faces[i];
		f2->vertexes = (vec3_t *)malloc (f->numvertexes * sizeof (vec3_t));
		hlassume (f2->vertexes != NULL, assume_NoMemory);
		memcpy (f2->vertexes, f->vertexes, f->numvertexes * sizeof (vec3_t));
	}
	return hb2;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl $0x30, %edi
callq 0x4500
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x30, %edx
callq 0x4310
movq 0x20(%rsp), %rax
movslq (%rax), %rdi
shlq $0x6, %rdi
callq 0x4500
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x8(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rsp), %rax
movslq (%rax), %rdx
shlq $0x6, %rdx
callq 0x4310
movq 0x20(%rsp), %rax
movslq 0x10(%rax), %rax
imulq $0x90, %rax, %rdi
callq 0x4500
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x18(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x20(%rsp), %rax
movslq 0x10(%rax), %rax
imulq $0x90, %rax, %rdx
callq 0x4310
movq 0x20(%rsp), %rax
movslq 0x20(%rax), %rax
imulq $0x18, %rax, %rdi
callq 0x4500
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x28(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0x20(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x20(%rsp), %rax
movslq 0x20(%rax), %rax
imulq $0x18, %rax, %rdx
callq 0x4310
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x188fe
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x14(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x14(%rsp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movslq 0x30(%rax), %rax
imulq $0x18, %rax, %rdi
callq 0x4500
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x8(%rsp), %rax
cmpq $0x0, 0x38(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rdi
movq (%rsp), %rax
movq 0x38(%rax), %rsi
movq (%rsp), %rax
movslq 0x30(%rax), %rax
imulq $0x18, %rax, %rdx
callq 0x4310
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x1884e
movq 0x18(%rsp), %rax
addq $0x28, %rsp
retq
nopl (%rax,%rax)