// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rdi, %r14
movq 0x18(%rdi), %rdi
xorl %esi, %esi
callq 0xf170a
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leaq (%rcx,%rcx,2), %rsi
movq %rsi, 0x8(%r12)
leaq 0x10(%r12), %r13
movl $0x64, %ebx
movq 0x18(%r14), %rdi
movq %r13, %rdx
leaq 0x18(%rsp), %rcx
callq 0xf166d
testl %eax, %eax
je 0xdae9a
movq (%r13), %r15
cmpq $0x3e8, %r15            # imm = 0x3E8
jg 0xdae9a
movl $0x1f4, %eax            # imm = 0x1F4
cmpq %rax, %r15
movl $0x1f4, %ebp            # imm = 0x1F4
cmovlq %r15, %rbp
movq 0x18(%r14), %rdi
movq 0x8(%r12), %rdx
leaq 0x20(%rsp), %rsi
movq %rbp, %rcx
callq 0xee8d4
movq 0x18(%rsp), %rsi
addq 0x8(%r12), %rsi
movq %rsi, 0x18(%r12)
cmpq $0x9, %r15
jl 0xdae6c
movl 0x20(%rsp), %eax
movl $0x69676562, %ecx       # imm = 0x69676562
xorl %ecx, %eax
movzwl 0x24(%rsp), %ecx
xorl $0x206e, %ecx           # imm = 0x206E
orl %eax, %ecx
je 0xdaeb0
cmpq $0x10, %r15
jb 0xdae6c
movq 0x20(%rsp), %rax
movabsq $0x61622d6e69676562, %rcx # imm = 0x61622D6E69676562
xorq %rcx, %rax
movq 0x25(%rsp), %rcx
movabsq $0x203436657361622d, %rdx # imm = 0x203436657361622D
xorq %rdx, %rcx
orq %rax, %rcx
je 0xdaee3
movq %rsi, 0x8(%r12)
decq %rbx
jne 0xdadbd
cmpl $0x0, 0xc(%rsp)
jne 0xdae92
leaq 0x68250(%rip), %rsi     # 0x1430d8
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
movl $0x0, (%r12)
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, (%r12)
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
sete %al
cmpl $0x0, 0xc(%rsp)
setne %cl
orb %al, %cl
movl $0x1, %ebx
jne 0xdae9c
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movl $0xb, %esi
jmp 0xdaf14
movl $0xc, (%r12)
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
sete %al
cmpl $0x0, 0xc(%rsp)
setne %cl
orb %al, %cl
movl $0x1, %ebx
jne 0xdae9c
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movl $0xc, %esi
movq %rbp, %r8
callq 0xdb109
jmp 0xdae9c