// File: /workspace/github_c_makefile_star2_O3/xtanitfy[P]Murphy/src/log.c
// Function: LOG_writeBlobToTxtFile
int LOG_writeBlobToTxtFile(char *txtFile,BLOB_s *pBlob)
{
	char filepath[256];
	sprintf(filepath,"bin/%s",txtFile);
	
	int fd = open(filepath,O_RDWR | O_CREAT | O_TRUNC,0666);
	CHECK_EXPR_RET(fd < 0,-1);

	BLOB_DATA_PTR(pBlob,ptr);
	
	char buf[256];

	if (pBlob->type == BLOB_TYPE_BIAS) {
		for (int i_out = 0;i_out < pBlob->channelSize;i_out++) {
			sprintf(buf,"%.8f ",ptr[0][i_out][0][0]);
			write(fd,buf,strlen(buf));
			write(fd,"\n",1);
		}
		close(fd);
		return 0;	
	}

	if (pBlob->type == BLOB_TYPE_WEIGHT) {
		for (int i_out = 0;i_out < pBlob->numSize;i_out++) {
			for (int i_in = 0;i_in < pBlob->channelSize;i_in++) {	
				for (int i_height = 0;i_height < pBlob->heightSize;i_height++) {	
					for (int i_width = 0;i_width < pBlob->widthSize;i_width++) {	
						sprintf(buf,"%.8f ",ptr[i_out][i_in][i_height][i_width]);
						write(fd,buf,strlen(buf));
					}
					if (pBlob->widthSize> 1) {
						write(fd,"\n",1);
					}
				}
				write(fd,"\n\n",1);
			}
			write(fd,"\n",1);
		}
		
		close(fd);
		return 0;
	}
	
	
	for (int i_batch = 0;i_batch < 2/*pBlob->batches*/;i_batch++) {
		for (int i_num = 0;i_num < pBlob->channelSize;i_num++) {	
			for (int i_height = 0;i_height < (pBlob->heightSize - pBlob->pady*2);i_height++) {	
				for (int i_width = 0;i_width < (pBlob->widthSize - pBlob->padx*2);i_width++) {	
					sprintf(buf,"%.8f ",ptr[i_batch][i_num][i_height+pBlob->pady][i_width+pBlob->padx]);
					write(fd,buf,strlen(buf));
				}
				write(fd,"\n",1);
			}
			write(fd,"\n",1);
		}
		write(fd,"\n",1);
	}	

	close(fd);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rsi, %rbx
movq %rdi, %rdx
leaq 0x1dba(%rip), %rsi      # 0x3065
leaq 0x160(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x1080
testl %eax, %eax
js 0x146f
movl %eax, %edx
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movl (%rbx), %eax
cmpl $0x2, %eax
movq %rcx, 0x20(%rsp)
movl %edx, 0xc(%rsp)
je 0x149a
cmpl $0x1, %eax
jne 0x151c
cmpq $0x0, 0x10(%rbx)
je 0x16b2
movq 0x20(%rsp), %rax
imulq %rax, %rsi
movq 0x10(%rsp), %rcx
imulq %rsi, %rcx
shlq $0x3, %rcx
movq %rcx, 0x10(%rsp)
shlq $0x3, %rsi
movq %rsi, 0x38(%rsp)
shlq $0x3, %rax
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
leaq 0x60(%rsp), %r13
movl 0xc(%rsp), %ebp
movq %rcx, 0x30(%rsp)
cmpq $0x0, 0x18(%rbx)
movq 0x20(%rsp), %r12
je 0x143b
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x40(%rsp)
cmpq $0x0, 0x20(%rbx)
je 0x1407
movq 0x18(%rsp), %r14
xorl %r15d, %r15d
cmpq $0x0, 0x28(%rbx)
je 0x13fb
movq %r15, 0x48(%rsp)
xorl %r12d, %r12d
leaq 0x1cdf(%rip), %r15      # 0x3083
movsd (%r14,%r12,8), %xmm0
movq %r13, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1040
movq %r13, %rdi
callq 0x1060
movl %ebp, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x1050
incq %r12
movq 0x28(%rbx), %rax
cmpq %r12, %rax
ja 0x13a4
cmpq $0x1, %rax
movq 0x20(%rsp), %r12
movq 0x48(%rsp), %r15
jbe 0x13fb
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c94(%rip), %rsi      # 0x308a
callq 0x1050
incq %r15
addq %r12, %r14
cmpq %r15, 0x20(%rbx)
ja 0x138e
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c74(%rip), %rsi      # 0x3089
callq 0x1050
movq 0x40(%rsp), %rcx
incq %rcx
movq 0x18(%rsp), %rax
addq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq %rcx, 0x18(%rbx)
ja 0x1376
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c41(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %rax
addq %rax, 0x28(%rsp)
cmpq %rcx, 0x10(%rbx)
ja 0x1355
jmp 0x16b2
leaq 0x1bca(%rip), %rdi      # 0x3040
leaq 0x1bd9(%rip), %rsi      # 0x3056
leaq 0x1be8(%rip), %rdx      # 0x306c
movl $0x1a, %ecx
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x16bd
cmpq $0x0, 0x10(%rsp)
je 0x16b2
movq 0x20(%rsp), %rbp
imulq %rsi, %rbp
shlq $0x3, %rbp
xorl %r14d, %r14d
leaq 0x60(%rsp), %r15
movl 0xc(%rsp), %r12d
movq 0x28(%rsp), %r13
movsd (%r13), %xmm0
movq %r15, %rdi
leaq 0x1bae(%rip), %rsi      # 0x3083
movb $0x1, %al
callq 0x1040
movq %r15, %rdi
callq 0x1060
movl %r12d, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x1050
movl $0x1, %edx
movl %r12d, %edi
leaq 0x1b89(%rip), %rsi      # 0x308a
callq 0x1050
incq %r14
addq %rbp, %r13
movq %r13, 0x28(%rsp)
cmpq %r14, 0x18(%rbx)
ja 0x14c0
jmp 0x16b2
imulq %rcx, %rsi
movq %rsi, 0x38(%rsp)
movq 0x10(%rsp), %rax
imulq %rsi, %rax
movq %rax, 0x10(%rsp)
movb $0x1, %al
xorl %r14d, %r14d
movq 0x20(%rsp), %r12
movl %eax, 0x54(%rsp)
cmpq $0x0, 0x18(%rbx)
movl 0xc(%rsp), %ebp
je 0x1689
imulq 0x10(%rsp), %r14
movq 0x28(%rsp), %rax
leaq (%rax,%r14,8), %rax
movq %rax, 0x58(%rsp)
movq $0x0, 0x30(%rsp)
movslq 0x38(%rbx), %rax
addq %rax, %rax
cmpq %rax, 0x20(%rbx)
je 0x165f
movq 0x38(%rsp), %rax
imulq 0x30(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x18(%rsp)
movslq 0x3c(%rbx), %rax
leaq (%rax,%rax), %rcx
cmpq %rcx, 0x28(%rbx)
leaq 0x1ad0(%rip), %rbp      # 0x3083
leaq 0x60(%rsp), %r13
movq 0x40(%rsp), %r15
je 0x1624
movslq 0x18(%rsp), %rcx
movq %rcx, 0x48(%rsp)
xorl %r14d, %r14d
movslq 0x38(%rbx), %rcx
addq 0x48(%rsp), %rcx
imulq %r12, %rcx
leaq (%r15,%rcx,8), %rcx
addl %r14d, %eax
cltq
movsd (%rcx,%rax,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x1040
movq %r13, %rdi
callq 0x1060
movl 0xc(%rsp), %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x1050
incq %r14
movq 0x28(%rbx), %rcx
movslq 0x3c(%rbx), %rax
movq %rax, %rdx
addq %rax, %rdx
subq %rdx, %rcx
cmpq %r14, %rcx
ja 0x15cc
movl $0x1, %edx
movl 0xc(%rsp), %ebp
movl %ebp, %edi
leaq 0x1a54(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x18(%rsp), %rdx
incq %rdx
movq 0x20(%rbx), %rax
movslq 0x38(%rbx), %rcx
addq %rcx, %rcx
subq %rcx, %rax
movq %rdx, 0x18(%rsp)
cmpq %rdx, %rax
ja 0x15a0
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1a1d(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x30(%rsp), %rcx
incq %rcx
movq %rcx, 0x30(%rsp)
cmpq %rcx, 0x18(%rbx)
ja 0x156d
movl $0x1, %r14d
movl $0x1, %edx
movl %ebp, %edi
leaq 0x19ed(%rip), %rsi      # 0x308a
callq 0x1050
testb $0x1, 0x54(%rsp)
movl $0x0, %eax
jne 0x153d
movl 0xc(%rsp), %edi
callq 0x10e0
xorl %eax, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq