// File: /workspace/github_c_makefile_star2_O1/KhronosGroup[P]dfdutils/createdfd.c
// Function: createDFD422
uint32_t *createDFD422(int bigEndian, int numSamples,
                       int bits[], int paddings[], int channels[],
                       int position_xs[], int position_ys[],
                       enum VkSuffix suffix) {
    assert(!bigEndian); (void) bigEndian;
    assert(suffix == s_UNORM); (void) suffix;

    int totalBits = 0;
    for (int i = 0; i < numSamples; ++i)
        totalBits += bits[i] + paddings[i];
    assert(totalBits % 8 == 0);

    uint32_t BDFDSize = sizeof(uint32_t) * (KHR_DF_WORD_SAMPLESTART + numSamples * KHR_DF_WORD_SAMPLEWORDS);
    uint32_t DFDSize = sizeof(uint32_t) + BDFDSize;
    uint32_t *DFD = (uint32_t *) malloc(DFDSize);
    memset(DFD, 0, DFDSize);
    DFD[0] = DFDSize;
    uint32_t *BDFD = DFD + 1;
    KHR_DFDSETVAL(BDFD, VENDORID, KHR_DF_VENDORID_KHRONOS);
    KHR_DFDSETVAL(BDFD, DESCRIPTORTYPE, KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT);
    KHR_DFDSETVAL(BDFD, VERSIONNUMBER, KHR_DF_VERSIONNUMBER_LATEST);
    KHR_DFDSETVAL(BDFD, DESCRIPTORBLOCKSIZE, BDFDSize);
    KHR_DFDSETVAL(BDFD, MODEL, KHR_DF_MODEL_YUVSDA);
    KHR_DFDSETVAL(BDFD, PRIMARIES, KHR_DF_PRIMARIES_UNSPECIFIED);
    KHR_DFDSETVAL(BDFD, TRANSFER, KHR_DF_TRANSFER_LINEAR);
    KHR_DFDSETVAL(BDFD, FLAGS, KHR_DF_FLAG_ALPHA_STRAIGHT);
    KHR_DFDSETVAL(BDFD, TEXELBLOCKDIMENSION0, 2 - 1); // 422 contains 2 x 1 blocks
    KHR_DFDSETVAL(BDFD, TEXELBLOCKDIMENSION1, 1 - 1);
    KHR_DFDSETVAL(BDFD, TEXELBLOCKDIMENSION2, 1 - 1);
    KHR_DFDSETVAL(BDFD, TEXELBLOCKDIMENSION3, 1 - 1);
    KHR_DFDSETVAL(BDFD, BYTESPLANE0, totalBits / 8);
    KHR_DFDSETVAL(BDFD, BYTESPLANE1, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE2, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE3, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE4, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE5, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE6, 0);
    KHR_DFDSETVAL(BDFD, BYTESPLANE7, 0);

    int bitOffset = 0;
    for (int i = 0; i < numSamples; ++i) {
        KHR_DFDSETSVAL(BDFD, i, BITOFFSET, bitOffset);
        KHR_DFDSETSVAL(BDFD, i, BITLENGTH, bits[i] - 1);
        KHR_DFDSETSVAL(BDFD, i, CHANNELID, channels[i]);
        KHR_DFDSETSVAL(BDFD, i, QUALIFIERS, 0); // None of: FLOAT, SIGNED, EXPONENT, LINEAR
        KHR_DFDSETSVAL(BDFD, i, SAMPLEPOSITION0, position_xs[i]);
        KHR_DFDSETSVAL(BDFD, i, SAMPLEPOSITION1, position_ys[i]);
        KHR_DFDSETSVAL(BDFD, i, SAMPLEPOSITION2, 0);
        KHR_DFDSETSVAL(BDFD, i, SAMPLEPOSITION3, 0);
        KHR_DFDSETSVAL(BDFD, i, SAMPLELOWER, 0);
        KHR_DFDSETSVAL(BDFD, i, SAMPLEUPPER, (1u << bits[i]) - 1u);
        bitOffset += bits[i] + paddings[i];
    }

    return DFD;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testl %edi, %edi
jne 0x20a5
cmpl $0x0, 0x68(%rsp)
jne 0x20c4
movq %rcx, %r15
movq %rdx, %r12
movq %r8, 0x18(%rsp)
movl %esi, %ebx
testl %esi, %esi
jle 0x1f4c
xorl %eax, %eax
xorl %ebp, %ebp
addl (%r12,%rax,4), %ebp
addl (%r15,%rax,4), %ebp
incq %rax
cmpq %rax, %rbx
jne 0x1f3a
jmp 0x1f4e
xorl %ebp, %ebp
movq %r9, 0x20(%rsp)
testb $0x7, %bpl
jne 0x20e3
movl %esi, %edi
shll $0x4, %edi
movl %esi, %eax
shll $0x14, %eax
movl %eax, 0x8(%rsp)
addl $0x1c, %edi
movq %rdi, 0x10(%rsp)
movl %esi, 0xc(%rsp)
callq 0x1080
movq %rax, %r13
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x1070
movq 0x10(%rsp), %rax
movl %eax, (%r13)
movl %r14d, 0x4(%r13)
movl 0x8(%rsp), %eax
addl $0x180002, %eax         # imm = 0x180002
movl %eax, 0x8(%r13)
movabsq $0x100010002, %rax      # imm = 0x100010002
movq %rax, 0xc(%r13)
shrl $0x3, %ebp
movzbl %bpl, %eax
movl %eax, 0x14(%r13)
movl %r14d, 0x18(%r13)
cmpl $0x0, 0xc(%rsp)
movq 0x20(%rsp), %r11
movq 0x18(%rsp), %rbp
jle 0x2093
movq 0x60(%rsp), %rax
shlq $0x2, %rbx
movl $0xffff, %edx           # imm = 0xFFFF
movl $0xff0000, %esi         # imm = 0xFF0000
xorl %edi, %edi
movzwl 0x1e(%r13,%rdi,4), %r8d
shll $0x10, %r8d
movl %r14d, %r9d
andl %edx, %r9d
orl %r9d, %r8d
movl %r8d, 0x1c(%r13,%rdi,4)
andl $0xff00ffff, %r8d       # imm = 0xFF00FFFF
movl (%r12,%rdi), %ecx
movl %ecx, %r10d
shll $0x10, %r10d
addl %esi, %r10d
andl %esi, %r10d
orl %r10d, %r8d
movl %r8d, 0x1c(%r13,%rdi,4)
movl (%rbp,%rdi), %r8d
andl $0xf, %r8d
shll $0x18, %r8d
orl %r9d, %r8d
orl %r10d, %r8d
movl %r8d, 0x1c(%r13,%rdi,4)
movl (%r11,%rdi), %r8d
movzbl %r8b, %r8d
movb %r8b, 0x20(%r13,%rdi,4)
movl (%rax,%rdi), %r9d
shll $0x8, %r9d
andl %edx, %r9d
orl %r8d, %r9d
movl %r9d, 0x20(%r13,%rdi,4)
movl $0x0, 0x24(%r13,%rdi,4)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
notl %r8d
movl %r8d, 0x28(%r13,%rdi,4)
addl %r14d, %ecx
addl (%r15,%rdi), %ecx
addq $0x4, %rdi
movl %ecx, %r14d
cmpq %rdi, %rbx
jne 0x1ff2
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x32b2(%rip), %rdi      # 0x535e
leaq 0x325e(%rip), %rsi      # 0x5311
leaq 0x32af(%rip), %rcx      # 0x5369
movl $0x18a, %edx            # imm = 0x18A
callq 0x1060
leaq 0x32f1(%rip), %rdi      # 0x53bc
leaq 0x323f(%rip), %rsi      # 0x5311
leaq 0x3290(%rip), %rcx      # 0x5369
movl $0x18b, %edx            # imm = 0x18B
callq 0x1060
leaq 0x32e4(%rip), %rdi      # 0x53ce
leaq 0x3220(%rip), %rsi      # 0x5311
leaq 0x3271(%rip), %rcx      # 0x5369
movl $0x190, %edx            # imm = 0x190
callq 0x1060