// File: /workspace/github_c_makefile_star2_O2/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
pushq $0xf
popq %rdi
cmovnel %edx, %edi
movl %r15d, %esi
callq 0x1f80
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)
andl $0x0, 0x20(%rbx,%r13,4)
decl %r15d
cmpl $0x6, %r15d
ja 0x1930
movl 0x40(%rsp), %edx
movl $0x3f800000, %eax       # imm = 0x3F800000
leaq 0x26fe(%rip), %rsi      # 0x4010
movslq (%rsi,%r15,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
xorl %eax, %eax
testl %edx, %edx
setne %al
jmp 0x1943
xorl %eax, %eax
testl %edx, %edx
setne %al
pushq $-0x1
popq %rcx
jmp 0x1945
pushq $-0x1
popq %rdx
movl %edx, %eax
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 0x1945
testl %ebp, %ebp
cmovel %r14d, %ecx
pushq $-0x1
popq %rsi
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 0x1945