// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt__GetGlyphGPOSInfoAdvance
static stbtt_int32  stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
{
    stbtt_uint16 lookupListOffset;
    stbtt_uint8 *lookupList;
    stbtt_uint16 lookupCount;
    stbtt_uint8 *data;
    stbtt_int32 i;

    if (!info->gpos) return 0;

    data = info->data + info->gpos;

    if (ttUSHORT(data+0) != 1) return 0; // Major version 1
    if (ttUSHORT(data+2) != 0) return 0; // Minor version 0

    lookupListOffset = ttUSHORT(data+8);
    lookupList = data + lookupListOffset;
    lookupCount = ttUSHORT(lookupList);

    for (i=0; i<lookupCount; ++i) {
        stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
        stbtt_uint8 *lookupTable = lookupList + lookupOffset;

        stbtt_uint16 lookupType = ttUSHORT(lookupTable);
        stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
        stbtt_uint8 *subTableOffsets = lookupTable + 6;
        switch(lookupType) {
            case 2: { // Pair Adjustment Positioning Subtable
                stbtt_int32 sti;
                for (sti=0; sti<subTableCount; sti++) {
                    stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
                    stbtt_uint8 *table = lookupTable + subtableOffset;
                    stbtt_uint16 posFormat = ttUSHORT(table);
                    stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
                    stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
                    if (coverageIndex == -1) continue;

                    switch (posFormat) {
                        case 1: {
                            stbtt_int32 l, r, m;
                            int straw, needle;
                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
                            stbtt_int32 valueRecordPairSizeInBytes = 2;
                            stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
                            stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
                            stbtt_uint8 *pairValueTable = table + pairPosOffset;
                            stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
                            stbtt_uint8 *pairValueArray = pairValueTable + 2;
                            // TODO: Support more formats.
                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
                            if (valueFormat1 != 4) return 0;
                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
                            if (valueFormat2 != 0) return 0;

                            STBTT_assert(coverageIndex < pairSetCount);
                            STBTT__NOTUSED(pairSetCount);

                            needle=glyph2;
                            r=pairValueCount-1;
                            l=0;

                            // Binary search.
                            while (l <= r) {
                                stbtt_uint16 secondGlyph;
                                stbtt_uint8 *pairValue;
                                m = (l + r) >> 1;
                                pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
                                secondGlyph = ttUSHORT(pairValue);
                                straw = secondGlyph;
                                if (needle < straw)
                                    r = m - 1;
                                else if (needle > straw)
                                    l = m + 1;
                                else {
                                    stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
                                    return xAdvance;
                                }
                            }
                        } break;

                        case 2: {
                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);

                            stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
                            stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
                            int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
                            int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);

                            stbtt_uint16 class1Count = ttUSHORT(table + 12);
                            stbtt_uint16 class2Count = ttUSHORT(table + 14);
                            STBTT_assert(glyph1class < class1Count);
                            STBTT_assert(glyph2class < class2Count);

                            // TODO: Support more formats.
                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
                            if (valueFormat1 != 4) return 0;
                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
                            if (valueFormat2 != 0) return 0;

                            if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) {
                                stbtt_uint8 *class1Records = table + 16;
                                stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count);
                                stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class);
                                return xAdvance;
                            }
                        } break;

                        default: {
                            // There are no other cases.
                            STBTT_assert(0);
                            break;
                        };
                    }
                }
                break;
            };

            default:
                // TODO: Implement other stuff.
                break;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x616b
movl $0x0, -0x4(%rbp)
jmp 0x670b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x30(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4990
movzwl %ax, %eax
cmpl $0x1, %eax
je 0x619f
movl $0x0, -0x4(%rbp)
jmp 0x670b
movq -0x38(%rbp), %rdi
addq $0x2, %rdi
callq 0x4990
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x61c0
movl $0x0, -0x4(%rbp)
jmp 0x670b
movq -0x38(%rbp), %rdi
addq $0x8, %rdi
callq 0x4990
movw %ax, -0x1a(%rbp)
movq -0x38(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4990
movw %ax, -0x2a(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movzwl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x6704
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl %ecx, %ecx
movslq %ecx, %rcx
leaq 0x2(%rax,%rcx), %rdi
callq 0x4990
movw %ax, -0x3e(%rbp)
movq -0x28(%rbp), %rax
movzwl -0x3e(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x4990
movw %ax, -0x4a(%rbp)
movq -0x48(%rbp), %rdi
addq $0x4, %rdi
callq 0x4990
movw %ax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x58(%rbp)
movw -0x4a(%rbp), %ax
subw $0x2, %ax
jne 0x66f2
jmp 0x6269
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movzwl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66f0
movq -0x58(%rbp), %rdi
movl -0x5c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x5e(%rbp)
movq -0x48(%rbp), %rax
movzwl -0x5e(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4990
movw %ax, -0x6a(%rbp)
movq -0x68(%rbp), %rdi
addq $0x2, %rdi
callq 0x4990
movw %ax, -0x6c(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0x6c(%rbp), %eax
cltq
addq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x10eb0
movl %eax, -0x70(%rbp)
cmpl $-0x1, -0x70(%rbp)
jne 0x62e9
jmp 0x66e2
movzwl -0x6a(%rbp), %eax
movl %eax, -0xe8(%rbp)
subl $0x1, %eax
je 0x630e
jmp 0x62fa
movl -0xe8(%rbp), %eax
subl $0x2, %eax
je 0x64de
jmp 0x66c1
movq -0x68(%rbp), %rdi
addq $0x4, %rdi
callq 0x4990
movw %ax, -0x86(%rbp)
movq -0x68(%rbp), %rdi
addq $0x6, %rdi
callq 0x4990
movw %ax, -0x88(%rbp)
movl $0x2, -0x8c(%rbp)
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
callq 0x4990
movw %ax, -0x8e(%rbp)
movq -0x68(%rbp), %rdi
addq $0xa, %rdi
movl -0x70(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x90(%rbp)
movq -0x68(%rbp), %rax
movzwl -0x90(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x4990
movw %ax, -0x9a(%rbp)
movq -0x98(%rbp), %rax
addq $0x2, %rax
movq %rax, -0xa8(%rbp)
movzwl -0x86(%rbp), %eax
cmpl $0x4, %eax
je 0x63c7
movl $0x0, -0x4(%rbp)
jmp 0x670b
movzwl -0x88(%rbp), %eax
cmpl $0x0, %eax
je 0x63df
movl $0x0, -0x4(%rbp)
jmp 0x670b
movl -0x70(%rbp), %eax
movzwl -0x8e(%rbp), %ecx
cmpl %ecx, %eax
jge 0x63ef
jmp 0x640e
leaq 0x10bb6(%rip), %rdi     # 0x16fac
leaq 0x103ba(%rip), %rsi     # 0x167b7
movl $0x9a0, %edx            # imm = 0x9A0
leaq 0x10bc0(%rip), %rcx     # 0x16fc9
callq 0x10a0
movl -0x18(%rbp), %eax
movl %eax, -0x84(%rbp)
movzwl -0x9a(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x78(%rbp), %eax
jg 0x64d9
movl -0x74(%rbp), %eax
addl -0x78(%rbp), %eax
sarl %eax
movl %eax, -0x7c(%rbp)
movq -0xa8(%rbp), %rax
movl -0x8c(%rbp), %ecx
addl $0x2, %ecx
imull -0x7c(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x4990
movw %ax, -0xaa(%rbp)
movzwl -0xaa(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x80(%rbp), %eax
jge 0x6496
movl -0x7c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x64d4
movl -0x84(%rbp), %eax
cmpl -0x80(%rbp), %eax
jle 0x64ac
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x64d2
movq -0xb8(%rbp), %rdi
addq $0x2, %rdi
callq 0x49b0
movw %ax, -0xba(%rbp)
movswl -0xba(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x670b
jmp 0x64d4
jmp 0x642b
jmp 0x66e0
movq -0x68(%rbp), %rdi
addq $0x4, %rdi
callq 0x4990
movw %ax, -0xbc(%rbp)
movq -0x68(%rbp), %rdi
addq $0x6, %rdi
callq 0x4990
movw %ax, -0xbe(%rbp)
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
callq 0x4990
movw %ax, -0xc0(%rbp)
movq -0x68(%rbp), %rdi
addq $0xa, %rdi
callq 0x4990
movw %ax, -0xc2(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xc0(%rbp), %eax
cltq
addq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x11090
movl %eax, -0xc8(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xc2(%rbp), %eax
cltq
addq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x11090
movl %eax, -0xcc(%rbp)
movq -0x68(%rbp), %rdi
addq $0xc, %rdi
callq 0x4990
movw %ax, -0xce(%rbp)
movq -0x68(%rbp), %rdi
addq $0xe, %rdi
callq 0x4990
movw %ax, -0xd0(%rbp)
movl -0xc8(%rbp), %eax
movzwl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x65a5
jmp 0x65c4
leaq 0x10a6a(%rip), %rdi     # 0x17016
leaq 0x10204(%rip), %rsi     # 0x167b7
movl $0x9c5, %edx            # imm = 0x9C5
leaq 0x10a0a(%rip), %rcx     # 0x16fc9
callq 0x10a0
movl -0xcc(%rbp), %eax
movzwl -0xd0(%rbp), %ecx
cmpl %ecx, %eax
jge 0x65d7
jmp 0x65f6
leaq 0x10a52(%rip), %rdi     # 0x17030
leaq 0x101d2(%rip), %rsi     # 0x167b7
movl $0x9c6, %edx            # imm = 0x9C6
leaq 0x109d8(%rip), %rcx     # 0x16fc9
callq 0x10a0
movzwl -0xbc(%rbp), %eax
cmpl $0x4, %eax
je 0x660e
movl $0x0, -0x4(%rbp)
jmp 0x670b
movzwl -0xbe(%rbp), %eax
cmpl $0x0, %eax
je 0x6626
movl $0x0, -0x4(%rbp)
jmp 0x670b
cmpl $0x0, -0xc8(%rbp)
jl 0x66bf
movl -0xc8(%rbp), %eax
movzwl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66bf
cmpl $0x0, -0xcc(%rbp)
jl 0x66bf
movl -0xcc(%rbp), %eax
movzwl -0xd0(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66bf
movq -0x68(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movl -0xc8(%rbp), %ecx
movzwl -0xd0(%rbp), %edx
imull %edx, %ecx
shll %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rdi
movl -0xcc(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x49b0
movw %ax, -0xe2(%rbp)
movswl -0xe2(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x670b
jmp 0x66e0
leaq 0x101ed(%rip), %rdi     # 0x168b5
leaq 0x100e8(%rip), %rsi     # 0x167b7
movl $0x9d8, %edx            # imm = 0x9D8
leaq 0x108ee(%rip), %rcx     # 0x16fc9
callq 0x10a0
jmp 0x66e2
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x6270
jmp 0x66f4
jmp 0x66f4
jmp 0x66f6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x61f7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)