// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/xfer.c
// Function: uuencode_read_header
static int uuencode_read_header(deark *c, struct uu_hdr_parser *uuhp, de_finfo *fi,
	int id_mode)
{
	int ret;
	i64 total_len;
	i64 line_count;
	u8 linebuf[500];
	i64 nbytes_in_linebuf;

	uuhp->hdr_line_startpos = bom_length(c);
	line_count=0;
	while(line_count<100) {
		ret = dbuf_find_line(c->infile, uuhp->hdr_line_startpos,
			&uuhp->hdr_line_len, &total_len);
		if(!ret) return 0;
		if(uuhp->hdr_line_len > 1000) return 0;

		nbytes_in_linebuf = (i64)sizeof(linebuf);
		if(uuhp->hdr_line_len < nbytes_in_linebuf)
			nbytes_in_linebuf = uuhp->hdr_line_len;
		de_read(linebuf, uuhp->hdr_line_startpos, nbytes_in_linebuf);

		uuhp->data_startpos = uuhp->hdr_line_startpos + total_len;

		if(nbytes_in_linebuf>=9 && !de_memcmp(linebuf, "begin ", 6)) {
			uuhp->hdr_line_type = HDR_UUENCODE_OR_XXENCODE;
			if(fi && !id_mode) {
				parse_begin_line(c, uuhp, fi, linebuf, nbytes_in_linebuf);
			}
			return 1;
		}

		if(nbytes_in_linebuf>=16 && !de_memcmp(linebuf, "begin-base64 ", 13)) {
			uuhp->hdr_line_type = HDR_UUENCODE_BASE64;
			if(fi && !id_mode) {
				parse_begin_line(c, uuhp, fi, linebuf, nbytes_in_linebuf);
			}
			return 1;
		}

		uuhp->hdr_line_startpos += total_len;
		line_count++;
	}

	if(!id_mode) de_err(c, "Unrecognized file format");
	uuhp->hdr_line_type = 0;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movl %ecx, 0xc(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
xorl %esi, %esi
callq 0xf1d1c
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leaq (%rcx,%rcx,2), %rax
movq %rax, 0x8(%r14)
leaq 0x10(%r14), %r13
movl $0x64, %ebx
movq 0x18(%r15), %rdi
movq 0x8(%r14), %rsi
movq %r13, %rdx
leaq 0x18(%rsp), %rcx
callq 0xf1c72
testl %eax, %eax
je 0xdb883
movq (%r13), %rbp
cmpq $0x3e8, %rbp            # imm = 0x3E8
jg 0xdb883
movl $0x1f4, %eax            # imm = 0x1F4
cmpq %rax, %rbp
movl $0x1f4, %r12d           # imm = 0x1F4
cmovlq %rbp, %r12
movq 0x18(%r15), %rdi
movq 0x8(%r14), %rdx
leaq 0x20(%rsp), %rsi
movq %r12, %rcx
callq 0xeeee8
movq 0x18(%rsp), %rax
addq 0x8(%r14), %rax
movq %rax, 0x18(%r14)
cmpq $0x9, %rbp
jl 0xdb828
movl 0x20(%rsp), %ecx
movl $0x69676562, %edx       # imm = 0x69676562
xorl %edx, %ecx
movzwl 0x24(%rsp), %edx
xorl $0x206e, %edx           # imm = 0x206E
orl %ecx, %edx
je 0xdb899
cmpq $0x10, %rbp
jl 0xdb857
movq 0x20(%rsp), %rcx
movabsq $0x61622d6e69676562, %rdx # imm = 0x61622D6E69676562
xorq %rdx, %rcx
movq 0x25(%rsp), %rdx
movabsq $0x203436657361622d, %rsi # imm = 0x203436657361622D
xorq %rsi, %rdx
orq %rcx, %rdx
je 0xdb8a2
movq %rax, 0x8(%r14)
decq %rbx
jne 0xdb7a6
cmpl $0x0, 0xc(%rsp)
jne 0xdb87c
leaq 0x67386(%rip), %rsi     # 0x142bf8
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9df7
movl $0x0, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xb, (%r14)
jmp 0xdb8a9
movl $0xc, (%r14)
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
sete %al
cmpl $0x0, 0xc(%rsp)
setne %cl
orb %al, %cl
movl $0x1, %ebx
jne 0xdb885
leaq 0x20(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %r8
callq 0xdbab2
jmp 0xdb885