// File: /workspace/github_c_makefile_star2_O3/open-mesh-mirror[P]batmand/allocate.c
// Function: debugMalloc
void *debugMalloc(uint32_t length, int32_t tag)
{
	unsigned char *memory;
	struct chunkHeader *chunkHeader;
	struct chunkTrailer *chunkTrailer;
	unsigned char *chunk;

/* 	printf("sizeof(struct chunkHeader) = %u, sizeof (struct chunkTrailer) = %u\n", sizeof (struct chunkHeader), sizeof (struct chunkTrailer)); */

	memory = malloc(length + sizeof(struct chunkHeader) + sizeof(struct chunkTrailer) + getHeaderPad() + getTrailerPad(length));

	if (memory == NULL)
	{
		debug_output( 0, "Cannot allocate %u bytes, malloc tag = %d\n", (unsigned int)(length + sizeof(struct chunkHeader) + sizeof(struct chunkTrailer)), tag );
		restore_and_exit(0);
	}

	chunkHeader = (struct chunkHeader *)memory;
	chunk = memory + sizeof(struct chunkHeader) + getHeaderPad();
	chunkTrailer = (struct chunkTrailer *)(memory + sizeof(struct chunkHeader) + length + getHeaderPad() + getTrailerPad(length));

	fillPadding((unsigned char*)chunkHeader + sizeof(struct chunkHeader), getHeaderPad());
	fillPadding(chunk + length, getTrailerPad(length));

	chunkHeader->length = length;
	chunkHeader->tag = tag;
	chunkHeader->magicNumber = MAGIC_NUMBER;

	chunkTrailer->magicNumber = MAGIC_NUMBER;

	pthread_mutex_lock(&chunk_mutex);
	chunkHeader->next = chunkList;
	chunkList = chunkHeader;
	pthread_mutex_unlock(&chunk_mutex);

#if defined MEMORY_USAGE

	addMemory( length, tag );

#endif

	return chunk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r13d
movl %edi, %ebp
movl %ebp, %r15d
andl $0x7, %r15d
movl $0x8, %r12d
subq %r15, %r12
testq %r15, %r15
cmoveq %r15, %r12
leaq (%r12,%rbp), %rdi
addq $0x1c, %rdi
callq 0x22e0
testq %rax, %rax
je 0x6181
movq %rax, %r14
movq %rax, %rdx
addq %rbp, %rax
addq $0x18, %rax
testq %r15, %r15
je 0x60d2
leaq -0x1(%r12), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm1     # xmm1 = xmm0[0,1,0,1]
movdqa 0xa8b2(%rip), %xmm2     # 0x10670
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pxor 0xa8b5(%rip), %xmm1     # 0x10680
pshufd $0xa0, %xmm1, %xmm0     # xmm0 = xmm1[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
pshuflw $0xe8, %xmm2, %xmm4     # xmm4 = xmm2[0,2,2,3,4,5,6,7]
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
movd %xmm4, %ecx
testb $0x1, %cl
je 0x5e03
movb $-0x59, (%rax)
packssdw %xmm2, %xmm2
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
movd %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x5e23
movb $0x4e, 0x1(%rax)
movdqa 0xa865(%rip), %xmm2     # 0x10690
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
packssdw %xmm2, %xmm4
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
movd %xmm4, %ecx
shrl $0x10, %ecx
testb $0x1, %cl
je 0x5e65
movb $-0xb, 0x2(%rax)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
movd %xmm2, %ecx
shrl $0x18, %ecx
testb $0x1, %cl
je 0x5e86
movb $-0x64, 0x3(%rax)
movdqa 0xa812(%rip), %xmm2     # 0x106a0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
pshuflw $0xe8, %xmm2, %xmm4     # xmm4 = xmm2[0,2,2,3,4,5,6,7]
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
pextrw $0x2, %xmm4, %ecx
testb $0x1, %cl
je 0x5ec7
movb $0x43, 0x4(%rax)
packssdw %xmm2, %xmm2
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x2, %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x5ee8
movb $-0x16, 0x5(%rax)
movdqa 0xa7c0(%rip), %xmm2     # 0x106b0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
packssdw %xmm2, %xmm4
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
pextrw $0x3, %xmm4, %ecx
testb $0x1, %cl
je 0x5f28
movb $-0x6f, 0x6(%rax)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x3, %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x5f4a
movb $0x38, 0x7(%rax)
movdqa 0xa76e(%rip), %xmm2     # 0x106c0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
pshuflw $0xe8, %xmm2, %xmm4     # xmm4 = xmm2[0,2,2,3,4,5,6,7]
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
pextrw $0x4, %xmm4, %ecx
testb $0x1, %cl
je 0x5f8b
movb $-0x21, 0x8(%rax)
packssdw %xmm2, %xmm2
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x4, %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x5fac
movb $-0x7a, 0x9(%rax)
movdqa 0xa71c(%rip), %xmm2     # 0x106d0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
packssdw %xmm2, %xmm4
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
pextrw $0x5, %xmm4, %ecx
testb $0x1, %cl
je 0x5fec
movb $0x2d, 0xa(%rax)
pshufhw $0x84, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,5,4,6]
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x5, %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x600e
movb $-0x2c, 0xb(%rax)
movdqa 0xa6ca(%rip), %xmm2     # 0x106e0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm2
pand %xmm3, %xmm2
pshuflw $0xe8, %xmm2, %xmm4     # xmm4 = xmm2[0,2,2,3,4,5,6,7]
pcmpeqd %xmm3, %xmm3
pxor %xmm3, %xmm4
packssdw %xmm4, %xmm4
packsswb %xmm4, %xmm4
pextrw $0x6, %xmm4, %ecx
testb $0x1, %cl
je 0x604f
movb $0x7b, 0xc(%rax)
packssdw %xmm2, %xmm2
pxor %xmm3, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x6, %xmm2, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x6070
movb $0x22, 0xd(%rax)
movdqa 0xa678(%rip), %xmm2     # 0x106f0
pshufd $0xa0, %xmm2, %xmm3     # xmm3 = xmm2[0,0,2,2]
pcmpgtd %xmm0, %xmm3
pshufd $0xf5, %xmm2, %xmm0     # xmm0 = xmm2[1,1,3,3]
pcmpeqd %xmm1, %xmm0
pand %xmm3, %xmm0
packssdw %xmm0, %xmm2
pcmpeqd %xmm1, %xmm1
pxor %xmm1, %xmm2
packssdw %xmm2, %xmm2
packsswb %xmm2, %xmm2
pextrw $0x7, %xmm2, %ecx
testb $0x1, %cl
je 0x60b0
movb $-0x37, 0xe(%rax)
pshufhw $0x84, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,4,6]
pxor %xmm1, %xmm0
packssdw %xmm0, %xmm0
packsswb %xmm0, %xmm0
pextrw $0x7, %xmm0, %ecx
shrl $0x8, %ecx
testb $0x1, %cl
je 0x60d2
movb $0x70, 0xf(%rax)
addq $0x18, %r14
movl %r13d, 0x8(%rdx)
movl %ebx, 0xc(%rdx)
movl $0x12345678, %ecx       # imm = 0x12345678
movl %ecx, 0x10(%rdx)
movl %ecx, (%rax,%r12)
leaq 0x113e0(%rip), %r15     # 0x174d0
movq %r15, %rdi
movq %rdx, %r12
callq 0x24c0
movq 0x11396(%rip), %rax     # 0x17498
movq %rax, (%r12)
movq %r12, 0x1138b(%rip)     # 0x17498
movq %r15, %rdi
callq 0x22d0
leaq 0x1138c(%rip), %rdi     # 0x174a8
callq 0x24c0
leaq 0x11378(%rip), %rax     # 0x174a0
movq (%rax), %rax
testq %rax, %rax
je 0x613a
cmpl %ebx, 0x10(%rax)
jne 0x6128
incl 0xc(%rax)
jmp 0x6163
movl $0x18, %edi
callq 0x22e0
movl %r13d, 0x8(%rax)
movl %ebx, 0x10(%rax)
movl $0x1, 0xc(%rax)
movq 0x11347(%rip), %rcx     # 0x174a0
movq %rcx, (%rax)
movq %rax, 0x1133d(%rip)     # 0x174a0
leaq 0x1133e(%rip), %rdi     # 0x174a8
callq 0x22d0
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x1c, %rbp
leaq 0xa68a(%rip), %rsi      # 0x10816
xorl %edi, %edi
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0xd88c
xorl %edi, %edi
callq 0xc084