// File: /workspace/github_c_makefile_star2_O1/KhronosGroup[P]dfdutils/interpretdfdtest.c
// Function: main
int main(int argc, char** argv)
{
    const char *errorText[] = {
        "UNSUPPORTED_NONTRIVIAL_ENDIANNESS",
        "UNSUPPORTED_MULTIPLE_SAMPLE_LOCATIONS",
        "UNSUPPORTED_MULTIPLE_PLANES",
        "UNSUPPORTED_CHANNEL_TYPES",
        "UNSUPPORTED_MIXED_CHANNELS"};

    InterpretedDFDChannel R = {0,0}, G = {0,0}, B = {0,0}, A = {0,0};
    uint32_t wordSize;
    enum InterpretDFDResult t;

#if 0
    t = interpretDFD(dfd1, &R, &G, &B, &A, &wordSize);
#else
#if 0
    uint32_t *d = createDFDUnpacked(1,2,4,0,s_UNORM);
#elif 0
    int channels[] = {0,1,2,3};
    int bits[] = {10,10,10,2};
    uint32_t *d = createDFDPacked(1,4,bits,channels,s_UNORM);
#elif 0
    int channels[] = {0,1,2};
    int bits[] = {5,6,5};
    uint32_t *d = createDFDPacked(1,3,bits,channels,s_UNORM);
#elif 1
    uint32_t *d = createDFDUnpacked(0, 3, 1, 0, s_UNORM);
#endif

    printDFD(d, *d);
    t = interpretDFD(d, &R, &G, &B, &A, &wordSize);
#endif

    if (t & i_UNSUPPORTED_ERROR_BIT) {
        printf("%s\n", errorText[t - i_UNSUPPORTED_ERROR_BIT]);
        return 0;
    } else {
        if (t & i_BIG_ENDIAN_FORMAT_BIT) {
            printf("Big-endian\n");
        } else {
            printf("Little-endian\n");
        }
        if (t & i_PACKED_FORMAT_BIT) {
            printf("Packed\n");
            if (R.size > 0) {
                printf("%u red bit%s starting at %u\n", R.size, R.size>1?"s":"", R.offset);
            }
            if (G.size > 0) {
                printf("%u green bit%s starting at %u\n", G.size, G.size>1?"s":"", G.offset);
            }
            if (B.size > 0) {
                printf("%u blue bit%s starting at %u\n", B.size, B.size>1?"s":"", B.offset);
            }
            if (A.size > 0) {
                printf("%u alpha bit%s starting at %u\n", A.size, A.size>1?"s":"", A.offset);
            }
            printf("Total word size %u\n", wordSize);
        } else {
            printf("Not packed\n");
            if (R.size > 0) {
                printf("%u red byte%s starting at %u\n", R.size, R.size>1?"s":"", R.offset);
            }
            if (G.size > 0) {
                printf("%u green byte%s starting at %u\n", G.size, G.size>1?"s":"", G.offset);
            }
            if (B.size > 0) {
                printf("%u blue byte%s starting at %u\n", B.size, B.size>1?"s":"", B.offset);
            }
            if (A.size > 0) {
                printf("%u alpha byte%s starting at %u\n", A.size, A.size>1?"s":"", A.offset);
            }
        }
        if (t & i_SRGB_FORMAT_BIT) {
            printf("sRGB\n");
        }
        if (t & i_NORMALIZED_FORMAT_BIT) {
            printf("Normalized\n");
        }
        if (t & i_SIGNED_FORMAT_BIT) {
            printf("Signed\n");
        }
        if (t & i_FLOAT_FORMAT_BIT) {
            printf("Float\n");
        }
    }
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
xorl %eax, %eax
leaq 0x20(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x18(%rsp), %r14
movq %rax, (%r14)
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
leaq 0x8(%rsp), %r12
movq %rax, (%r12)
xorl %edi, %edi
movl $0x3, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1834
movq %rax, %r13
movl (%rax), %esi
movq %rax, %rdi
callq 0x2f48
leaq 0x2c(%rsp), %r9
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x118c
movl %eax, %ebx
btl $0x8, %eax
jb 0x2654
testb $0x1, %bl
leaq 0x301a(%rip), %rax      # 0x5584
leaq 0x3021(%rip), %rdi      # 0x5592
cmoveq %rax, %rdi
callq 0x1040
testb $0x2, %bl
jne 0x266d
leaq 0x3013(%rip), %rdi      # 0x559d
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x25be
cmpl $0x1, %esi
leaq 0x4529(%rip), %rax      # 0x6aca
leaq 0x4756(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x2f50(%rip), %rdi      # 0x5507
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x25ed
cmpl $0x1, %esi
leaq 0x44fa(%rip), %rax      # 0x6aca
leaq 0x4727(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x2f3f(%rip), %rdi      # 0x5525
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x261c
cmpl $0x1, %esi
leaq 0x44cb(%rip), %rax      # 0x6aca
leaq 0x46f8(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x2f30(%rip), %rdi      # 0x5545
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x2747
cmpl $0x1, %esi
leaq 0x4498(%rip), %rax      # 0x6aca
leaq 0x46c5(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x2f1c(%rip), %rdi      # 0x5564
xorl %eax, %eax
callq 0x1050
jmp 0x2747
addl $0xffffff00, %ebx       # imm = 0xFFFFFF00
leaq 0x2f6b(%rip), %rax      # 0x55cc
movslq (%rax,%rbx,4), %rdi
addq %rax, %rdi
jmp 0x2786
leaq 0x2f34(%rip), %rdi      # 0x55a8
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x26a8
cmpl $0x1, %esi
leaq 0x443f(%rip), %rax      # 0x6aca
leaq 0x466c(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x2dd9(%rip), %rdi      # 0x547a
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x26d7
cmpl $0x1, %esi
leaq 0x4410(%rip), %rax      # 0x6aca
leaq 0x463d(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x2dc7(%rip), %rdi      # 0x5497
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x2706
cmpl $0x1, %esi
leaq 0x43e1(%rip), %rax      # 0x6aca
leaq 0x460e(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x2db7(%rip), %rdi      # 0x54b6
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x2735
cmpl $0x1, %esi
leaq 0x43b2(%rip), %rax      # 0x6aca
leaq 0x45df(%rip), %rdx      # 0x6cfe
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x2da6(%rip), %rdi      # 0x54d4
xorl %eax, %eax
callq 0x1050
movl 0x2c(%rsp), %esi
leaq 0x2db3(%rip), %rdi      # 0x54f3
xorl %eax, %eax
callq 0x1050
testb $0x4, %bl
je 0x2758
leaq 0x2e5c(%rip), %rdi      # 0x55af
callq 0x1040
testb $0x8, %bl
je 0x2769
leaq 0x2e50(%rip), %rdi      # 0x55b4
callq 0x1040
testb $0x10, %bl
je 0x277a
leaq 0x2e4a(%rip), %rdi      # 0x55bf
callq 0x1040
testb $0x20, %bl
je 0x278b
leaq 0x2e40(%rip), %rdi      # 0x55c6
callq 0x1040
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop