// File: FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: ReadBrushes(_IO_FILE*)
static brush_t *ReadBrushes (FILE *file)
{
	brush_t *brushes = NULL;
	while (1)
	{
#ifdef HLBSP_REMOVEHULL2
		if (file == brushfiles[2] && g_nohull2)
			break;
#endif
		int r;
		int brushinfo;
		r = fscanf (file, "%i\n", &brushinfo);
		if (r == 0 || r == -1)
		{
			if (brushes == NULL)
			{
				Error ("ReadBrushes: no more models");
			}
			else
			{
				Error ("ReadBrushes: file end");
			}
		}
		if (brushinfo == -1)
		{
			break;
		}
		brush_t *b;
		b = AllocBrush ();
		b->next = brushes;
		brushes = b;
		side_t **psn;
		psn = &b->sides;
		while (1)
		{
			int planenum;
			int numpoints;
			r = fscanf (file, "%i %u\n", &planenum, &numpoints);
			if (r != 2)
			{
				Error ("ReadBrushes: get side failed");
			}
			if (planenum == -1)
			{
				break;
			}
			side_t *s;
			s = AllocSide ();
			s->plane = g_dplanes[planenum ^ 1];
			s->w = new Winding (numpoints);
			int x;
			for (x = 0; x < numpoints; x++)
			{
				double v[3];
				r = fscanf (file, "%lf %lf %lf\n", &v[0], &v[1], &v[2]);
				if (r != 3)
				{
					Error ("ReadBrushes: get point failed");
				}
				VectorCopy (v, s->w->m_Points[numpoints - 1 - x]);
			}
			s->next = NULL;
			*psn = s;
			psn = &s->next;
		}
	}
	return brushes;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x30c6962(%rip), %rax   # 0x30efa60
jne 0x2910e
testb $0x1, 0x20c6923(%rip)   # 0x20efa2a
je 0x2910e
jmp 0x29391
movq 0x70(%rsp), %rdi
leaq 0x10013(%rip), %rsi     # 0x3912d
leaq 0x60(%rsp), %rdx
movb $0x0, %al
callq 0x4570
movl %eax, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x29138
cmpl $-0x1, 0x64(%rsp)
jne 0x29160
cmpq $0x0, 0x68(%rsp)
jne 0x29150
leaq 0x126f7(%rip), %rdi     # 0x3b83e
movb $0x0, %al
callq 0xb510
jmp 0x2915e
leaq 0x12703(%rip), %rdi     # 0x3b85a
movb $0x0, %al
callq 0xb510
jmp 0x29160
cmpl $-0x1, 0x60(%rsp)
jne 0x2916c
jmp 0x29391
callq 0x250b0
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, (%rax)
movq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x126c9(%rip), %rsi     # 0x3b870
leaq 0x4c(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movb $0x0, %al
callq 0x4570
movl %eax, 0x64(%rsp)
cmpl $0x2, 0x64(%rsp)
je 0x291d1
leaq 0x126ad(%rip), %rdi     # 0x3b877
movb $0x0, %al
callq 0xb510
cmpl $-0x1, 0x4c(%rsp)
jne 0x291dd
jmp 0x2938c
callq 0x24f90
movq %rax, 0x40(%rsp)
movslq 0x4c(%rsp), %rcx
xorq $0x1, %rcx
shlq $0x6, %rcx
leaq 0x20c6835(%rip), %rdx   # 0x20efa30
movq 0x40(%rsp), %rax
movups (%rcx,%rdx), %xmm0
movups 0x10(%rcx,%rdx), %xmm1
movups 0x20(%rcx,%rdx), %xmm2
movups 0x30(%rcx,%rdx), %xmm3
movups %xmm3, 0x38(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm0, 0x8(%rax)
movl $0x20, %edi
callq 0x42f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movl 0x48(%rsp), %esi
callq 0xea10
jmp 0x29243
movq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x48(%rax)
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x29364
movq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x10(%rsp), %rcx
addq $0x8, %rcx
leaq 0x10(%rsp), %r8
addq $0x10, %r8
leaq 0x1252d(%rip), %rsi     # 0x3b7b7
movb $0x0, %al
callq 0x4570
movl %eax, 0x64(%rsp)
cmpl $0x3, 0x64(%rsp)
je 0x292ce
leaq 0x125f1(%rip), %rdi     # 0x3b894
movb $0x0, %al
callq 0xb510
jmp 0x292ce
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
movl $0x20, %esi
callq 0x4300
jmp 0x2939b
movsd 0x10(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movl 0x48(%rsp), %ecx
subl $0x1, %ecx
subl 0x30(%rsp), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd 0x18(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movl 0x48(%rsp), %ecx
subl $0x1, %ecx
subl 0x30(%rsp), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movsd 0x20(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movl 0x48(%rsp), %ecx
subl $0x1, %ecx
subl 0x30(%rsp), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x29259
movq 0x40(%rsp), %rax
movq $0x0, (%rax)
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x2919b
jmp 0x290f2
movq 0x68(%rsp), %rax
addq $0x78, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x4520
nopw %cs:(%rax,%rax)