// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x20(%rdi), %r15
cmpb $-0x1, (%r15)
movl 0x28(%rdi), %eax
je 0x9135
testl %eax, %eax
jne 0x907d
cmpl $0x0, 0x2c(%rdi)
je 0x9088
cmpl $0x1, %eax
jne 0x90cb
cmpl $0x1, 0x2c(%rdi)
jne 0x90cb
movq 0x18(%rdi), %r14
subl %r14d, %r15d
leal 0x1(%r15), %r12d
leal 0x2(%r15), %eax
movslq %eax, %rdi
callq 0x1120
movq %rax, %rbx
cmpl $0x7ffffffe, %r15d      # imm = 0x7FFFFFFE
ja 0x90c3
cmpl $0x2, %r12d
movl $0x1, %edx
cmovgel %r12d, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1110
movslq %r12d, %rax
jmp 0x9242
testl %eax, %eax
jne 0x9246
cmpl $0x1, 0x2c(%rdi)
jne 0x9246
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %r14
movq 0x18(%rdi), %r13
subq %r13, %rax
subq %r14, %r15
leaq (%rax,%r15), %r12
addq $0x81, %r12
movq %r12, %r15
shlq $0x20, %r15
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %r15, %rdi
sarq $0x20, %rdi
callq 0x1120
movq %rax, %rbx
movb (%r13), %al
xorl %edx, %edx
cmpb $-0x1, %al
je 0x9218
movb %al, (%rbx,%rdx)
movb 0x1(%r13,%rdx), %al
incq %rdx
jmp 0x9120
cmpl 0x2c(%rdi), %eax
jne 0x9180
movq 0x18(%rdi), %r14
cmpb $-0x1, (%r14)
je 0x9214
xorl %edi, %edi
cmpb $-0x1, (%r14,%rdi)
leaq 0x1(%rdi), %rdi
jne 0x914a
callq 0x1120
movq %rax, %rbx
movb (%r14), %al
cmpb $-0x1, %al
je 0x9240
xorl %ecx, %ecx
movb %al, (%rbx,%rcx)
movb 0x1(%r14,%rcx), %al
incq %rcx
cmpb $-0x1, %al
jne 0x916a
movl %ecx, %eax
jmp 0x9242
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %r14
subq %r14, %rax
movq %rcx, -0x30(%rbp)
subq %rcx, %r15
leaq (%rax,%r15), %r13
addq $0x81, %r13
movq %r13, %r15
shlq $0x20, %r15
movabsq $0x100000000, %rdi      # imm = 0x100000000
addq %r15, %rdi
sarq $0x20, %rdi
callq 0x1120
movb (%r14), %r12b
xorl %edx, %edx
cmpb $-0x1, %r12b
je 0x9214
movq %rax, %rbx
movb (%r14), %al
cmpb $-0x1, %al
je 0x91e4
xorl %edx, %edx
movb %al, (%rbx,%rdx)
movb 0x1(%r14,%rdx), %al
incq %rdx
cmpb $-0x1, %al
jne 0x91d5
cmpl %r13d, %edx
jge 0x91ff
movl %edx, %edi
addq %rbx, %rdi
notl %edx
addl %r13d, %edx
incq %rdx
movq -0x30(%rbp), %rsi
callq 0x1110
sarq $0x20, %r15
xorl %eax, %eax
cmpb $-0x1, %r12b
movb $0x0, (%rbx,%r15)
cmoveq %rax, %rbx
jmp 0x9246
xorl %ebx, %ebx
jmp 0x9246
cmpl %r12d, %edx
jge 0x9235
movl %edx, %eax
movq %rbx, %rdi
addq %rax, %rdi
notl %edx
addl %r12d, %edx
incq %rdx
movq %r14, %rsi
callq 0x1110
sarq $0x20, %r15
movb $0x0, (%rbx,%r15)
jmp 0x9246
xorl %eax, %eax
movb $0x0, (%rbx,%rax)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq