// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/ffget.c
// Function: FFGET_getnewblock
int FFGET_getnewblock( FFGET_FILE *f )
{
	int i;
	int bs = 0;
	char *p;

	// We read the maximum of FFGET_BUFFER_MAX -2, because later, when we
	// use fgets(), we may need to read in an /additional/ single byte
	// and if we dont allocate spare room, we may have a buffer overflow

	if (f->FILEEND > 0)
	{
		f->endpoint = f->buffer;
		f->startpoint = f->buffer +1;
		f->FFEOF = 1;
		return 0;

	} else {
		long block_pos;

		block_pos = ftell(f->f); /** Get our current read position so we can use it in FFGET_ftell if required **/

		bs = fread( f->buffer, 1, FFGET_BUFFER_MAX -FFGET_BUFFER_PADDING, f->f );

		if (bs < (FFGET_BUFFER_MAX -FFGET_BUFFER_PADDING))
		{
			if (feof(f->f))
			{
				f->FILEEND = 1;
			}
			else
			{
				LOGGER_log("%s:%d:FFGET_getnewblock:ERROR: File read failed with error:%s", FL, strerror(errno));
				return 0;
			}
		}

		if (bs > 0)
		{

			// If we read in some data, then adjust the buffer to deal with it
			//
			// First we set the start point back to the start of the buffer,
			// then we set the end point to be the start +datasize we read, -1
			// then we adjust the total bytes read (for the sake of record keeping
			// though it has no /real/ purpose)
			//

			f->buffer[bs] = '\0';	//20040208-1703:PLD:JS
			f->last_block_read_from = block_pos; // 200607150941:PLD
			f->startpoint = f->buffer;
			f->endpoint = f->startpoint +bs -1;
			f->bytes += bs;

			// Check the buffer for poisioning \0's
			//  As these routines are being used for 7-bit valid text data,
			// we have to filter out any nasty \0's.

			if (FFGET_ALLOW_NUL == 0)
			{
				p = f->startpoint;
				for (i = 0; i < bs; i++) {
					if (*p == '\0') *p = ' ';
					p++;
				}
				*p = '\0';
			}

			if (FFGET_DPEDANTIC) LOGGER_log("%s:%d:FFGET_getnewblock:DEBUG-PEDANTIC: Size: %ld bytes\n", FL, f->bytes);

		}

	}

	return bs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x2030(%rax)
jle 0x9554
movq -0x10(%rbp), %rcx
addq $0x8, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2018(%rax)
movq -0x10(%rbp), %rcx
addq $0x8, %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2010(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x2034(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x96e6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2210
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1fff, %edx           # imm = 0x1FFF
callq 0x20b0
movl %eax, -0x18(%rbp)
cmpl $0x1fff, -0x18(%rbp)    # imm = 0x1FFF
jge 0x95e6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2220
cmpl $0x0, %eax
je 0x95af
movq -0x10(%rbp), %rax
movl $0x1, 0x2030(%rax)
jmp 0x95e4
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq %rax, %rcx
leaq 0x12b3b(%rip), %rdi     # 0x1c100
leaq 0x12b72(%rip), %rsi     # 0x1c13e
movl $0x8a, %edx
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x4(%rbp)
jmp 0x96e6
jmp 0x95e6
cmpl $0x0, -0x18(%rbp)
jle 0x96de
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, 0x8(%rax,%rcx)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2028(%rax)
movq -0x10(%rbp), %rcx
addq $0x8, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2010(%rax)
movq -0x10(%rbp), %rax
movq 0x2010(%rax), %rcx
movslq -0x18(%rbp), %rax
addq %rax, %rcx
addq $-0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2018(%rax)
movslq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x2040(%rax), %rcx
movq %rcx, 0x2040(%rax)
cmpl $0x0, 0x2190b(%rip)     # 0x2af68
jne 0x96ae
movq -0x10(%rbp), %rax
movq 0x2010(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x96a7
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x9690
movq -0x20(%rbp), %rax
movb $0x20, (%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9675
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
cmpl $0xa, 0x218b7(%rip)     # 0x2af6c
jl 0x96dc
movq -0x10(%rbp), %rax
movq 0x2040(%rax), %rcx
leaq 0x12a7d(%rip), %rdi     # 0x1c146
leaq 0x12a6e(%rip), %rsi     # 0x1c13e
movl $0xae, %edx
movb $0x0, %al
callq 0x117c0
jmp 0x96de
jmp 0x96e0
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop