// File: /workspace/github_cpp_makefile_star2_O3/AndreyVV-100[P]GachiLang/TreeBase/Stack.cpp
// Function: StackLog(Stack*)
void StackLog(Stack* stk)
{
	FILE* file = fopen ("stklog.txt", "a");

	struct tm* mytime = nullptr;
	time_t alltime = 0;
	time (&alltime);
	mytime = localtime (&alltime);
	fprintf (file, "\n%s", asctime (mytime));

	if (!stk)
	{
		fprintf (file, "Stack [STK_NULL] : The address of stack is null.\n\n");

		fclose (file);

		return;
	}

	switch (stk->status_error)
	{
		case BUF_NULL:
			fprintf(file, "Stack [BUF_NULL] : The address of buffer is nullptr.\n" "End of log.\n");
			fclose(file);
			return;

		case STK_PETREL_B:
			fprintf(file, "Stack [STK_PETREL_B] : The begin stormy petrel in stack was damaged.\n" "End of log.\n");
			fclose(file);
			return;

		case STK_PETREL_E:
			fprintf(file, "Stack [STK_PETREL_E] : The end stormy petrel in stack was damaged.\n" "End of log.\n");
			fclose(file);
			return;

		case STK_DEL:
			fprintf(file, "Stack [STK_DEL] : The stack was deleted.\n" "End of log.\n");
			fclose(file);
			return;

		case DO_MEM_ERR:
			fprintf(file, "Stack [DO_MEM_ERR] : The program can`t pick out new memory.\n" "End of log.\n");
			fclose(file);
			return;

		case NOT_CREATED:
			fprintf(file, "Stack [NOT_CREATED] : Attempt to manipulation with stack which wasn`t constructed.\n" "End of log.\n");
			fclose(file);
			return;

		case STK_GOOD:
			fprintf (file, "Stack [STK_GOOD] : Nice!\n");
			break;

		case BAD_SIZE_CAP:
			fprintf (file, "Stack [BAD_SIZE_CAP] : The size of stack is more then capacity.\n");
			break;

		case BAD_SIZE_ZERO:
			fprintf (file,  "Stack [BAD_SIZE_ZERO] : StackPop was called when size was zero.\n");
			break;

		case BAD_CAP:
			fprintf (file, "Stack [BAD_CAP] : The capacity of stack is less then minimal capacity.\n");
			break;

		case BUF_PETREL_B:
			fprintf (file, "Stack [BUF_PETREL_B] : The begin stormy petrel in buffer was damaged.\n");
			break;

		case BUF_PETREL_E:
			fprintf (file, "Stack [BUF_PETREL_E] : The end stormy petrel in buffer was damaged.");
			break;

		case BAD_CREATE:
			fprintf (file, "Stack [BAD_CREATE] : Trying to construct stack which already not empty.\n");
			break;

		case ERR_HASH_STK:
			fprintf (file, "Stack [ERR_HASH_STK] : Data in stack was changed illegally.");
			break;

		case ERR_HASH_BUF:
			fprintf (file, "Stack [ERR_HASH_BUF] : Data in buffer was changed illegally.");
			break;

		default:
			fprintf (file, "Stack [UNK] : Unknown error.\n");
			break;
	};

	fprintf (file, "size = %lu\n" "capacity = %lu\n" "min_capacity = %lu\n" "buffer:\n", 
			   stk->size,     stk->capacity,     stk->min_capacity);

	/*
	fprintf (file, "begin buffer petrel = %llX\n" "end buffer petrel   = %llX\n",
		*((storm*) (stk->buffer - 1)),
		*((storm*) (stk->buffer + stk->capacity)));
	

	for (int element = 0; element < stk->capacity; element++)
		fprintf (file, "[%d] = %lf\n", element, stk->buffer[element]);
		*/
	for (size_t i_elem = 0; i_elem < stk->size; i_elem++)
		printf ("Type: %d - %s\n", stk->buffer[i_elem].type, (stk->buffer[i_elem].ind) ? stk->buffer[i_elem].ind : "");

	fprintf (file, "\n" "End of log.\n");
	fclose  (file);

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x229c(%rip), %rdi      # 0x5e55
leaq 0x22a0(%rip), %rsi      # 0x5e60
callq 0x1110
movq %rax, %rbx
leaq -0x38(%rbp), %r15
movq $0x0, (%r15)
movq %r15, %rdi
callq 0x10e0
movq %r15, %rdi
callq 0x10b0
movq %rax, %rdi
callq 0x1060
leaq 0x2270(%rip), %rsi      # 0x5e62
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1160
testq %r14, %r14
je 0x3c33
movl 0x28(%r14), %eax
cmpq $0xf, %rax
ja 0x3ca6
leaq 0x2183(%rip), %rcx      # 0x5d9c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2433(%rip), %rdi      # 0x605c
movl $0x19, %esi
jmp 0x3d26
leaq 0x222c(%rip), %rdi      # 0x5e66
movl $0x32, %esi
movl $0x1, %edx
jmp 0x3dae
leaq 0x25c4(%rip), %rdi      # 0x6214
movl $0x3b, %esi
jmp 0x3d26
leaq 0x2352(%rip), %rdi      # 0x5fb3
movl $0x48, %esi
jmp 0x3c3f
leaq 0x255c(%rip), %rdi      # 0x61cb
movl $0x48, %esi
jmp 0x3d26
leaq 0x2219(%rip), %rdi      # 0x5e99
movl $0x41, %esi
jmp 0x3c3f
leaq 0x246a(%rip), %rdi      # 0x60f8
movl $0x47, %esi
jmp 0x3d26
leaq 0x235d(%rip), %rdi      # 0x5ffc
movl $0x5f, %esi
jmp 0x3c3f
leaq 0x25e0(%rip), %rdi      # 0x628d
movl $0x1d, %esi
jmp 0x3d26
leaq 0x22c2(%rip), %rdi      # 0x5f7d
movl $0x35, %esi
jmp 0x3c3f
leaq 0x220f(%rip), %rdi      # 0x5edb
movl $0x51, %esi
jmp 0x3c3f
leaq 0x2250(%rip), %rdi      # 0x5f2d
movl $0x4f, %esi
jmp 0x3c3f
leaq 0x2562(%rip), %rdi      # 0x6250
movl $0x3c, %esi
jmp 0x3d26
leaq 0x237a(%rip), %rdi      # 0x6076
jmp 0x3d05
leaq 0x23b2(%rip), %rdi      # 0x60b7
movl $0x40, %esi
jmp 0x3d26
leaq 0x2474(%rip), %rdi      # 0x6187
movl $0x43, %esi
jmp 0x3d26
leaq 0x241f(%rip), %rdi      # 0x6140
movl $0x46, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rcx
movq 0x20(%r14), %r8
leaq 0x2565(%rip), %rsi      # 0x62ab
movq %rbx, -0x30(%rbp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1160
cmpq $0x0, 0x10(%r14)
je 0x3d99
leaq 0x18ee(%rip), %r12      # 0x5650
leaq 0x2578(%rip), %r15      # 0x62e1
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x8(%r14), %rax
movl (%rax,%r13), %esi
movq 0x18(%rax,%r13), %rdx
testq %rdx, %rdx
cmoveq %r12, %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1040
incq %rbx
addq $0x30, %r13
cmpq 0x10(%r14), %rbx
jb 0x3d6e
leaq 0x21cf(%rip), %rdi      # 0x5f6f
movl $0xd, %esi
movl $0x1, %edx
movq -0x30(%rbp), %rbx
movq %rbx, %rcx
callq 0x11a0
movq %rbx, %rdi
callq 0x10f0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq