// File: /workspace/github_c_makefile_star2_O1/KhronosGroup[P]dfdutils/createdfd.c
// Function: writeSample
static void writeSample(uint32_t *DFD, int sampleNo, int channel,
                        int bits, int offset,
                        int topSample, int bottomSample, enum VkSuffix suffix)
{
    // Use this to avoid type-punning complaints from the gcc optimizer
    // with -Wall.
    union {
        uint32_t i;
        float f;
    } lower, upper;
    uint32_t *sample = DFD + 1 + KHR_DF_WORD_SAMPLESTART + sampleNo * KHR_DF_WORD_SAMPLEWORDS;
    if (channel == 3) channel = KHR_DF_CHANNEL_RGBSDA_ALPHA;

    if (channel == 3) channel = KHR_DF_CHANNEL_RGBSDA_ALPHA;
    channel = setChannelFlags(channel, suffix);

    sample[KHR_DF_SAMPLEWORD_BITOFFSET] =
        (offset << KHR_DF_SAMPLESHIFT_BITOFFSET) |
        ((bits - 1) << KHR_DF_SAMPLESHIFT_BITLENGTH) |
        (channel << KHR_DF_SAMPLESHIFT_CHANNELID);

    sample[KHR_DF_SAMPLEWORD_SAMPLEPOSITION_ALL] = 0;

    switch (suffix) {
    case s_UNORM:
    case s_SRGB:
    default:
        if (bits > 32) {
            upper.i = 0xFFFFFFFFU;
        } else {
            upper.i = (uint32_t)((1U << bits) - 1U);
        }
        lower.i = 0U;
        break;
    case s_SNORM:
        if (bits > 32) {
            upper.i = 0x7FFFFFFF;
        } else {
            upper.i = topSample ? (1U << (bits - 1)) - 1 : (1U << bits) - 1;
        }
        lower.i = ~upper.i;
        if (bottomSample) lower.i += 1;
        break;
    case s_USCALED:
    case s_UINT:
        upper.i = bottomSample ? 1U : 0U;
        lower.i = 0U;
        break;
    case s_SSCALED:
    case s_SINT:
        upper.i = bottomSample ? 1U : 0U;
        lower.i = ~0U;
        break;
    case s_SFLOAT:
        upper.f = 1.0f;
        lower.f = -1.0f;
        break;
    case s_UFLOAT:
        upper.f = 1.0f;
        lower.f = 0.0f;
        break;
    }
    sample[KHR_DF_SAMPLEWORD_SAMPLELOWER] = lower.i;
    sample[KHR_DF_SAMPLEWORD_SAMPLEUPPER] = upper.i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebp
movl %r8d, %r12d
movl %ecx, %r14d
movq %rdi, %rbx
movl 0x48(%rsp), %r15d
shll $0x2, %esi
movslq %esi, %r13
cmpl $0x3, %edx
movl $0xf, %edi
cmovnel %edx, %edi
movl %r15d, %esi
callq 0x226c
leal -0x1(%r14), %ecx
movl %ecx, %edx
shll $0x10, %edx
orl %r12d, %edx
shll $0x18, %eax
orl %edx, %eax
movl %eax, 0x1c(%rbx,%r13,4)
movl $0x0, 0x20(%rbx,%r13,4)
decl %r15d
cmpl $0x6, %r15d
ja 0x1acc
movl 0x40(%rsp), %edx
movl $0x3f800000, %eax       # imm = 0x3F800000
leaq 0x3564(%rip), %rsi      # 0x5010
movslq (%rsi,%r15,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
xorl %eax, %eax
testl %edx, %edx
setne %al
jmp 0x1ae4
xorl %eax, %eax
testl %edx, %edx
setne %al
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x1ae6
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r14d, %ecx
shll %cl, %eax
cmpl $0x21, %r14d
notl %eax
cmovgel %edx, %eax
xorl %ecx, %ecx
movl %ecx, 0x24(%rbx,%r13,4)
movl %eax, 0x28(%rbx,%r13,4)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xbf800000, %ecx       # imm = 0xBF800000
jmp 0x1ae6
testl %ebp, %ebp
cmovel %r14d, %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
cmpl $0x21, %r14d
notl %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovll %esi, %eax
movl %eax, %esi
notl %esi
movl %eax, %ecx
negl %ecx
testl %edx, %edx
cmovel %esi, %ecx
jmp 0x1ae6