// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/parse.c
// Function: stringend
static int stringend(JanetParser *p, JanetParseState *state) {
    Janet ret;
    uint8_t *bufstart = p->buf;
    int32_t buflen = (int32_t) p->bufcount;
    if (state->flags & PFLAG_LONGSTRING) {
        /* Post process to remove leading whitespace */
        JanetParseState top = p->states[p->statecount - 1];
        int32_t indent_col = (int32_t) top.column - 1;
        uint8_t *r = bufstart, *end = r + buflen;
        /* Unless there are only spaces before EOLs, disable reindenting */
        int reindent = 1;
        while (reindent && (r < end)) {
            if (*r++ == '\n') {
                for (int32_t j = 0; (r < end) && (*r != '\n') && (j < indent_col); j++, r++) {
                    if (*r != ' ') {
                        reindent = 0;
                        break;
                    }
                }
                if ((r + 1) < end && *r == '\r' && *(r + 1) == '\n') reindent = 1;
            }
        }
        /* Now reindent if able */
        if (reindent) {
            uint8_t *w = bufstart;
            r = bufstart;
            while (r < end) {
                if (*r == '\n') {
                    *w++ = *r++;
                    for (int32_t j = 0; (r < end) && (*r != '\n') && (j < indent_col); j++, r++);
                    if ((r + 1) < end && *r == '\r' && *(r + 1) == '\n') *w++ = *r++;
                } else {
                    *w++ = *r++;
                }
            }
            buflen = (int32_t)(w - bufstart);
        }
        /* Check for leading EOL so we can remove it */
        if (buflen > 1 && bufstart[0] == '\r' && bufstart[1] == '\n') { /* Windows EOL */
            buflen = buflen - 2;
            bufstart = bufstart + 2;
        } else if (buflen > 0 && bufstart[0] == '\n') { /* Unix EOL */
            buflen--;
            bufstart++;
        }
        /* Check for trailing EOL so we can remove it */
        if (buflen > 1 && bufstart[buflen - 2] == '\r' && bufstart[buflen - 1] == '\n') { /* Windows EOL */
            buflen = buflen - 2;
        } else if (buflen > 0 && bufstart[buflen - 1] == '\n') { /* Unix EOL */
            buflen--;
        }
    }
    if (state->flags & PFLAG_BUFFER) {
        JanetBuffer *b = janet_buffer(buflen);
        janet_buffer_push_bytes(b, bufstart, buflen);
        ret = janet_wrap_buffer(b);
    } else {
        ret = janet_wrap_string(janet_string(bufstart, buflen));
    }
    p->bufcount = 0;
    popstate(p, ret);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %r14
movq 0x40(%rdi), %rax
testb $0x40, 0x9(%rsi)
je 0x37458
imulq $0x28, 0x30(%rbx), %rcx
movq 0x10(%rbx), %rdx
movl -0x10(%rdx,%rcx), %ecx
decl %ecx
movslq %eax, %rdx
addq %r14, %rdx
pushq $0x1
popq %rdi
movq %r14, %r8
movl %edi, %r9d
testl %r9d, %r9d
je 0x37376
cmpq %rdx, %r8
jae 0x37376
leaq 0x1(%r8), %r10
cmpb $0xa, (%r8)
movq %r10, %r8
movl %edi, %r9d
jne 0x37314
xorl %r9d, %r9d
movq %r10, %r8
cmpq %rdx, %r8
jae 0x37355
movb (%r8), %r10b
cmpb $0xa, %r10b
je 0x37355
cmpl %ecx, %r9d
jge 0x37355
cmpb $0x20, %r10b
jne 0x3735a
incl %r9d
incq %r8
jmp 0x37334
movl %edi, %r9d
jmp 0x3735d
xorl %r9d, %r9d
leaq 0x1(%r8), %r10
cmpq %rdx, %r10
jae 0x37314
cmpb $0xd, (%r8)
jne 0x37314
cmpb $0xa, (%r10)
cmovel %edi, %r9d
jmp 0x37314
testl %r9d, %r9d
je 0x373f7
movq %r14, %rdi
movq %r14, %r8
movq %r8, %rax
cmpq %rdx, %rdi
jae 0x373f4
movb (%rdi), %r8b
cmpb $0xa, %r8b
jne 0x373e6
leaq 0x1(%rax), %r8
movb $0xa, (%rax)
addq $0x2, %rdi
xorl %r10d, %r10d
movq %rdi, %r11
movq %r11, %r9
leaq -0x1(%r11), %rdi
cmpq %rdx, %rdi
jae 0x373c6
cmpb $0xa, -0x1(%r9)
je 0x373c6
leal 0x1(%r10), %r15d
leaq 0x1(%r9), %r11
cmpl %ecx, %r10d
movl %r15d, %r10d
jl 0x373a3
cmpq %rdx, %r9
jae 0x37381
cmpb $0xd, (%rdi)
jne 0x37381
cmpb $0xa, (%r9)
jne 0x37381
movb $0xd, 0x1(%rax)
addq $0x2, %rax
movq %r9, %rdi
movq %rax, %r8
jmp 0x37381
incq %rdi
movb %r8b, (%rax)
incq %rax
movq %rax, %r8
jmp 0x37381
subl %r14d, %eax
cmpl $0x2, %eax
jl 0x37414
movb (%r14), %cl
cmpb $0xd, %cl
jne 0x3741c
cmpb $0xa, 0x1(%r14)
jne 0x3742b
addl $-0x2, %eax
addq $0x2, %r14
jmp 0x37426
cmpl $0x1, %eax
jne 0x37458
movb (%r14), %cl
cmpb $0xa, %cl
jne 0x37426
decl %eax
incq %r14
cmpl $0x2, %eax
jb 0x37442
leal -0x2(%rax), %r15d
cmpb $0xd, (%r14,%r15)
jne 0x3744d
leal -0x1(%rax), %ecx
cmpb $0xa, (%r14,%rcx)
jne 0x3744d
jmp 0x3745b
xorl %r15d, %r15d
cmpl $0x1, %eax
jne 0x3745b
pushq $0x1
popq %rax
leal -0x1(%rax), %ecx
cmpb $0xa, (%r14,%rcx)
cmovel %ecx, %eax
movl %eax, %r15d
testb $0x2, 0x9(%rsi)
jne 0x37480
movq %r14, %rdi
movl %r15d, %esi
callq 0x41116
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
movq %rax, %rdi
callq 0x4b366
jmp 0x374ab
movl %r15d, %edi
callq 0x15f78
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x16172
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4b3ab
andq $0x0, 0x40(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x37070