// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movl 0x58(%rsp), %eax
movl 0x50(%rsp), %eax
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movl %edx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movl %r8d, 0x30(%rsp)
movl %r9d, 0x2c(%rsp)
movq 0x40(%rsp), %rax
addq $0x4, %rax
addq $0x18, %rax
movl 0x3c(%rsp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
cmpl $0x3, 0x38(%rsp)
jne 0x2339
movl $0xf, 0x38(%rsp)
cmpl $0x3, 0x38(%rsp)
jne 0x2348
movl $0xf, 0x38(%rsp)
movl 0x38(%rsp), %edi
movl 0x58(%rsp), %esi
callq 0x3630
movl %eax, 0x38(%rsp)
movl 0x30(%rsp), %ecx
movl 0x34(%rsp), %eax
shll $0x10, %eax
addl $0xffff0000, %eax       # imm = 0xFFFF0000
orl %eax, %ecx
movl 0x38(%rsp), %eax
shll $0x18, %eax
orl %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
movq 0x18(%rsp), %rax
movl $0x0, 0x4(%rax)
movl 0x58(%rsp), %eax
movq %rax, 0x10(%rsp)
subq $0x8, %rax
ja 0x23ad
movq 0x10(%rsp), %rax
leaq 0x4cea(%rip), %rcx      # 0x708c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x23ad
cmpl $0x20, 0x34(%rsp)
jle 0x23be
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x23d0
movl 0x34(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, 0x24(%rsp)
movl $0x0, 0x28(%rsp)
jmp 0x24b8
cmpl $0x20, 0x34(%rsp)
jle 0x23ee
movl $0x7fffffff, 0x24(%rsp) # imm = 0x7FFFFFFF
jmp 0x2426
cmpl $0x0, 0x2c(%rsp)
je 0x240c
movl 0x34(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x241e
movl 0x34(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
xorl $-0x1, %eax
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x2443
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x24b8
movl 0x50(%rsp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x24(%rsp)
movl $0x0, 0x28(%rsp)
jmp 0x24b8
movl 0x50(%rsp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x24(%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
jmp 0x24b8
movss 0x4b79(%rip), %xmm0     # 0x7004
movss %xmm0, 0x24(%rsp)
movss 0x4bef(%rip), %xmm0     # 0x7088
movss %xmm0, 0x28(%rsp)
jmp 0x24b8
movss 0x4b5b(%rip), %xmm0     # 0x7004
movss %xmm0, 0x24(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movl 0x28(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0x24(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xc(%rax)
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)