// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %r14
movq %rdi, %rbx
xorl %eax, %eax
movb %al, 0x5efd(%rdi)
movb %al, 0x6efe(%rdi)
movl %eax, 0x27f8(%rdi)
movb %al, 0x59fc(%rdi)
movb %al, 0x17b05(%rdi)
movl %eax, 0x17100(%rdi)
movl %eax, 0x166f8(%rdi)
movl %eax, 0x59f8(%rdi)
movq $0x0, 0x18d3c(%rdi)
movl %eax, 0x18d44(%rdi)
movl 0x205c(%rsi), %ecx
movl 0x214ac(%rip), %eax     # 0x2c38c
cmpl $0x1, %ecx
je 0xaf29
cmpl $0x3, %ecx
jne 0xaf61
testl %eax, %eax
jle 0xaf0d
leaq 0xbfb9(%rip), %rdi      # 0x16eae
leaq 0xa3b2(%rip), %rsi      # 0x152ae
movl $0xbb3, %edx            # imm = 0xBB3
movl $0x3, %ecx
xorl %eax, %eax
callq 0xc960
movb $0x0, 0x18d3a(%rbx)
movw $0xa0d, 0x18d38(%rbx)   # imm = 0xA0D
movl $0x1, 0x18d3c(%rbx)
jmp 0xaf7f
testl %eax, %eax
jle 0xaf4c
leaq 0xbfc4(%rip), %rdi      # 0x16ef8
leaq 0xa373(%rip), %rsi      # 0x152ae
movl $0xbb7, %edx            # imm = 0xBB7
movl $0x1, %ecx
xorl %eax, %eax
callq 0xc960
movw $0xa, 0x18d38(%rbx)
movl $0x1, 0x18d44(%rbx)
jmp 0xaf7f
testl %eax, %eax
jle 0xaf7f
leaq 0xbfd4(%rip), %rdi      # 0x16f40
leaq 0xa33b(%rip), %rsi      # 0x152ae
movl $0xbbb, %edx            # imm = 0xBBB
xorl %eax, %eax
callq 0xc960
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
movl $0x1, %edi
callq 0x76e4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8811
movl %eax, %ebp
xorl %edi, %edi
callq 0x76e4
movl 0x18d44(%rbx), %eax
cmpl 0x18d3c(%rbx), %eax
jle 0xafe2
movw $0xa, 0x18d38(%rbx)
movq 0x21387(%rip), %rdi     # 0x2c370
cmpl $-0x1, %ebp
je 0xb01d
testq %rdi, %rdi
jne 0xb02c
movl $0x1, %ebp
cmpl $0x0, 0x2138d(%rip)     # 0x2c38c
jle 0xb02c
leaq 0xbf8f(%rip), %rdi      # 0x16f97
leaq 0xa29f(%rip), %rsi      # 0x152ae
movl $0xbdc, %edx            # imm = 0xBDC
xorl %eax, %eax
callq 0xc960
jmp 0xb02c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0xb02c
callq 0x2030
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq