// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/mime.c
// Function: MIME_is_file_RFC822
int MIME_is_file_RFC822( char *fname )
{
    char conditions[16][16] = {
        "Received: ", "From: ", "Subject: ", "Date: ", "Content-", "content-", "from: ", "subject: ", "date: ", "boundary=", "Boundary=", "MIME-Version"        };
    int result = 0;
    int flag_mime_version = 0;
    int hitcount = 0;
    int linecount = 100; // We should only need to read the first 10 lines of any file.
    char *line;
    FILE *f;

    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_is_file_RFC822:DEBUG: Testing %s for RFC822 headers",FL,fname);

    f = fopen(fname,"r");
    if (!f)
    {
        if (glb.quiet == 0)
        {
            LOGGER_log("%s:%d:MIME_is_file_mime:ERROR: cannot open file '%s' for reading (%s)", FL, fname,strerror(errno));
        }
        return 0;
    }

    line = malloc(sizeof(char) *1025);
    if (!line)
    {
        LOGGER_log("%s:%d:MIME_is_file_mime:ERROR: cannot allocate memory for read buffer", FL);
        return 0;
    }

    while (((!flag_mime_version)||(hitcount < 2))&&(fgets(line,1024,f))&&(linecount--))
    {
        /** test every line for possible headers, until we get a blank line **/

        if ((glb.header_longsearch == 0)&&(*line == '\n' || *line == '\r')) break;

        for (result = 0; result < 12; result++)
        {
            /** Test for every possible MIME header prefix, ie, From: Subject: etc **/
            if (MIME_DPEDANTIC) LOGGER_log("%s:%d:MIME_is_file_mime:DEBUG: Testing for '%s' in '%s'", FL, line, conditions[result]);
            if (strncasecmp(line,conditions[result],strlen(conditions[result]))==0)
            {
                /** If we get a match, then increment the hit counter **/
                hitcount++;
                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_is_file_RFC822:DEBUG: Hit on %s",FL,conditions[result]);
                if (result == 11)
                {
                    flag_mime_version = 1;
                    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_is_file_RFC822:DEBUG: Find 'MIME Version' field",FL);
                }
            }
        }
    }

    fclose(f);
    if (hitcount >= 2 && flag_mime_version) result = 1;
    else result = 0;
    if (line) free(line);
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_is_file_RFC822:DEBUG: Hit count = %d, result = %d",FL,hitcount,result);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
leaq -0x110(%rbp), %rdi
leaq 0x17a63(%rip), %rsi     # 0x1c000
movl $0x100, %edx            # imm = 0x100
callq 0x2250
movl $0x0, -0x114(%rbp)
movl $0x0, -0x118(%rbp)
movl $0x0, -0x11c(%rbp)
movl $0x64, -0x120(%rbp)
cmpl $0x1, 0x2311a(%rip)     # 0x276f0
jl 0x45f6
movq -0x10(%rbp), %rcx
leaq 0x15142(%rip), %rdi     # 0x19725
leaq 0x14ee5(%rip), %rsi     # 0x194cf
movl $0x437, %edx            # imm = 0x437
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rdi
leaq 0x19093(%rip), %rsi     # 0x1d694
callq 0x2330
movq %rax, -0x130(%rbp)
cmpq $0x0, -0x130(%rbp)
jne 0x4667
cmpl $0x0, 0x230d6(%rip)     # 0x276f4
jne 0x465b
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq -0x138(%rbp), %rcx
movq %rax, %r8
leaq 0x1511c(%rip), %rdi     # 0x19764
leaq 0x14e80(%rip), %rsi     # 0x194cf
movl $0x43e, %edx            # imm = 0x43E
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x4(%rbp)
jmp 0x491d
movl $0x401, %edi            # imm = 0x401
callq 0x2290
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
jne 0x46a8
leaq 0x15121(%rip), %rdi     # 0x197aa
leaq 0x14e3f(%rip), %rsi     # 0x194cf
movl $0x446, %edx            # imm = 0x446
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x4(%rbp)
jmp 0x491d
jmp 0x46aa
cmpl $0x0, -0x118(%rbp)
je 0x46c4
xorl %eax, %eax
cmpl $0x2, -0x11c(%rbp)
movb %al, -0x139(%rbp)
jge 0x470a
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x21d0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x139(%rbp)
je 0x470a
movl -0x120(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x120(%rbp)
cmpl $0x0, %eax
setne %al
movb %al, -0x139(%rbp)
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x4719
jmp 0x489a
cmpl $0x0, 0x2381c(%rip)     # 0x27f3c
jne 0x4745
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x4740
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x4745
jmp 0x489a
movl $0x0, -0x114(%rbp)
cmpl $0xc, -0x114(%rbp)
jge 0x4895
cmpl $0xa, 0x22f8d(%rip)     # 0x276f0
jl 0x479b
movq -0x128(%rbp), %rcx
movslq -0x114(%rbp), %rax
leaq -0x110(%rbp), %r8
shlq $0x4, %rax
addq %rax, %r8
leaq 0x15068(%rip), %rdi     # 0x197f0
leaq 0x14d40(%rip), %rsi     # 0x194cf
movl $0x453, %edx            # imm = 0x453
movb $0x0, %al
callq 0x117c0
movq -0x128(%rbp), %rax
movq %rax, -0x150(%rbp)
movslq -0x114(%rbp), %rcx
leaq -0x110(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
movslq -0x114(%rbp), %rax
leaq -0x110(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x2100
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
movq %rax, %rdx
callq 0x22a0
cmpl $0x0, %eax
jne 0x487f
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
cmpl $0x1, 0x22edc(%rip)     # 0x276f0
jl 0x4845
movslq -0x114(%rbp), %rax
leaq -0x110(%rbp), %rcx
shlq $0x4, %rax
addq %rax, %rcx
leaq 0x14ff6(%rip), %rdi     # 0x19828
leaq 0x14c96(%rip), %rsi     # 0x194cf
movl $0x458, %edx            # imm = 0x458
movb $0x0, %al
callq 0x117c0
cmpl $0xb, -0x114(%rbp)
jne 0x487d
movl $0x1, -0x118(%rbp)
cmpl $0x1, 0x22e91(%rip)     # 0x276f0
jl 0x487b
leaq 0x14feb(%rip), %rdi     # 0x19853
leaq 0x14c60(%rip), %rsi     # 0x194cf
movl $0x45c, %edx            # imm = 0x45C
movb $0x0, %al
callq 0x117c0
jmp 0x487d
jmp 0x487f
jmp 0x4881
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x474f
jmp 0x46aa
movq -0x130(%rbp), %rdi
callq 0x20e0
cmpl $0x2, -0x11c(%rbp)
jl 0x48c4
cmpl $0x0, -0x118(%rbp)
je 0x48c4
movl $0x1, -0x114(%rbp)
jmp 0x48ce
movl $0x0, -0x114(%rbp)
cmpq $0x0, -0x128(%rbp)
je 0x48e4
movq -0x128(%rbp), %rdi
callq 0x2030
cmpl $0x1, 0x22e05(%rip)     # 0x276f0
jl 0x4914
movl -0x11c(%rbp), %ecx
movl -0x114(%rbp), %r8d
leaq 0x14f8d(%rip), %rdi     # 0x1988e
leaq 0x14bc7(%rip), %rsi     # 0x194cf
movl $0x466, %edx            # imm = 0x466
movb $0x0, %al
callq 0x117c0
movl -0x114(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax)