// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/cfuns.c
// Function: opreduce
static JanetSlot opreduce(
    JanetFopts opts,
    JanetSlot *args,
    int op,
    int opim,
    Janet nullary,
    Janet unary) {
    JanetCompiler *c = opts.compiler;
    int32_t i, len;
    int8_t imm = 0;
    len = janet_v_count(args);
    JanetSlot t;
    if (len == 0) {
        return janetc_cslot(nullary);
    } else if (len == 1) {
        t = janetc_gettarget(opts);
        /* Special case subtract to be times -1 */
        if (op == JOP_SUBTRACT) {
            janetc_emit_ssi(c, JOP_MULTIPLY_IMMEDIATE, t, args[0], -1, 1);
        } else {
            janetc_emit_sss(c, op, t, janetc_cslot(unary), args[0], 1);
        }
        return t;
    }
    t = janetc_gettarget(opts);
    if (opim && can_slot_be_imm(args[1], &imm)) {
        janetc_emit_ssi(c, opim, t, args[0], imm, 1);
    } else {
        janetc_emit_sss(c, op, t, args[0], args[1], 1);
    }
    for (i = 2; i < len; i++) {
        if (opim && can_slot_be_imm(args[i], &imm)) {
            janetc_emit_ssi(c, opim, t, t, imm, 1);
        } else {
            janetc_emit_sss(c, op, t, t, args[i], 1);
        }
    }
    return t;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, -0x58(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movb $0x0, -0x29(%rbp)
testq %rsi, %rsi
je 0x199fb
movl %edx, %r13d
movq %rsi, %r15
leaq 0x10(%rbp), %rax
movslq -0x4(%rsi), %r14
cmpq $0x1, %r14
je 0x19a12
testl %r14d, %r14d
jne 0x19a7b
movq -0x58(%rbp), %rbx
movq %rbx, %rdi
movq %r8, %rsi
callq 0x19f5c
movq %rbx, %rax
jmp 0x19c62
movq %r9, %rbx
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x50(%rbp), %rdi
callq 0x1aa9e
cmpl $0x8, %r13d
jne 0x19bf9
movq 0x10(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rsp)
pushq $0x9
popq %rsi
pushq $-0x1
popq %rdx
pushq $0x1
popq %rcx
movq -0x38(%rbp), %rdi
callq 0x1ffee
jmp 0x19c4f
movl %ecx, %r12d
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x50(%rbp), %rdi
callq 0x1aa9e
testl %r12d, %r12d
je 0x19afd
movq 0x28(%r15), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%r15), %xmm0
movups %xmm0, (%rsp)
leaq -0x29(%rbp), %rdi
callq 0x19c74
testl %eax, %eax
je 0x19afd
movsbl -0x29(%rbp), %edx
movq 0x10(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rsp)
movzbl %r12b, %esi
pushq $0x1
popq %rcx
movq -0x38(%rbp), %rdi
callq 0x1ffee
jmp 0x19b43
movq 0x28(%r15), %rax
movq %rax, 0x40(%rsp)
movups 0x18(%r15), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rsp)
movzbl %r13b, %esi
pushq $0x1
popq %rdx
movq -0x38(%rbp), %rdi
callq 0x2010f
addq $0x30, %r15
pushq $0x2
popq %rbx
movzbl %r13b, %r13d
movzbl %r12b, %eax
movl %eax, -0x5c(%rbp)
cmpq %r14, %rbx
jge 0x19c4f
testl %r12d, %r12d
je 0x19bb1
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq -0x29(%rbp), %rdi
callq 0x19c74
testl %eax, %eax
je 0x19bb1
movsbl -0x29(%rbp), %edx
movq -0x40(%rbp), %rax
movq %rax, 0x28(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movups %xmm0, (%rsp)
movq -0x38(%rbp), %rdi
movl -0x5c(%rbp), %esi
pushq $0x1
popq %rcx
callq 0x1ffee
jmp 0x19bed
movq 0x10(%r15), %rax
movq %rax, 0x40(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x30(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x28(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movups %xmm0, (%rsp)
movq -0x38(%rbp), %rdi
movl %r13d, %esi
pushq $0x1
popq %rdx
callq 0x2010f
incq %rbx
addq $0x18, %r15
jmp 0x19b55
leaq -0x78(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19f5c
movq 0x10(%r15), %rax
movq %rax, 0x40(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x28(%rsp)
movups (%r12), %xmm0
movups %xmm0, 0x18(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rsp)
movzbl %r13b, %esi
pushq $0x1
popq %rdx
movq -0x38(%rbp), %rdi
callq 0x2010f
movq -0x40(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq