// File: /workspace/github_c_makefile_star2_O2/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
leaq 0x20(%rsp), %rbx
andq $0x0, (%rbx)
leaq 0x18(%rsp), %r14
andq $0x0, (%r14)
leaq 0x10(%rsp), %r15
andq $0x0, (%r15)
leaq 0x8(%rsp), %r12
andq $0x0, (%r12)
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
xorl %edi, %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x16b8
movq %rax, %r13
movl (%rax), %esi
movq %rax, %rdi
callq 0x2b18
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 0x227e
testb $0x1, %bl
leaq 0x2410(%rip), %rax      # 0x45a4
leaq 0x2417(%rip), %rdi      # 0x45b2
cmoveq %rax, %rdi
callq 0x1040
testb $0x2, %bl
jne 0x2297
leaq 0x2409(%rip), %rdi      # 0x45bd
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x21e8
cmpl $0x1, %esi
leaq 0x38f3(%rip), %rax      # 0x5abe
leaq 0x3b20(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x2346(%rip), %rdi      # 0x4527
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x2217
cmpl $0x1, %esi
leaq 0x38c4(%rip), %rax      # 0x5abe
leaq 0x3af1(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x2335(%rip), %rdi      # 0x4545
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x2246
cmpl $0x1, %esi
leaq 0x3895(%rip), %rax      # 0x5abe
leaq 0x3ac2(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x2326(%rip), %rdi      # 0x4565
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x2371
cmpl $0x1, %esi
leaq 0x3862(%rip), %rax      # 0x5abe
leaq 0x3a8f(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x2312(%rip), %rdi      # 0x4584
xorl %eax, %eax
callq 0x1050
jmp 0x2371
addl $0xffffff00, %ebx       # imm = 0xFFFFFF00
leaq 0x2361(%rip), %rax      # 0x45ec
movslq (%rax,%rbx,4), %rdi
addq %rax, %rdi
jmp 0x23b0
leaq 0x232a(%rip), %rdi      # 0x45c8
callq 0x1040
movl 0x24(%rsp), %esi
testl %esi, %esi
je 0x22d2
cmpl $0x1, %esi
leaq 0x3809(%rip), %rax      # 0x5abe
leaq 0x3a36(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x20(%rsp), %ecx
leaq 0x21cf(%rip), %rdi      # 0x449a
xorl %eax, %eax
callq 0x1050
movl 0x1c(%rsp), %esi
testl %esi, %esi
je 0x2301
cmpl $0x1, %esi
leaq 0x37da(%rip), %rax      # 0x5abe
leaq 0x3a07(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x18(%rsp), %ecx
leaq 0x21bd(%rip), %rdi      # 0x44b7
xorl %eax, %eax
callq 0x1050
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x2330
cmpl $0x1, %esi
leaq 0x37ab(%rip), %rax      # 0x5abe
leaq 0x39d8(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x10(%rsp), %ecx
leaq 0x21ad(%rip), %rdi      # 0x44d6
xorl %eax, %eax
callq 0x1050
movl 0xc(%rsp), %esi
testl %esi, %esi
je 0x235f
cmpl $0x1, %esi
leaq 0x377c(%rip), %rax      # 0x5abe
leaq 0x39a9(%rip), %rdx      # 0x5cf2
cmoveq %rax, %rdx
movl 0x8(%rsp), %ecx
leaq 0x219c(%rip), %rdi      # 0x44f4
xorl %eax, %eax
callq 0x1050
movl 0x2c(%rsp), %esi
leaq 0x21a9(%rip), %rdi      # 0x4513
xorl %eax, %eax
callq 0x1050
testb $0x4, %bl
je 0x2382
leaq 0x2252(%rip), %rdi      # 0x45cf
callq 0x1040
testb $0x8, %bl
je 0x2393
leaq 0x2246(%rip), %rdi      # 0x45d4
callq 0x1040
testb $0x10, %bl
je 0x23a4
leaq 0x2240(%rip), %rdi      # 0x45df
callq 0x1040
testb $0x20, %bl
je 0x23b5
leaq 0x2236(%rip), %rdi      # 0x45e6
callq 0x1040
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nopl (%rax)