// File: /workspace/github_c_makefile_star2_O1/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 0x1465
movl %eax, %edx
movq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movl (%rbx), %eax
cmpl $0x2, %eax
movq %rcx, 0x18(%rsp)
movl %edx, 0xc(%rsp)
je 0x1490
movq 0x18(%rbx), %rdx
cmpl $0x1, %eax
jne 0x1511
cmpq $0x0, 0x10(%rbx)
je 0x16ae
movq 0x18(%rsp), %rax
imulq %rax, %rsi
imulq %rsi, %rdx
shlq $0x3, %rdx
movq %rdx, 0x30(%rsp)
shlq $0x3, %rsi
movq %rsi, 0x40(%rsp)
shlq $0x3, %rax
movq %rax, 0x18(%rsp)
xorl %ecx, %ecx
leaq 0x60(%rsp), %r13
movl 0xc(%rsp), %ebp
movq %rcx, 0x28(%rsp)
cmpq $0x0, 0x18(%rbx)
movq 0x18(%rsp), %r12
je 0x1431
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x48(%rsp)
cmpq $0x0, 0x20(%rbx)
je 0x13fd
movq 0x10(%rsp), %r14
xorl %r15d, %r15d
cmpq $0x0, 0x28(%rbx)
je 0x13f1
movq %r15, 0x50(%rsp)
xorl %r12d, %r12d
leaq 0x1ce9(%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 0x139a
cmpq $0x1, %rax
movq 0x18(%rsp), %r12
movq 0x50(%rsp), %r15
jbe 0x13f1
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c9e(%rip), %rsi      # 0x308a
callq 0x1050
incq %r15
addq %r12, %r14
cmpq %r15, 0x20(%rbx)
ja 0x1384
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c7e(%rip), %rsi      # 0x3089
callq 0x1050
movq 0x48(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %rax
addq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq %rcx, 0x18(%rbx)
ja 0x136c
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1c4b(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x28(%rsp), %rcx
incq %rcx
movq 0x30(%rsp), %rax
addq %rax, 0x20(%rsp)
cmpq %rcx, 0x10(%rbx)
ja 0x134b
jmp 0x16ae
leaq 0x1bd4(%rip), %rdi      # 0x3040
leaq 0x1be3(%rip), %rsi      # 0x3056
leaq 0x1bf2(%rip), %rdx      # 0x306c
movl $0x1a, %ecx
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x16b9
cmpq $0x0, 0x18(%rbx)
je 0x16ae
movq 0x18(%rsp), %rbp
imulq %rsi, %rbp
shlq $0x3, %rbp
xorl %r14d, %r14d
leaq 0x60(%rsp), %r15
movl 0xc(%rsp), %r12d
movq 0x20(%rsp), %r13
movsd (%r13), %xmm0
movq %r15, %rdi
leaq 0x1bb9(%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 0x1b94(%rip), %rsi      # 0x308a
callq 0x1050
incq %r14
addq %rbp, %r13
movq %r13, 0x20(%rsp)
cmpq %r14, 0x18(%rbx)
ja 0x14b5
jmp 0x16ae
imulq %rcx, %rsi
movq %rsi, 0x40(%rsp)
imulq %rsi, %rdx
movq %rdx, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x18(%rsp), %r12
cmpq $0x0, 0x18(%rbx)
movl 0xc(%rsp), %ebp
je 0x1684
movq 0x30(%rsp), %rax
imulq 0x38(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x58(%rsp)
movq $0x0, 0x28(%rsp)
movslq 0x38(%rbx), %rax
addq %rax, %rax
cmpq %rax, 0x20(%rbx)
je 0x165a
movq 0x40(%rsp), %rax
imulq 0x28(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x48(%rsp)
movq $0x0, 0x10(%rsp)
movslq 0x3c(%rbx), %rax
leaq (%rax,%rax), %rcx
cmpq %rcx, 0x28(%rbx)
leaq 0x1adb(%rip), %rbp      # 0x3083
movq 0x48(%rsp), %r15
movq %rbx, %r13
leaq 0x60(%rsp), %rbx
je 0x161c
movslq 0x10(%rsp), %rcx
movq %rcx, 0x50(%rsp)
xorl %r14d, %r14d
movslq 0x38(%r13), %rcx
addq 0x50(%rsp), %rcx
imulq %r12, %rcx
leaq (%r15,%rcx,8), %rcx
addl %r14d, %eax
cltq
movsd (%rcx,%rax,8), %xmm0
movq %rbx, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x1040
movq %rbx, %rdi
callq 0x1060
movl 0xc(%rsp), %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1050
incq %r14
movq 0x28(%r13), %rcx
movslq 0x3c(%r13), %rax
movq %rax, %rdx
addq %rax, %rdx
subq %rdx, %rcx
cmpq %r14, %rcx
ja 0x15c4
movl $0x1, %edx
movl 0xc(%rsp), %ebp
movl %ebp, %edi
leaq 0x1a5c(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x10(%rsp), %rdx
incq %rdx
movq 0x20(%r13), %rax
movslq 0x38(%r13), %rcx
addq %rcx, %rcx
subq %rcx, %rax
movq %rdx, 0x10(%rsp)
cmpq %rdx, %rax
movq %r13, %rbx
ja 0x1595
movl $0x1, %edx
movl %ebp, %edi
leaq 0x1a22(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq %rcx, 0x18(%rbx)
ja 0x1562
movl $0x1, %edx
movl %ebp, %edi
leaq 0x19f8(%rip), %rsi      # 0x308a
callq 0x1050
movq 0x38(%rsp), %rcx
leaq 0x1(%rcx), %rax
testq %rcx, %rcx
movq %rax, 0x38(%rsp)
je 0x1531
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