// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %r14
movq 0x40(%rdi), %rdi
testb $0x40, 0x9(%rsi)
je 0x3a6af
movslq %edi, %r8
movq %r14, %r10
testq %r8, %r8
jle 0x3a648
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
leaq (%rcx,%rcx,4), %rcx
movl -0x10(%rax,%rcx,8), %eax
leal -0x1(%rax), %ecx
leaq (%r14,%r8), %rdx
movl $0x1, %r9d
movq %r14, %r11
leaq 0x1(%r11), %r15
cmpb $0xa, (%r11)
jne 0x3a586
movl $0x1, %r10d
cmpq %rdx, %r15
jae 0x3a56a
xorl %r12d, %r12d
movq %r15, %r11
movb (%r15,%r12), %r13b
cmpb $0xa, %r13b
je 0x3a567
cmpl %ecx, %r12d
jge 0x3a567
cmpb $0x20, %r13b
jne 0x3a59b
incq %r11
leaq (%r15,%r12), %r13
incq %r13
incq %r12
cmpq %rdx, %r13
jb 0x3a540
addq %r12, %r15
movq %r15, %r11
leaq 0x1(%r11), %r15
cmpq %rdx, %r15
jae 0x3a58f
cmpb $0xd, (%r11)
jne 0x3a58f
cmpb $0xa, (%r15)
cmovel %r9d, %r10d
jmp 0x3a58f
movq %r15, %r11
movl $0x1, %r10d
testl %r10d, %r10d
je 0x3a5a0
cmpq %rdx, %r11
jb 0x3a525
jmp 0x3a5a0
xorl %r10d, %r10d
jmp 0x3a56d
testl %r10d, %r10d
je 0x3a64e
movq %r14, %r10
testq %r8, %r8
jle 0x3a648
movq %r14, %rdi
movq %r14, %r8
movb (%r8), %r9b
cmpb $0xa, %r9b
jne 0x3a62a
movb $0xa, (%rdi)
leaq 0x1(%r8), %r9
cmpq %rdx, %r9
jae 0x3a607
cmpb $0xa, (%r9)
je 0x3a607
cmpl $0x2, %eax
jl 0x3a607
addq $0x2, %r8
movl $0x1, %r10d
movq %r8, %r9
cmpq %rdx, %r8
jae 0x3a603
cmpb $0xa, (%r9)
je 0x3a603
leal 0x1(%r10), %r11d
leaq 0x1(%r9), %r8
cmpl %ecx, %r10d
movl %r11d, %r10d
jl 0x3a5e5
leaq -0x1(%r9), %r8
leaq 0x1(%rdi), %r10
addq $0x2, %r8
cmpq %rdx, %r8
jae 0x3a639
cmpb $0xd, (%r9)
jne 0x3a639
cmpb $0xa, (%r8)
jne 0x3a639
movb $0xd, 0x1(%rdi)
addq $0x2, %rdi
jmp 0x3a633
incq %r8
movb %r9b, (%rdi)
incq %rdi
movq %r8, %r9
movq %rdi, %r10
movq %r10, %rdi
movq %r9, %r8
cmpq %rdx, %r9
jb 0x3a5bb
subl %r14d, %r10d
movl %r10d, %edi
cmpl $0x2, %edi
jl 0x3a66a
movb (%r14), %al
cmpb $0xd, %al
jne 0x3a672
cmpb $0xa, 0x1(%r14)
jne 0x3a680
addl $-0x2, %edi
addq $0x2, %r14
jmp 0x3a67b
cmpl $0x1, %edi
jne 0x3a6af
movb (%r14), %al
cmpb $0xa, %al
jne 0x3a67b
decl %edi
incq %r14
cmpl $0x2, %edi
jb 0x3a697
leal -0x2(%rdi), %r15d
cmpb $0xd, (%r14,%r15)
jne 0x3a6a4
leal -0x1(%rdi), %eax
cmpb $0xa, (%r14,%rax)
jne 0x3a6a4
jmp 0x3a6b2
xorl %r15d, %r15d
cmpl $0x1, %edi
movl $0x1, %edi
jne 0x3a6b2
leal -0x1(%rdi), %eax
cmpb $0xa, (%r14,%rax)
cmovel %eax, %edi
movl %edi, %r15d
testb $0x2, 0x9(%rsi)
jne 0x3a6d7
movq %r14, %rdi
movl %r15d, %esi
callq 0x44754
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
movq %rax, %rdi
callq 0x4ed39
jmp 0x3a702
movl %r15d, %edi
callq 0x176f7
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x178c5
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4ed7e
movq $0x0, 0x40(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a244