// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/corelib.c
// Function: templatize_comparator
static void templatize_comparator(
    JanetTable *env,
    int32_t flags,
    const char *name,
    int invert,
    uint32_t op,
    const char *doc) {

    /* Reg 0: Argument tuple (args) */
    /* Reg 1: Argument count (argn) */
    /* Reg 2: Jump flag (jump?) */
    /* Reg 3: Last value (last) */
    /* Reg 4: Next operand (next) */
    /* Reg 5: Loop iterator (i) */
    uint32_t comparator_asm[] = {
        SS(JOP_LENGTH, 1, 0), /* Put number of arguments in register 1 -> argn = count(args) */
        SSS(JOP_LESS_THAN_IMMEDIATE, 2, 1, 2), /* Check if numargs less than 2 */
        SI(JOP_JUMP_IF, 2, 10), /* If numargs < 2, jump to done */

        /* Prime loop */
        SSI(JOP_GET_INDEX, 3, 0, 0), /* last = args[0] */
        SI(JOP_LOAD_INTEGER, 5, 1), /* i = 1 */

        /* Main loop */
        SSS(JOP_IN, 4, 0, 5), /* next = args[i] */
        SSS(op, 2, 3, 4), /* jump? = last compare next */
        SI(JOP_JUMP_IF_NOT, 2, 7), /* if not jump? goto fail (return false) */
        SSI(JOP_ADD_IMMEDIATE, 5, 5, 1), /* i++ */
        SS(JOP_MOVE_NEAR, 3, 4), /* last = next */
        SSI(JOP_EQUALS, 2, 5, 1), /* jump? = (i == argn) */
        SI(JOP_JUMP_IF_NOT, 2, -6), /* if not jump? go back 6 */

        /* Done, return true */
        S(invert ? JOP_LOAD_FALSE : JOP_LOAD_TRUE, 3),
        S(JOP_RETURN, 3),

        /* Failed, return false */
        S(invert ? JOP_LOAD_TRUE : JOP_LOAD_FALSE, 3),
        S(JOP_RETURN, 3)
    };

    janet_quick_asm(
        env,
        flags | JANET_FUNCDEF_FLAG_VARARG,
        name,
        0,
        0,
        INT32_MAX,
        6,
        comparator_asm,
        sizeof(comparator_asm),
        doc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x13f, -0x70(%rbp)     # imm = 0x13F
movl $0x2010224, -0x6c(%rbp) # imm = 0x2010224
movl $0xa021d, -0x68(%rbp)   # imm = 0xA021D
movl $0x33d, -0x64(%rbp)     # imm = 0x33D
movl $0x1052b, -0x60(%rbp)   # imm = 0x1052B
movl $0x500043a, -0x5c(%rbp) # imm = 0x500043A
movl -0x20(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
orl $0x30000, %eax          # imm = 0x30000
orl $0x4000000, %eax        # imm = 0x4000000
movl %eax, -0x58(%rbp)
movl $0x7021e, -0x54(%rbp)   # imm = 0x7021E
movl $0x1050505, -0x50(%rbp) # imm = 0x1050505
movl $0x4031b, -0x4c(%rbp)   # imm = 0x4031B
movl $0x1050225, -0x48(%rbp) # imm = 0x1050225
movl $0xfffa021e, -0x44(%rbp) # imm = 0xFFFA021E
movl -0x1c(%rbp), %edx
movl $0x29, %eax
movl $0x2a, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl $0x300, %eax            # imm = 0x300
movl %eax, -0x40(%rbp)
movl $0x303, -0x3c(%rbp)     # imm = 0x303
movl -0x1c(%rbp), %edx
movl $0x2a, %eax
movl $0x29, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl $0x300, %eax            # imm = 0x300
movl %eax, -0x38(%rbp)
movl $0x303, -0x34(%rbp)     # imm = 0x303
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
orl $0x10000, %esi          # imm = 0x10000
movq -0x18(%rbp), %rdx
leaq -0x70(%rbp), %r10
movq -0x28(%rbp), %rax
xorl %r8d, %r8d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl %r8d, %ecx
movl $0x6, (%rsp)
movq %r10, 0x8(%rsp)
movq $0x40, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x27470
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)