// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/boundary-stack.c
// Function: BS_boundary_detect
int BS_boundary_detect( char *haystack, char *needle, int needle_length )
{
	int result=1;
	int current_start = glb.detect_limit;
	char *haystack_start;

	if ((glb.have_empty_boundary == 1)&&(needle_length < 1))
	{
		result = strncmp(haystack,"--",2);
		DBS LOGGER_log("%s:%d:BS_boundary_detect:DEBUG: empty-boundary test, result = %d",FL, result);
		return result;

	}

	if ((needle_length < 1)&&(glb.have_empty_boundary == 0)) return 1;


	DBS LOGGER_log("%s:%d:BS_boundary_detect: needle='%s', length=%d, haystack='%s', shift-window=%d"
			,FL
			,needle
			,needle_length
			,haystack
			,current_start
			);

	haystack_start = haystack;
	while ((current_start-- > 0)&&(*haystack_start != '\0'))
	{
		DBS LOGGER_log("%s:%d:BS_boundary_detect:DEBUG: CMP '%s' to '%s'",FL, needle, haystack_start);
		if (strncmp( needle, haystack_start, needle_length )==0)
		{
			DBS LOGGER_log("%s:%d:BS_boundary_detect:DEBUG: Hit on compare",FL);
			result = 0;  
			break; 
		}
		haystack_start++;
	}

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movl 0x22d44(%rip), %eax     # 0x35954
movl %eax, -0x24(%rbp)
cmpl $0x1, 0x22d46(%rip)     # 0x35960
jne 0x12c6b
cmpl $0x1, -0x1c(%rbp)
jge 0x12c6b
movq -0x10(%rbp), %rdi
leaq 0x98f7(%rip), %rsi      # 0x1c524
movl $0x2, %edx
callq 0x2090
movl %eax, -0x20(%rbp)
cmpl $0x0, 0x22cff(%rip)     # 0x35940
je 0x12c60
movl -0x20(%rbp), %ecx
leaq 0xc497(%rip), %rdi      # 0x1f0e4
leaq 0xc37e(%rip), %rsi      # 0x1efd2
movl $0x19e, %edx            # imm = 0x19E
movb $0x0, %al
callq 0x117c0
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x12d75
cmpl $0x1, -0x1c(%rbp)
jge 0x12c86
cmpl $0x0, 0x22ce8(%rip)     # 0x35960
jne 0x12c86
movl $0x1, -0x4(%rbp)
jmp 0x12d75
cmpl $0x0, 0x22cb3(%rip)     # 0x35940
je 0x12cbb
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movq -0x10(%rbp), %r9
movl -0x24(%rbp), %eax
leaq 0xc480(%rip), %rdi      # 0x1f125
leaq 0xc326(%rip), %rsi      # 0x1efd2
movl $0x1a7, %edx            # imm = 0x1A7
movl %eax, (%rsp)
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
jle 0x12ce8
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x12cf1
jmp 0x12d6f
cmpl $0x0, 0x22c48(%rip)     # 0x35940
je 0x12d1c
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %r8
leaq 0xc46d(%rip), %rdi      # 0x1f176
leaq 0xc2c2(%rip), %rsi      # 0x1efd2
movl $0x1b1, %edx            # imm = 0x1B1
movb $0x0, %al
callq 0x117c0
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x2090
cmpl $0x0, %eax
jne 0x12d5e
cmpl $0x0, 0x22c07(%rip)     # 0x35940
je 0x12d55
leaq 0xc465(%rip), %rdi      # 0x1f1a7
leaq 0xc289(%rip), %rsi      # 0x1efd2
movl $0x1b4, %edx            # imm = 0x1B4
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x20(%rbp)
jmp 0x12d6f
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x12cc3
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop