// File: /workspace/github_c_makefile_star2_O2/anuwu[P]ERPLAG-Compiler/lexer.c
// Function: extract_lexeme
char* extract_lexeme (twinBuffer *twinBuf)
/*
Given the location of forward and begin pointer, it extracts the characters
into a lexeme 
*/
{
	char *word , *ptr ;
	int i , len ;
 
	if (*twinBuf->forward == EOF)
	{
		if (twinBuf->where_begin == twinBuf->where_forward)
		{
 
			ptr = twinBuf->begin ;
			if (*ptr == EOF)
				return NULL ;
 
			while (*ptr != EOF)
				ptr++ ;
			word = (char *) malloc (sizeof(char) * (ptr - twinBuf->begin + 1)) ;
			ptr = twinBuf->begin ;
			for (i = 0 ; *ptr != EOF ; i++)
			{
				word[i] = *ptr ;
				ptr++ ;
			}
 
			word[i] = '\0' ;
			return word ;
		}
		else
		{
			int j ;
 
			len = (twinBuf->forward - twinBuf->buf2 + 1) + (twinBuf->buf1 + bufSize - twinBuf->begin) ;
			word = (char *) malloc (sizeof(char) * (len + 1)) ;
 
			ptr = twinBuf->begin ;
			if (*ptr == EOF)
				return NULL ;
			for (i = 0 ; *ptr != EOF ; i++)
			{
				word[i] = *ptr ;
				ptr++ ;
			}
 
			ptr = twinBuf->buf2 ;
			for ( ; i < len ; i++)
			{
				word[i] = *ptr ;
				ptr++ ;
			}
 
			word[len] = '\0' ;
		}
	}
	else if ((twinBuf->where_begin == TWIN_ONE && twinBuf->where_forward == TWIN_ONE) || (twinBuf->where_begin == TWIN_TWO && twinBuf->where_forward == TWIN_TWO))
	{
		len = twinBuf->forward - twinBuf->begin + 1 ;
		word = (char *) malloc (sizeof(char) * (len + 1)) ;
 
		ptr = twinBuf->begin ;
		for (i = 0 ; i < len ; i++)
		{
			word[i] = *ptr ;
			ptr++ ;
		}
 
		word[len] = '\0' ;
	}
	else if (twinBuf->where_begin == TWIN_ONE && twinBuf->where_forward == TWIN_TWO)
	{
		int j ;
 
		len = (twinBuf->forward - twinBuf->buf2 + 1) + (twinBuf->buf1 + bufSize - twinBuf->begin) ;
		word = (char *) malloc (sizeof(char) * (len + 1)) ;
 
		ptr = twinBuf->begin ;
		for (i = 0 ; *ptr != EOF ; i++)
		{
			word[i] = *ptr ;
			ptr++ ;
		}
 
		ptr = twinBuf->buf2 ;
		for ( ; i < len ; i++)
		{
			word[i] = *ptr ;
			ptr++ ;
		}
 
		word[len] = '\0' ;
	}
 
	return word ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x20(%rdi), %rcx
cmpb $-0x1, (%rcx)
movl 0x28(%rdi), %edx
je 0x806d
cmpl $0x1, %edx
je 0x8099
testl %edx, %edx
jne 0x81b5
movl 0x2c(%rdi), %edx
testl %edx, %edx
je 0x80a3
cmpl $0x1, %edx
jne 0x81b5
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rbx
movq 0x18(%rdi), %r12
subq %r12, %rax
subq %rbx, %rcx
leaq (%rax,%rcx), %r15
addq $0x81, %r15
movq %r15, %r14
shlq $0x20, %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %r14, %rdi
sarq $0x20, %rdi
callq 0x1110
xorl %ecx, %ecx
movb (%r12,%rcx), %dl
cmpb $-0x1, %dl
je 0x8186
movb %dl, (%rax,%rcx)
incq %rcx
jmp 0x8058
cmpl 0x2c(%rdi), %edx
jne 0x80d8
movq 0x18(%rdi), %rbx
movb (%rbx), %r14b
cmpb $-0x1, %r14b
je 0x813b
pushq $0x1
popq %rdi
movl %r14d, %eax
cmpb $-0x1, %al
je 0x813f
movb (%rbx,%rdi), %al
incq %rdi
jmp 0x8089
cmpl $0x1, 0x2c(%rdi)
jne 0x81b5
movq 0x18(%rdi), %rbx
subl %ebx, %ecx
leal 0x1(%rcx), %r14d
addl $0x2, %ecx
movslq %ecx, %rdi
callq 0x1110
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
cmpq %rcx, %rdx
je 0x8136
movb (%rbx,%rcx), %sil
movb %sil, (%rax,%rcx)
incq %rcx
jmp 0x80c6
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rbx
movq 0x18(%rdi), %r12
subq %r12, %rax
subq %rbx, %rcx
leaq (%rax,%rcx), %r15
addq $0x81, %r15
movq %r15, %r14
shlq $0x20, %r14
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %r14, %rdi
sarq $0x20, %rdi
callq 0x1110
movb (%r12), %sil
xorl %edx, %edx
cmpb $-0x1, %sil
je 0x813b
xorl %ecx, %ecx
cmpb $-0x1, %sil
je 0x815a
movb %sil, (%rax,%rcx)
movb 0x1(%r12,%rcx), %sil
incq %rcx
incl %edx
jmp 0x8120
movslq %r14d, %rdx
jmp 0x817e
xorl %eax, %eax
jmp 0x81b5
callq 0x1110
xorl %ecx, %ecx
cmpb $-0x1, %r14b
je 0x817c
movb %r14b, (%rax,%rcx)
movb 0x1(%rbx,%rcx), %r14b
incq %rcx
jmp 0x8146
cmpl %r15d, %edx
cmovgl %edx, %r15d
subq %rcx, %r15
xorl %edx, %edx
cmpq %rdx, %r15
je 0x81a8
movb (%rbx,%rdx), %sil
leaq (%rax,%rdx), %rdi
movb %sil, (%rcx,%rdi)
incq %rdx
jmp 0x8166
movl %ecx, %edx
movq %rax, %rcx
addq %rdx, %rcx
jmp 0x81b2
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
subq %rcx, %r15
xorl %edx, %edx
cmpq %rdx, %r15
je 0x81a8
movb (%rbx,%rdx), %sil
leaq (%rax,%rdx), %rdi
movb %sil, (%rcx,%rdi)
incq %rdx
jmp 0x8192
sarq $0x20, %r14
movq %rax, %rcx
addq %r14, %rcx
movb $0x0, (%rcx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop