// File: /workspace/github_c_makefile_star2_O3/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 0x16a8
movq %rax, %r13
movl (%rax), %esi
movq %rax, %rdi
callq 0x2d69
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 0x2478
testb $0x1, %bl
leaq 0x2226(%rip), %rax      # 0x45b4
leaq 0x222d(%rip), %rdi      # 0x45c2
cmoveq %rax, %rdi
callq 0x1040
testb $0x2, %bl
jne 0x2491
leaq 0x221f(%rip), %rdi      # 0x45cd
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x23e2
cmpl $0x1, %esi
leaq 0x3729(%rip), %rax      # 0x5aee
leaq 0x3956(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x215c(%rip), %rdi      # 0x4537
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x2411
cmpl $0x1, %esi
leaq 0x36fa(%rip), %rax      # 0x5aee
leaq 0x3927(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x214b(%rip), %rdi      # 0x4555
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x2440
cmpl $0x1, %esi
leaq 0x36cb(%rip), %rax      # 0x5aee
leaq 0x38f8(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x213c(%rip), %rdi      # 0x4575
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x256b
cmpl $0x1, %esi
leaq 0x3698(%rip), %rax      # 0x5aee
leaq 0x38c5(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x2128(%rip), %rdi      # 0x4594
xorl %eax, %eax
callq 0x1050
jmp 0x256b
addl $0xffffff00, %ebx       # imm = 0xFFFFFF00
leaq 0x2177(%rip), %rax      # 0x45fc
movslq (%rax,%rbx,4), %rdi
addq %rax, %rdi
jmp 0x25aa
leaq 0x2140(%rip), %rdi      # 0x45d8
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x24cc
cmpl $0x1, %esi
leaq 0x363f(%rip), %rax      # 0x5aee
leaq 0x386c(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x1fe5(%rip), %rdi      # 0x44aa
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x24fb
cmpl $0x1, %esi
leaq 0x3610(%rip), %rax      # 0x5aee
leaq 0x383d(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x1fd3(%rip), %rdi      # 0x44c7
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x252a
cmpl $0x1, %esi
leaq 0x35e1(%rip), %rax      # 0x5aee
leaq 0x380e(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x1fc3(%rip), %rdi      # 0x44e6
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x2559
cmpl $0x1, %esi
leaq 0x35b2(%rip), %rax      # 0x5aee
leaq 0x37df(%rip), %rdx      # 0x5d22
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x1fb2(%rip), %rdi      # 0x4504
xorl %eax, %eax
callq 0x1050
movl 0x2c(%rsp), %esi
leaq 0x1fbf(%rip), %rdi      # 0x4523
xorl %eax, %eax
callq 0x1050
testb $0x4, %bl
je 0x257c
leaq 0x2068(%rip), %rdi      # 0x45df
callq 0x1040
testb $0x8, %bl
je 0x258d
leaq 0x205c(%rip), %rdi      # 0x45e4
callq 0x1040
testb $0x10, %bl
je 0x259e
leaq 0x2056(%rip), %rdi      # 0x45ef
callq 0x1040
testb $0x20, %bl
je 0x25af
leaq 0x204c(%rip), %rdi      # 0x45f6
callq 0x1040
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop