// File: /workspace/github_c_makefile_star2_O0/NedFreed[P]msglint/msglint.c
// Function: parsehead
static void parsehead(msgcontext *ctx, struct headmap *hmap,
		      const char *body, int len, int htype,
		      headinfo *hinfo, dbinfo *db)
{
    const unsigned char *scan, *end;
    msgtoken *parse, *cur, *lasttok, *subtok;
    MIMEinfo *mcur = ctx->mcur;
    int j, do_parse = verbose;

    if (hmap->type == head_unknown) {
	wprintf(NULL, w_fatal, "unknown header line %d", db->startline);
	exit(1);
    }

    parse = tokenize(ctx, body, len, hmap->flags, db);
    
    /* strip leading comments */
    if (parse != NULL && parse->type == tok_comment &&
	(hmap == NULL || *hmap->parse != 'C')) {
	wprintf(db, w_warn, "starting with comment unwise");
	while (parse != NULL && parse->type == tok_comment) {
	    cur = parse->next;
	    parse->next = msgfree;
	    msgfree = parse;
	    parse = cur;
	}
    }
    
    /* check for empty header */
    if (parse == NULL) {
	wprintf(db, w_error, "empty ");
	return;
    }

    /* check for inappropriate header */
    if ((htype == HEAD_MIME && (hmap->flags & HF_OK_MASK) != 0) ||
	((htype == HEAD_MSG || htype == HEAD_INNER || htype == HEAD_TEXT ||
	  htype == HEAD_EXTB) &&
	 (hmap->flags & HF_OK_MASK) != 0 && (hmap->flags & MSG_OK) == 0) ||
	(htype == HEAD_DSN && !(hmap->flags & DSN_OK)) ||
	(htype == HEAD_RCPT && !(hmap->flags & DSNRCPT_OK)) ||
	(htype == HEAD_MTRKM && !(hmap->flags & MTRKM_OK)) ||
	(htype == HEAD_MTRKR && !(hmap->flags & MTRKR_OK)) ||
	(htype == HEAD_MDN && !(hmap->flags & MDN_OK))) {
	j = db->headlen;
	db->headlen = 0;
	wprintf(db, w_warn, "'%.*s' unexpected in %s", j, db->headname,
		headtypename[htype]);
	db->headlen = j;
    } else if (htype == HEAD_MIME &&
	       (db->headlen < 9 || strncasecmp("content-", db->headname, 8))) {
	wprintf(db, w_warn, "MIME headers should only be 'Content-*'. "
		"No meaning will apply to ");
    }
    
    /* parse headers */
    if (hmap->parse != NULL) {
	validatehead(ctx, hmap->parse, parse, hinfo, hmap, db);
    }

    /* special case headers */
    switch (hmap->type) {
      case contenttype:
	mcur->typenum = (ctypeid) hinfo->value;
	if  (mcur->typenum == ct_unknown &&
	     tokprefix("x-", 2, mcur->keep[K_CTYPE]) == 0) {
	    wprintf(db, w_warn, "experimental top-level type '%t' "
		    "strongly discouraged (" RFC_MIME_XTY ") line %d",
		    mcur->keep[K_CTYPE], ctx->lineno);
	} else if (tokprefix("x-", 2, mcur->keep[K_SUBTYPE]) == 0) {
	    wprintf(db, w_warn, "use of experimental media subtype '%t' "
		    "in released software unwise line %d",
		    mcur->keep[K_SUBTYPE], ctx->lineno);
	}
	if (mcur->typenum == text) {
	    if (mcur->keep[K_CHARSET] != NULL) {
	        validate_charset(mcur, mcur->keep[K_CHARSET], ctx->lineno);
	    }
	} else if (mcur->typenum == multipart) {
	    if (mcur->keep[K_BOUNDARY] == NULL) {
		mcur->typenum = ct_unknown;
		wprintf(db, w_error, "multipart missing boundary parameter");
	    } else {
		if (tokcomp("report", -1, mcur->keep[K_SUBTYPE]) == 0) {
		    mcur->inreport = 1;
		} else if (tokcomp("related", -1,
				   mcur->keep[K_SUBTYPE]) == 0) {
		    mcur->inrelated = 1;
		    if (mcur->keep[K_RELTYPE] != NULL) {
			subtok = tokenize(ctx, mcur->keep[K_RELTYPE]->data,
					  mcur->keep[K_RELTYPE]->len,
					  STRUCTURED|TSPECIAL, db);
			db->flags |= DB_INTYPE;
			validatehead(ctx, type_syntax, subtok, hinfo,
				     hmap, db);
			db->flags &= ~DB_INTYPE;
			if (subtok != NULL) {
			    for (lasttok = subtok; lasttok->next != NULL;
				 lasttok = lasttok->next)
				;
			    lasttok->next = msgfree;
			    msgfree = subtok;
			}
		    }
		} else if (tokcomp("digest", -1,
				   mcur->keep[K_SUBTYPE]) == 0) {
		    mcur->indigest = 1;
		}
	    }
	}
	break;
	
      default:
	if (hmap->parse == NULL &&
	    (hmap->flags & HEADTYPE_MASK) != UNSTRUCTURED) {
	    do_parse = 1;
	}
	break;
    }

    if (do_parse) {
	wprintf(db, w_ok, "Parse of ");
	tokprint(w_ok, parse);
    }
    
    /* put parse result on free list */
    while (parse != NULL) {
	for (j = 0; j < 10 && parse != mcur->keep[j]; ++j)
	    ;
	cur = parse->next;
	if (j == 10) {
	    parse->next = msgfree;
	    msgfree = parse;
	}
	parse = cur;
    }

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl 0xf23c(%rip), %eax      # 0x14ce0
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x5adb
movq 0x10(%rbp), %rax
movl 0x8(%rax), %ecx
xorl %eax, %eax
movl %eax, %edi
leaq 0x9c4b(%rip), %rsi      # 0xf70e
leaq 0xb408(%rip), %rdx      # 0x10ed2
movb $0x0, %al
callq 0x2e50
movl $0x1, %edi
callq 0x21c0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq 0x10(%rbp), %r8
callq 0x61d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x5b96
movq -0x40(%rbp), %rax
cmpl $0x5, 0x10(%rax)
jne 0x5b96
cmpq $0x0, -0x10(%rbp)
je 0x5b2a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movsbl (%rax), %eax
cmpl $0x43, %eax
je 0x5b96
movq 0x10(%rbp), %rdi
leaq 0x983c(%rip), %rsi      # 0xf371
leaq 0xb3ad(%rip), %rdx      # 0x10ee9
movb $0x0, %al
callq 0x2e50
xorl %eax, %eax
cmpq $0x0, -0x40(%rbp)
movb %al, -0x69(%rbp)
je 0x5b5d
movq -0x40(%rbp), %rax
cmpl $0x5, 0x10(%rax)
sete %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x5b66
jmp 0x5b94
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq 0xf3b8(%rip), %rcx      # 0x14f30
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, 0xf3a6(%rip)      # 0x14f30
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x5b43
jmp 0x5b96
cmpq $0x0, -0x40(%rbp)
jne 0x5bbb
movq 0x10(%rbp), %rdi
leaq 0x9b6e(%rip), %rsi      # 0xf716
leaq 0xb357(%rip), %rdx      # 0x10f06
movb $0x0, %al
callq 0x2e50
jmp 0x608c
cmpl $0x1, -0x20(%rbp)
jne 0x5bd6
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3f0, %eax            # imm = 0x3F0
cmpl $0x0, %eax
jne 0x5c7d
cmpl $0x0, -0x20(%rbp)
je 0x5bee
cmpl $0x5, -0x20(%rbp)
je 0x5bee
cmpl $0x6, -0x20(%rbp)
je 0x5bee
cmpl $0x7, -0x20(%rbp)
jne 0x5c10
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3f0, %eax            # imm = 0x3F0
cmpl $0x0, %eax
je 0x5c10
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5c7d
cmpl $0x2, -0x20(%rbp)
jne 0x5c25
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x5c7d
cmpl $0x3, -0x20(%rbp)
jne 0x5c3a
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x5c7d
cmpl $0x8, -0x20(%rbp)
jne 0x5c51
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x5c7d
cmpl $0x9, -0x20(%rbp)
jne 0x5c68
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x5c7d
cmpl $0x4, -0x20(%rbp)
jne 0x5cd0
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x5cd0
movq 0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x64(%rbp)
movq 0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq 0x10(%rbp), %rdi
movl -0x64(%rbp), %ecx
movq 0x10(%rbp), %rax
movq (%rax), %r8
movslq -0x20(%rbp), %rdx
leaq 0xed95(%rip), %rax      # 0x14a40
movq (%rax,%rdx,8), %r9
leaq 0x96bb(%rip), %rsi      # 0xf371
leaq 0xb250(%rip), %rdx      # 0x10f0d
movb $0x0, %al
callq 0x2e50
movl -0x64(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x5d18
cmpl $0x1, -0x20(%rbp)
jne 0x5d16
movq 0x10(%rbp), %rax
cmpl $0x9, 0x10(%rax)
jl 0x5cfd
movq 0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xb237(%rip), %rdi      # 0x10f25
movl $0x8, %edx
callq 0x2140
cmpl $0x0, %eax
je 0x5d16
movq 0x10(%rbp), %rdi
leaq 0x9669(%rip), %rsi      # 0xf371
leaq 0xb21f(%rip), %rdx      # 0x10f2e
movb $0x0, %al
callq 0x2e50
jmp 0x5d18
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x5d44
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %r8
movq 0x10(%rbp), %r9
callq 0x6c30
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
jne 0x5fbd
jmp 0x5d56
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x74(%rax)
movq -0x60(%rbp), %rax
cmpl $0x0, 0x74(%rax)
jne 0x5db5
movq -0x60(%rbp), %rax
movq (%rax), %rdx
leaq 0xb1f5(%rip), %rdi      # 0x10f71
movl $0x2, %esi
callq 0x9a60
cmpl $0x0, %eax
jne 0x5db5
movq 0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x95cc(%rip), %rsi      # 0xf371
leaq 0xb1c8(%rip), %rdx      # 0x10f74
movb $0x0, %al
callq 0x2e50
jmp 0x5dfe
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb1ad(%rip), %rdi      # 0x10f71
movl $0x2, %esi
callq 0x9a60
cmpl $0x0, %eax
jne 0x5dfc
movq 0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x9583(%rip), %rsi      # 0xf371
leaq 0xb1ce(%rip), %rdx      # 0x10fc3
movb $0x0, %al
callq 0x2e50
jmp 0x5dfe
movq -0x60(%rbp), %rax
cmpl $0x2, 0x74(%rax)
jne 0x5e30
movq -0x60(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x5e2b
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x9ad0
jmp 0x5fbb
movq -0x60(%rbp), %rax
cmpl $0x1, 0x74(%rax)
jne 0x5fb9
movq -0x60(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x5e72
movq -0x60(%rbp), %rax
movl $0x0, 0x74(%rax)
movq 0x10(%rbp), %rdi
leaq 0x98b7(%rip), %rsi      # 0xf716
leaq 0xb1a8(%rip), %rdx      # 0x1100e
movb $0x0, %al
callq 0x2e50
jmp 0x5fb7
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb1b2(%rip), %rdi      # 0x11033
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x60a0
cmpl $0x0, %eax
jne 0x5ea0
movq -0x60(%rbp), %rax
movl $0x1, 0x54(%rax)
jmp 0x5fb5
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb18b(%rip), %rdi      # 0x1103a
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x60a0
cmpl $0x0, %eax
jne 0x5f88
movq -0x60(%rbp), %rax
movl $0x1, 0x58(%rax)
movq -0x60(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x5f86
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %edx
movq 0x10(%rbp), %r8
movl $0x3, %ecx
callq 0x61d0
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
movl 0x14(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %r8
movq 0x10(%rbp), %r9
leaq 0x97ff(%rip), %rsi      # 0xf730
callq 0x6c30
movq 0x10(%rbp), %rax
movl 0x14(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x14(%rax)
cmpq $0x0, -0x58(%rbp)
je 0x5f84
movq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5f6b
jmp 0x5f5e
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x5f52
movq 0xefbe(%rip), %rcx      # 0x14f30
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq %rax, 0xefac(%rip)      # 0x14f30
jmp 0x5f86
jmp 0x5fb3
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xb0ab(%rip), %rdi      # 0x11042
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x60a0
cmpl $0x0, %eax
jne 0x5fb1
movq -0x60(%rbp), %rax
movl $0x1, 0x50(%rax)
jmp 0x5fb3
jmp 0x5fb5
jmp 0x5fb7
jmp 0x5fb9
jmp 0x5fbb
jmp 0x5fe0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x5fde
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x5fde
movl $0x1, -0x68(%rbp)
jmp 0x5fe0
cmpl $0x0, -0x68(%rbp)
je 0x600f
movq 0x10(%rbp), %rdi
leaq 0x931f(%rip), %rsi      # 0xf310
leaq 0xb051(%rip), %rdx      # 0x11049
movb $0x0, %al
callq 0x2e50
movq -0x40(%rbp), %rsi
leaq 0x9306(%rip), %rdi      # 0xf310
callq 0x9d90
jmp 0x6011
cmpq $0x0, -0x40(%rbp)
je 0x608a
movl $0x0, -0x64(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x64(%rbp)
movb %al, -0x6a(%rbp)
jge 0x6040
movq -0x40(%rbp), %rax
movq -0x60(%rbp), %rcx
movslq -0x64(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
setne %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
testb $0x1, %al
jne 0x6049
jmp 0x6056
jmp 0x604b
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x601f
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpl $0xa, -0x64(%rbp)
jne 0x6080
movq 0xeec2(%rip), %rcx      # 0x14f30
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, 0xeeb0(%rip)      # 0x14f30
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x6011
jmp 0x608c
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)