// File: /workspace/github_c_makefile_star2_O0/blakemcbride[P]LISP9/ls9.c
// Function: substr
cell substr(cell s, cell n0, cell n1) {
	int	k, k0, k1, i, j;
	cell	n;
	byte	*s0, *s1;

	if (!stringp(s)) expect("substr", "string", s);
	if (!fixp(n0)) expect("substr", "fixnum", n0);
	if (!fixp(n1)) expect("substr", "fixnum", n1);
	k0 = fixval(n0);
	k1 = fixval(n1);
	if (k0 < 0 || k1 < 0 || k0 > k1 || k1 >= stringlen(s))
		error("substr: invalid range", cons(n0, cons(n1, NIL)));
	k = k1-k0;
	n = mkstr(NULL, k);
	j = 0;
	s0 = string(s);
	s1 = string(n);
	for (i=k0; i<k1; i++) {
		s1[j] = s0[i];
		j++;
	}
	s1[j] = 0;
	return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
cmpl $0x0, -0x4(%rbp)
jl 0xfbf3
movq 0x10782(%rip), %rax     # 0x20350
movslq -0x4(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xfbf3
movq 0x1075b(%rip), %rcx     # 0x20340
movslq -0x4(%rbp), %rdx
movl $0xffffffef, %eax       # imm = 0xFFFFFFEF
cmpl (%rcx,%rdx,4), %eax
je 0xfc09
movl -0x4(%rbp), %edx
leaq 0xbe07(%rip), %rdi      # 0x1ba04
leaq 0xb9d9(%rip), %rsi      # 0x1b5dd
callq 0x2950
cmpl $0x0, -0x8(%rbp)
jl 0xfc3b
movq 0x1073a(%rip), %rax     # 0x20350
movslq -0x8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xfc3b
movq 0x10713(%rip), %rcx     # 0x20340
movslq -0x8(%rbp), %rdx
movl $0xfffffff2, %eax       # imm = 0xFFFFFFF2
cmpl (%rcx,%rdx,4), %eax
je 0xfc51
movl -0x8(%rbp), %edx
leaq 0xbdbf(%rip), %rdi      # 0x1ba04
leaq 0xbcd3(%rip), %rsi      # 0x1b91f
callq 0x2950
cmpl $0x0, -0xc(%rbp)
jl 0xfc83
movq 0x106f2(%rip), %rax     # 0x20350
movslq -0xc(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xfc83
movq 0x106cb(%rip), %rcx     # 0x20340
movslq -0xc(%rbp), %rdx
movl $0xfffffff2, %eax       # imm = 0xFFFFFFF2
cmpl (%rcx,%rdx,4), %eax
je 0xfc99
movl -0xc(%rbp), %edx
leaq 0xbd77(%rip), %rdi      # 0x1ba04
leaq 0xbc8b(%rip), %rsi      # 0x1b91f
callq 0x2950
movq 0x106a0(%rip), %rax     # 0x20340
movq 0x106a1(%rip), %rcx     # 0x20348
movslq -0x8(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movq 0x10684(%rip), %rax     # 0x20340
movq 0x10685(%rip), %rcx     # 0x20348
movslq -0xc(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xfd08
cmpl $0x0, -0x18(%rbp)
jl 0xfd08
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0xfd08
movl -0x18(%rbp), %eax
movq 0x10669(%rip), %rcx     # 0x20358
movq 0x10652(%rip), %rdx     # 0x20348
movslq -0x4(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
subl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jl 0xfd37
movl -0x8(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0xc(%rbp), %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x3990
movl -0x3c(%rbp), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x3990
movl %eax, %esi
leaq 0xbcd9(%rip), %rdi      # 0x1ba0b
callq 0x26c0
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x2880
movl %eax, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movq 0x105fb(%rip), %rax     # 0x20358
movq 0x105e4(%rip), %rcx     # 0x20348
movslq -0x4(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq 0x105da(%rip), %rax     # 0x20358
movq 0x105c3(%rip), %rcx     # 0x20348
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xfdd0
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xfd9e
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x24(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)