// File: /workspace/github_c_makefile_star2_O0/Matthias-Wandel[P]imgcomp/src/exif.c
// Function: process_EXIF
void process_EXIF (unsigned char * ExifSection, unsigned int length)
{
    unsigned int FirstOffset;

    FocalplaneXRes = 0;
    FocalplaneUnits = 0;
    ExifImageWidth = 0;

    if (ShowTags){
        printf("Exif header %u bytes long\n",length);
    }

    {   // Check the EXIF header component
        static uchar ExifHeader[] = "Exif\0\0";
        if (memcmp(ExifSection+2, ExifHeader,6)){
            ErrNonfatal("Incorrect Exif header",0,0);
            return;
        }
    }

    if (memcmp(ExifSection+8,"II",2) == 0){
        if (ShowTags) printf("Exif section in Intel order\n");
        MotorolaOrder = 0;
    }else{
        if (memcmp(ExifSection+8,"MM",2) == 0){
            if (ShowTags) printf("Exif section in Motorola order\n");
            MotorolaOrder = 1;
        }else{
            ErrNonfatal("Invalid Exif alignment marker.",0,0);
            return;
        }
    }

    // Check the next value for correctness.
    if (Get16u(ExifSection+10) != 0x2a){
        ErrNonfatal("Invalid Exif start (1)",0,0);
        return;
    }

    FirstOffset = Get32u(ExifSection+12);
    if (FirstOffset < 8 || FirstOffset > 16){
        if (FirstOffset < 16 || FirstOffset > length-16){
            ErrNonfatal("invalid offset for first Exif IFD value",0,0);
            return;
        }
        // Usually set to 8, but other values valid too.
        ErrNonfatal("Suspicious offset of first Exif IFD value",0,0);
    }

    DirWithThumbnailPtrs = NULL;

    // First directory starts 16 bytes in.  All offset are relative to 8 bytes in.
    ProcessExifDir(ExifSection+8+FirstOffset, ExifSection+8, length-8, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xcf5e(%rip)     # 0x16588
xorps %xmm0, %xmm0
movsd %xmm0, 0xcf5b(%rip)     # 0x16590
movl $0x0, 0xcf59(%rip)      # 0x16598
leaq 0xbe6a(%rip), %rax      # 0x154b0
cmpl $0x0, (%rax)
je 0x965c
movl -0xc(%rbp), %esi
leaq 0x685c(%rip), %rdi      # 0xfeb1
movb $0x0, %al
callq 0x3170
movq -0x8(%rbp), %rdi
addq $0x2, %rdi
leaq 0xac55(%rip), %rsi      # 0x142c0
movl $0x6, %edx
callq 0x3210
cmpl $0x0, %eax
je 0x968f
leaq 0x684b(%rip), %rdi      # 0xfecc
xorl %edx, %edx
movl %edx, %esi
callq 0x8cb0
jmp 0x97c9
movq -0x8(%rbp), %rax
addq $0x8, %rax
movw (%rax), %ax
subw $0x4949, %ax            # imm = 0x4949
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x96cf
leaq 0xbe00(%rip), %rax      # 0x154b0
cmpl $0x0, (%rax)
je 0x96c3
leaq 0x6829(%rip), %rdi      # 0xfee5
movb $0x0, %al
callq 0x3170
movl $0x0, 0xceb3(%rip)      # 0x16580
jmp 0x9726
movq -0x8(%rbp), %rax
addq $0x8, %rax
movw (%rax), %ax
subw $0x4d4d, %ax            # imm = 0x4D4D
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x970f
leaq 0xbdc0(%rip), %rax      # 0x154b0
cmpl $0x0, (%rax)
je 0x9703
leaq 0x6809(%rip), %rdi      # 0xff05
movb $0x0, %al
callq 0x3170
movl $0x1, 0xce73(%rip)      # 0x16580
jmp 0x9724
leaq 0x680f(%rip), %rdi      # 0xff25
xorl %edx, %edx
movl %edx, %esi
callq 0x8cb0
jmp 0x97c9
jmp 0x9726
movq -0x8(%rbp), %rdi
addq $0xa, %rdi
callq 0x9120
cmpl $0x2a, %eax
je 0x974a
leaq 0x6805(%rip), %rdi      # 0xff44
xorl %edx, %edx
movl %edx, %esi
callq 0x8cb0
jmp 0x97c9
movq -0x8(%rbp), %rdi
addq $0xc, %rdi
callq 0x9280
movl %eax, -0x10(%rbp)
cmpl $0x8, -0x10(%rbp)
jb 0x9766
cmpl $0x10, -0x10(%rbp)
jbe 0x979b
cmpl $0x10, -0x10(%rbp)
jb 0x9779
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x10, %ecx
cmpl %ecx, %eax
jbe 0x978b
leaq 0x67db(%rip), %rdi      # 0xff5b
xorl %edx, %edx
movl %edx, %esi
callq 0x8cb0
jmp 0x97c9
leaq 0x67f1(%rip), %rdi      # 0xff83
xorl %edx, %edx
movl %edx, %esi
callq 0x8cb0
movq $0x0, 0xcdfa(%rip) # 0x165a0
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movl -0x10(%rbp), %eax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
movl -0xc(%rbp), %edx
subl $0x8, %edx
xorl %ecx, %ecx
callq 0x97d0
addq $0x10, %rsp
popq %rbp
retq
nop