// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]zepl/lisp.c
// Function: newStringWithLength
Object *newStringWithLength(char *string, size_t length, GC_PARAM)
{
	int nEscapes = 0;

	for (int i = 1; i < length; ++i)
		if (string[i - 1] == '\\' && strchr("\\\"trn", string[i]))
			++i, ++nEscapes;

	Object *object = newObjectWithString(TYPE_STRING,
					     length - nEscapes + 1, GC_ROOTS);

	for (int r = 1, w = 0; r <= length; ++r) {
		if (string[r - 1] == '\\' && r < length) {
			switch (string[r]) {
			case '\\':
				object->string[w++] = '\\';
				r++;
				break;
			case '"':
				object->string[w++] = '"';
				r++;
				break;
			case 't':
				object->string[w++] = '\t';
				r++;
				break;
			case 'r':
				object->string[w++] = '\r';
				r++;
				break;
			case 'n':
				object->string[w++] = '\n';
				r++;
				break;
			default:
				object->string[w++] = '\\';
				break;
			}
		} else
			object->string[w++] = string[r - 1];
	}

	object->string[length - nEscapes] = '\0';
	return object;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movslq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x5b3f
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
jne 0x5b32
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x59e6(%rip), %rdi      # 0xb4fb
callq 0x2120
cmpq $0x0, %rax
je 0x5b32
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5b34
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5ae2
movq -0x10(%rbp), %rsi
movslq -0x1c(%rbp), %rax
subq %rax, %rsi
addq $0x1, %rsi
movq -0x18(%rbp), %rdx
movl $0x1, %edi
callq 0x5a60
movq %rax, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movslq -0x2c(%rbp), %rax
cmpq -0x10(%rbp), %rax
ja 0x5ce5
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
jne 0x5caf
movslq -0x2c(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x5caf
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
subl $0x22, %eax
je 0x5c0e
jmp 0x5bba
movl -0x34(%rbp), %eax
subl $0x5c, %eax
je 0x5be9
jmp 0x5bc4
movl -0x34(%rbp), %eax
subl $0x6e, %eax
je 0x5c74
jmp 0x5bd2
movl -0x34(%rbp), %eax
subl $0x72, %eax
je 0x5c52
jmp 0x5bdc
movl -0x34(%rbp), %eax
subl $0x74, %eax
je 0x5c30
jmp 0x5c96
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0x5c, 0x10(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5cad
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0x22, 0x10(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5cad
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0x9, 0x10(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5cad
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0xd, 0x10(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5cad
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0xa, 0x10(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5cad
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb $0x5c, 0x10(%rax,%rcx)
jmp 0x5cd5
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rbp)
movslq %ecx, %rcx
movb %dl, 0x10(%rax,%rcx)
jmp 0x5cd7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5b6e
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
subq %rdx, %rcx
movb $0x0, 0x10(%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)