// File: /workspace/github_c_makefile_star2_O2/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_headers_get
int MIMEH_headers_get( struct MIMEH_header_info *hinfo, FFGET_FILE *f )
{
    int result = 0;

    // Setup some basic defaults
    hinfo->filename[0] = '\0';
    hinfo->name[0] = '\0';
    hinfo->content_type = _CTYPE_UNKNOWN;
    hinfo->subject[0] = '\0';
    hinfo->charset[0] = '\0';

    // 20040116-1234:PLD - added to appease valgrind
    hinfo->content_disposition = 0;
    hinfo->content_transfer_encoding = 0;
    hinfo->boundary_located = 0;

    hinfo->crlf_count=0;
    hinfo->crcr_count=0;
    hinfo->lf_count=0;

    if (f->linebreak == (FFGET_LINEBREAK_CR|FFGET_LINEBREAK_LF)) {
        if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_headers_get:DEBUG: Setting to CRLF based on ffget value of %d", FL, f->linebreak);
        snprintf(hinfo->delimeter,sizeof(hinfo->delimeter),"\r\n");
        hinfo->crlf_count = 1;
    } else if (f->linebreak == FFGET_LINEBREAK_LF) {
        if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_headers_get:DEBUG: Setting to LF based on ffget value of %d", FL, f->linebreak);
        snprintf(hinfo->delimeter,sizeof(hinfo->delimeter),"\n");
        hinfo->lf_count = 1;
    } else {
        if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIMEH_headers_get:DEBUG: ffget value of %d offered us no guide for the delimeter", FL, f->linebreak);
    }



    // Initialise header defects array.
    hinfo->header_defect_count = 0;
    memset(hinfo->defects, 0, sizeof(int) *_MIMEH_DEFECT_ARRAY_SIZE);

    snprintf( hinfo->content_type_string, _MIMEH_CONTENT_TYPE_MAX , "text/plain" );


    // Read from the file, the headers we need
    FFGET_set_watch_SDL(1);
    result = MIMEH_read_headers(hinfo, f);
    FFGET_set_watch_SDL(0);

    if (hinfo->lf_count > hinfo->crlf_count) {
        snprintf(hinfo->delimeter,sizeof(hinfo->delimeter),"\n");
    }

    // If we ran out of input whilst looking at headers, then, we basically
    // flag this, free up the headers, and return.
    if (result == -1)
    {
        if (glb.headerline) free(glb.headerline);
        return result;
    }

    // If we came back with an OKAY result, but there's nothing in the
    //  headers, then flag off an error
    if (glb.headerline == NULL)
    {
        if (MIMEH_DNORMAL) LOGGER_log("%s:%d:MIME_parse_headers:DEBUG: null headerline\n", FL);
        return 1;
    }

    return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %eax, %eax
movb %al, 0x5efd(%rdi)
movb %al, 0x6efe(%rdi)
andl $0x0, 0x27f8(%rdi)
movb %al, 0x59fc(%rdi)
movb %al, 0x17b05(%rdi)
andl $0x0, 0x17100(%rdi)
andl $0x0, 0x166f8(%rdi)
andl $0x0, 0x59f8(%rdi)
andq $0x0, 0x18d3c(%rdi)
andl $0x0, 0x18d44(%rdi)
movq %rsi, %r14
movl 0x205c(%rsi), %ecx
movl 0x20910(%rip), %eax     # 0x2b38c
cmpl $0x1, %ecx
je 0xaac3
cmpl $0x3, %ecx
jne 0xaaf9
testl %eax, %eax
jle 0xaaa7
leaq 0xb44d(%rip), %rdi      # 0x15ede
leaq 0x9846(%rip), %rsi      # 0x142de
pushq $0x3
popq %rcx
movl $0xbb3, %edx            # imm = 0xBB3
xorl %eax, %eax
callq 0xc2a1
movb $0x0, 0x18d3a(%rbx)
movw $0xa0d, 0x18d38(%rbx)   # imm = 0xA0D
movl $0x1, 0x18d3c(%rbx)
jmp 0xab17
testl %eax, %eax
jle 0xaae4
leaq 0xb45a(%rip), %rdi      # 0x15f28
leaq 0x9809(%rip), %rsi      # 0x142de
pushq $0x1
popq %rcx
movl $0xbb7, %edx            # imm = 0xBB7
xorl %eax, %eax
callq 0xc2a1
movw $0xa, 0x18d38(%rbx)
movl $0x1, 0x18d44(%rbx)
jmp 0xab17
testl %eax, %eax
jle 0xab17
leaq 0xb46c(%rip), %rdi      # 0x15f70
leaq 0x97d3(%rip), %rsi      # 0x142de
movl $0xbbb, %edx            # imm = 0xBBB
xorl %eax, %eax
callq 0xc2a1
leaq 0x18b98(%rbx), %rdi
movl $0x194, %edx            # imm = 0x194
xorl %esi, %esi
callq 0x2170
movabsq $0x616c702f74786574, %rax # imm = 0x616C702F74786574
movq %rax, 0x27fc(%rbx)
movl $0x6e6961, 0x2803(%rbx) # imm = 0x6E6961
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x73dc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x84b7
movl %eax, %r14d
xorl %edi, %edi
callq 0x73dc
movl 0x18d44(%rbx), %eax
cmpl 0x18d3c(%rbx), %eax
jle 0xab7b
movw $0xa, 0x18d38(%rbx)
movq 0x207ee(%rip), %rdi     # 0x2b370
cmpl $-0x1, %r14d
je 0xabb6
xorl %eax, %eax
testq %rdi, %rdi
jne 0xabbe
cmpl $0x0, 0x207f6(%rip)     # 0x2b38c
jle 0xabb2
leaq 0xb428(%rip), %rdi      # 0x15fc7
leaq 0x9738(%rip), %rsi      # 0x142de
movl $0xbdc, %edx            # imm = 0xBDC
xorl %eax, %eax
callq 0xc2a1
movl %ebp, %eax
jmp 0xabbe
callq 0x2030
pushq $-0x1
popq %rax
popq %rbx
popq %r14
popq %rbp
retq