// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/fmtutil.c
// Function: do_box_sequence
static void do_box_sequence(deark *c, struct de_boxesctx *bctx,
	i64 pos1, i64 len, i64 max_nboxes, int level)
{
	i64 pos;
	i64 box_len;
	i64 endpos;
	int ret;
	i64 box_count = 0;

	if(level >= 32) { // An arbitrary recursion limit.
		return;
	}

	pos = pos1;
	endpos = pos1 + len;

	while(pos < endpos) {
		if(max_nboxes>=0 && box_count>=max_nboxes) break;
		ret = do_box(c, bctx, pos, endpos-pos, level, &box_len);
		if(!ret) break;
		box_count++;
		pos += box_len;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, 0x68(%rsp)
movq %rcx, 0x38(%rsp)
movq %r9, 0x48(%rsp)
cmpl $0x1f, %r9d
jle 0xecad8
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
addq %rdx, 0x38(%rsp)
movq 0x48(%rsp), %rax
incl %eax
movl %eax, 0x44(%rsp)
xorl %edx, %edx
movq %rsi, 0x60(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x68(%rsp), %rcx
testq %rcx, %rcx
sets %al
cmpq %rcx, %rdx
setl %cl
movq 0x38(%rsp), %r14
subq %r12, %r14
jle 0xecac6
orb %cl, %al
je 0xecac6
movq %rdx, 0x70(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x50(%rsp)
movq 0x28(%r13), %rbp
movq %rbx, %rdi
pushq $0x78
popq %rsi
callq 0xdecaf
movq %rax, 0x28(%r13)
movq %rbp, 0x20(%rsp)
movq %rbp, (%rax)
cmpq $0x7, %r14
movq %r12, 0x30(%rsp)
jg 0xecb6c
movq %rbx, %rdi
leaq 0x5098d(%rip), %rsi     # 0x13d4e7
movl %r14d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
jmp 0xecd5c
movq %rax, %r15
movq 0x10(%r13), %rdi
movq %r12, %rsi
callq 0xe404f
movq %rax, %rbp
movq 0x10(%r13), %rdi
leaq 0x4(%r12), %rsi
leaq 0x78(%rsp), %rdx
pushq $0x4
popq %rcx
xorl %r8d, %r8d
callq 0xe657c
movl 0x7c(%rsp), %eax
movl %eax, 0xc(%r15)
cmpq $0x8, %rbp
jl 0xecbab
addq $-0x8, %rbp
jmp 0xecbc2
cmpq $0x1, %rbp
je 0xecc86
testq %rbp, %rbp
jne 0xecc9a
leaq -0x8(%r14), %rbp
pushq $0x8
popq %rcx
cmpl $0x75756964, %eax       # imm = 0x75756964
jne 0xecbf8
cmpq $0xf, %rbp
jbe 0xecbf8
movl $0x1, 0x10(%r15)
movq 0x10(%r13), %rdi
leaq 0x14(%r15), %rsi
movq %r12, %r13
movq %rcx, %rbx
addq %rcx, %r12
movq %r12, %rdx
pushq $0x10
popq %rcx
callq 0xe3cb7
jmp 0xecc01
movq %r12, %r13
movq %rcx, %rbx
addq %rcx, %r12
addq %rbp, %rbx
movq 0x48(%rsp), %rax
movl %eax, 0x8(%r15)
movq %r13, 0x28(%r15)
movq %rbx, 0x28(%rsp)
movq %rbx, 0x30(%r15)
movq %r12, 0x38(%r15)
movq %rbp, 0x40(%r15)
cmpl $0x0, 0x10(%r15)
je 0xecc39
addq $0x10, %r12
movq %r12, 0x38(%r15)
leaq -0x10(%rbp), %rax
movq %rax, 0x40(%r15)
movq 0x60(%rsp), %r13
movq 0x18(%r13), %rax
testq %rax, %rax
movq 0x10(%rsp), %rbx
je 0xecc54
movq %rbx, %rdi
movq %r13, %rsi
callq *%rax
cmpl $0x0, (%rbx)
movq 0x30(%rsp), %r12
jle 0xecd31
movq 0x50(%r15), %rcx
testq %rcx, %rcx
je 0xeccb5
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
pushq $0x50
popq %rsi
leaq 0x31f21(%rip), %rdx     # 0x11eb9e
xorl %eax, %eax
callq 0xde40c
jmp 0xeccbd
cmpq $0xf, %r14
ja 0xece44
movq 0x10(%rsp), %rbx
jmp 0xecb50
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5085f(%rip), %rsi     # 0x13d508
xorl %eax, %eax
callq 0xdf2a5
jmp 0xecd5c
movq 0x50(%rsp), %rbx
movb $0x0, (%rbx)
cmpl $0x0, 0x10(%r15)
je 0xecd07
movq %r15, %rsi
addq $0x14, %rsi
leaq 0x50(%rbx), %r12
movq %r12, %rdx
pushq $0x32
popq %rcx
callq 0xec7c5
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x5083b(%rip), %rsi     # 0x13d52a
leaq 0x88(%rsp), %rdx
movq %r12, %rcx
movq 0x30(%rsp), %r12
movq %rbx, %r8
movq %r12, %r9
jmp 0xecd2a
movq %rbp, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x50832(%rip), %rsi     # 0x13d549
leaq 0x88(%rsp), %rdx
movq %rbx, %rcx
movq %r12, %r8
movq 0x28(%rsp), %r9
xorl %eax, %eax
callq 0xde896
movq 0x28(%rsp), %rcx
cmpq %r14, %rcx
jbe 0xecd9c
addq %r12, %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x50821(%rip), %rsi     # 0x13d56e
movq %r12, %rdx
movq 0x38(%rsp), %r8
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, %r12b
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %r14
movq 0x28(%r13), %rsi
movq %rbx, %rdi
callq 0xded32
movq %r14, 0x28(%r13)
testb %r12b, %r12b
movq 0x30(%rsp), %r12
movq 0x70(%rsp), %rdx
jne 0xecac6
incq %rdx
addq %rbp, %r12
movq %rbp, 0x18(%rsp)
jmp 0xecafd
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
movq %r13, %rsi
callq *0x20(%r13)
movl %eax, %ebp
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
testl %ebp, %ebp
movq 0x20(%rsp), %r14
je 0xece32
cmpl $0x0, 0x5c(%r15)
je 0xece7e
movq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
cmpl $0x0, 0x60(%r15)
pushq $-0x1
popq %r8
movq 0x28(%rsp), %rbp
je 0xecdf8
movq 0x68(%r15), %r8
movq 0x40(%r15), %rcx
movq 0x70(%r15), %rax
movq 0x38(%r15), %rdx
addq %rax, %rdx
subq %rax, %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movl 0x44(%rsp), %r9d
callq 0xecaa0
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
xorl %r12d, %r12d
jmp 0xecd69
movb $0x1, %r12b
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rbx
jmp 0xecd69
movq 0x10(%r13), %rdi
leaq 0x8(%r12), %rsi
callq 0xe4143
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xe10b1
movq 0x58(%rsp), %rbp
movb $0x1, %r12b
cmpq $0x10, %rbp
jge 0xece90
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rbx
jmp 0xecd64
xorl %r12d, %r12d
movq 0x10(%rsp), %rbx
movq 0x28(%rsp), %rbp
jmp 0xecd69
addq $-0x10, %rbp
movl 0xc(%r15), %eax
pushq $0x10
popq %rcx
movq 0x30(%rsp), %r12
jmp 0xecbc5