// File: /workspace/github_c_makefile_star2_O1/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), %r15
testb $0x40, 0x9(%rsi)
je 0x3ab8f
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
leaq (%rcx,%rcx,4), %rcx
movl -0x10(%rax,%rcx,8), %eax
leal -0x1(%rax), %ecx
movslq %r15d, %rdi
leaq (%r14,%rdi), %rdx
testq %rdi, %rdi
jle 0x3aa89
movl $0x1, %r8d
movq %r14, %r9
cmpb $0xa, (%r9)
leaq 0x1(%r9), %r9
movl $0x1, %r10d
jne 0x3aa76
cmpq %rdx, %r9
jae 0x3aa5f
xorl %r11d, %r11d
movq %r9, %r12
movb (%r9,%r11), %r13b
cmpb $0xa, %r13b
je 0x3aa54
cmpl %ecx, %r11d
jge 0x3aa54
cmpb $0x20, %r13b
jne 0x3aa59
incq %r12
leaq (%r9,%r11), %r13
incq %r13
incq %r11
cmpq %rdx, %r13
jb 0x3aa28
addq %r11, %r9
jmp 0x3aa5f
movq %r12, %r9
jmp 0x3aa5f
addq %r11, %r9
xorl %r10d, %r10d
leaq 0x1(%r9), %r11
cmpq %rdx, %r11
jae 0x3aa76
cmpb $0xd, (%r9)
jne 0x3aa76
cmpb $0xa, (%r11)
cmovel %r8d, %r10d
testl %r10d, %r10d
je 0x3aa80
cmpq %rdx, %r9
jb 0x3aa0d
testl %r10d, %r10d
je 0x3ab2e
movq %r14, %r15
testq %rdi, %rdi
jle 0x3ab2b
movq %r14, %rdi
movq %r14, %r8
movb (%r8), %r9b
cmpb $0xa, %r9b
jne 0x3ab0d
movb %r9b, (%rdi)
leaq 0x1(%r8), %r9
cmpq %rdx, %r9
jae 0x3aae7
cmpb $0xa, (%r9)
je 0x3aae7
cmpl $0x2, %eax
jl 0x3aae7
addq $0x2, %r8
movl $0x1, %r10d
movq %r8, %r9
cmpq %rdx, %r8
jae 0x3aae3
cmpb $0xa, (%r9)
je 0x3aae3
leal 0x1(%r10), %r11d
leaq 0x1(%r9), %r8
cmpl %ecx, %r10d
movl %r11d, %r10d
jl 0x3aac5
leaq -0x1(%r9), %r8
leaq 0x1(%rdi), %r15
addq $0x2, %r8
cmpq %rdx, %r8
jae 0x3ab1c
movb (%r9), %r10b
cmpb $0xd, %r10b
jne 0x3ab1c
cmpb $0xa, (%r8)
jne 0x3ab1c
movb %r10b, 0x1(%rdi)
addq $0x2, %rdi
jmp 0x3ab16
incq %r8
movb %r9b, (%rdi)
incq %rdi
movq %r8, %r9
movq %rdi, %r15
movq %r15, %rdi
movq %r9, %r8
cmpq %rdx, %r9
jb 0x3aa9b
subl %r14d, %r15d
cmpl $0x2, %r15d
jl 0x3ab4b
cmpb $0xd, (%r14)
jne 0x3ab4b
cmpb $0xa, 0x1(%r14)
jne 0x3ab4b
addl $-0x2, %r15d
addq $0x2, %r14
jmp 0x3ab5c
testl %r15d, %r15d
jle 0x3ab5c
cmpb $0xa, (%r14)
jne 0x3ab5c
decl %r15d
incq %r14
cmpl $0x2, %r15d
jl 0x3ab7d
leal -0x2(%r15), %eax
cmpb $0xd, (%r14,%rax)
jne 0x3ab7d
leal -0x1(%r15), %ecx
cmpb $0xa, (%r14,%rcx)
jne 0x3ab7d
movl %eax, %r15d
jmp 0x3ab8f
testl %r15d, %r15d
jle 0x3ab8f
leal -0x1(%r15), %eax
cmpb $0xa, (%r14,%rax)
cmovel %eax, %r15d
testb $0x2, 0x9(%rsi)
jne 0x3abb4
movq %r14, %rdi
movl %r15d, %esi
callq 0x45094
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
movq %rax, %rdi
callq 0x4f9ad
jmp 0x3abdf
movl %r15d, %edi
callq 0x17757
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x17925
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4f9f2
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 0x3a724