// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt__GetCoverageIndex
static stbtt_int32  stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
{
    stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
    switch(coverageFormat) {
        case 1: {
            stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);

            // Binary search.
            stbtt_int32 l=0, r=glyphCount-1, m;
            int straw, needle=glyph;
            while (l <= r) {
                stbtt_uint8 *glyphArray = coverageTable + 4;
                stbtt_uint16 glyphID;
                m = (l + r) >> 1;
                glyphID = ttUSHORT(glyphArray + 2 * m);
                straw = glyphID;
                if (needle < straw)
                    r = m - 1;
                else if (needle > straw)
                    l = m + 1;
                else {
                     return m;
                }
            }
        } break;

        case 2: {
            stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
            stbtt_uint8 *rangeArray = coverageTable + 4;

            // Binary search.
            stbtt_int32 l=0, r=rangeCount-1, m;
            int strawStart, strawEnd, needle=glyph;
            while (l <= r) {
                stbtt_uint8 *rangeRecord;
                m = (l + r) >> 1;
                rangeRecord = rangeArray + 6 * m;
                strawStart = ttUSHORT(rangeRecord);
                strawEnd = ttUSHORT(rangeRecord + 2);
                if (needle < strawStart)
                    r = m - 1;
                else if (needle > strawEnd)
                    l = m + 1;
                else {
                    stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
                    return startCoverageIndex + glyph - strawStart;
                }
            }
        } break;

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

    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4990
movw %ax, -0x16(%rbp)
movzwl -0x16(%rbp), %eax
movl %eax, -0x70(%rbp)
subl $0x1, %eax
je 0x10eeb
jmp 0x10eda
movl -0x70(%rbp), %eax
subl $0x2, %eax
je 0x10f8a
jmp 0x11058
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
callq 0x4990
movw %ax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movzwl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x10f85
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
sarl %eax
movl %eax, -0x24(%rbp)
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x3a(%rbp)
movzwl -0x3a(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x10f63
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x10f83
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x10f76
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x10f81
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1107e
jmp 0x10f83
jmp 0x10f13
jmp 0x11077
movq -0x10(%rbp), %rdi
addq $0x2, %rdi
callq 0x4990
movw %ax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movzwl -0x3c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jg 0x11056
movl -0x4c(%rbp), %eax
addl -0x50(%rbp), %eax
sarl %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
imull $0x6, -0x54(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x58(%rbp)
movq -0x68(%rbp), %rdi
addq $0x2, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x5c(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x58(%rbp), %eax
jge 0x1101c
movl -0x54(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x11051
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x1102f
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1104f
movq -0x68(%rbp), %rdi
addq $0x4, %rdi
callq 0x4990
movw %ax, -0x6a(%rbp)
movzwl -0x6a(%rbp), %eax
addl -0x14(%rbp), %eax
subl -0x58(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1107e
jmp 0x11051
jmp 0x10fbe
jmp 0x11077
leaq 0x5856(%rip), %rdi      # 0x168b5
leaq 0x5751(%rip), %rsi      # 0x167b7
movl $0x92e, %edx            # imm = 0x92E
leaq 0x5fd8(%rip), %rcx      # 0x1704a
callq 0x10a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)