// File: /workspace/github_c_makefile_star2_O0/Matthias-Wandel[P]imgcomp/src/exif.c
// Function: ConvertAnyFormat
double ConvertAnyFormat(void * ValuePtr, int Format)
{
    double Value;
    Value = 0;

    switch(Format){
        case FMT_SBYTE:     Value = *(signed char *)ValuePtr;  break;
        case FMT_BYTE:      Value = *(uchar *)ValuePtr;        break;

        case FMT_USHORT:    Value = Get16u(ValuePtr);          break;
        case FMT_ULONG:     Value = Get32u(ValuePtr);          break;

        case FMT_URATIONAL:
        case FMT_SRATIONAL: 
            {
                int Num,Den;
                Num = Get32s(ValuePtr);
                Den = Get32s(4+(char *)ValuePtr);
                if (Den == 0){
                    Value = 0;
                }else{
                    if (Format == FMT_SRATIONAL){
                        Value = (double)Num/Den;
                    }else{
                        Value = (double)(unsigned)Num/(double)(unsigned)Den;
                    }
                }
                break;
            }

        case FMT_SSHORT:    Value = (signed short)Get16u(ValuePtr);  break;
        case FMT_SLONG:     Value = Get32s(ValuePtr);                break;

        // Not sure if this is correct (never seen float used in Exif format)
        case FMT_SINGLE:    Value = (double)*(float *)ValuePtr;      break;
        case FMT_DOUBLE:    Value = *(double *)ValuePtr;             break;

        default:
            ErrNonfatal("Illegal format code %d in Exif header",Format,0);
    }
    return Value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movl -0xc(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xb, %eax
ja 0x95e9
movq -0x28(%rbp), %rax
leaq 0x672a(%rip), %rcx      # 0xfc00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rdi
callq 0x9120
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rdi
callq 0x9280
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rdi
callq 0x9170
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
callq 0x9170
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x9566
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x959c
cmpl $0xa, -0xc(%rbp)
jne 0x9581
cvtsi2sdl -0x1c(%rbp), %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x959a
movl -0x1c(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x20(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x959c
jmp 0x95fa
movq -0x8(%rbp), %rdi
callq 0x9120
cwtl
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rdi
callq 0x9170
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x95fa
movl -0xc(%rbp), %esi
leaq 0x6898(%rip), %rdi      # 0xfe8b
xorl %edx, %edx
callq 0x8cb0
movsd -0x18(%rbp), %xmm0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)