// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0x146550
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x38(%rbp)
cmpq $0x64, -0x38(%rbp)
jge 0x1462d3
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rdx
addq $0x10, %rdx
leaq -0x30(%rbp), %rcx
callq 0x169640
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x146167
movl $0x0, -0x4(%rbp)
jmp 0x1462fc
movq -0x18(%rbp), %rax
cmpq $0x3e8, 0x10(%rax)      # imm = 0x3E8
jle 0x146181
movl $0x0, -0x4(%rbp)
jmp 0x1462fc
movq $0x1f4, -0x238(%rbp) # imm = 0x1F4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x238(%rbp), %rax
jge 0x1461ac
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x238(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x230(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x238(%rbp), %rcx
callq 0x164d10
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
addq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
cmpq $0x9, -0x238(%rbp)
jl 0x14624c
leaq -0x230(%rbp), %rdi
leaq 0x88a34(%rip), %rsi     # 0x1cec2f
movl $0x6, %edx
callq 0x19170
cmpl $0x0, %eax
jne 0x14624c
movq -0x18(%rbp), %rax
movl $0xb, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x146240
cmpl $0x0, -0x24(%rbp)
jne 0x146240
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x230(%rbp), %rcx
movq -0x238(%rbp), %r8
callq 0x146590
movl $0x1, -0x4(%rbp)
jmp 0x1462fc
cmpq $0x10, -0x238(%rbp)
jl 0x1462b2
leaq -0x230(%rbp), %rdi
leaq 0x889d2(%rip), %rsi     # 0x1cec36
movl $0xd, %edx
callq 0x19170
cmpl $0x0, %eax
jne 0x1462b2
movq -0x18(%rbp), %rax
movl $0xc, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x1462a9
cmpl $0x0, -0x24(%rbp)
jne 0x1462a9
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x230(%rbp), %rcx
movq -0x238(%rbp), %r8
callq 0x146590
movl $0x1, -0x4(%rbp)
jmp 0x1462fc
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x146126
cmpl $0x0, -0x24(%rbp)
jne 0x1462eb
movq -0x10(%rbp), %rdi
leaq 0x88960(%rip), %rsi     # 0x1cec44
movb $0x0, %al
callq 0x15bfb0
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopl (%rax,%rax)