// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x120(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1d68(%rip), %rsi      # 0x306d
movb $0x0, %al
callq 0x1040
leaq -0x120(%rbp), %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x1080
movl %eax, -0x124(%rbp)
cmpl $0x0, -0x124(%rbp)
jge 0x1360
leaq 0x1d0e(%rip), %rdi      # 0x3048
leaq 0x1d1d(%rip), %rsi      # 0x305e
leaq 0x1d2c(%rip), %rdx      # 0x3074
movl $0x1a, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x18af
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x270(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x268(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x260(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x14a8
movl $0x0, -0x234(%rbp)
movslq -0x234(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x1491
movq -0x260(%rbp), %rcx
movq -0x268(%rbp), %rsi
movq -0x270(%rbp), %rdx
leaq -0x230(%rbp), %rdi
movq -0x130(%rbp), %rax
imulq %rsi, %rdx
imulq %rcx, %rdx
imulq $0x0, %rdx, %rdx
shlq $0x3, %rdx
addq %rdx, %rax
movslq -0x234(%rbp), %rdx
imulq %rcx, %rsi
imulq %rsi, %rdx
shlq $0x3, %rdx
addq %rdx, %rax
imulq $0x0, %rcx, %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x1c67(%rip), %rsi      # 0x308b
movb $0x1, %al
callq 0x1040
movl -0x124(%rbp), %eax
movl %eax, -0x27c(%rbp)
leaq -0x230(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x1060
movl -0x27c(%rbp), %edi
movq -0x278(%rbp), %rsi
movq %rax, %rdx
callq 0x1050
movl -0x124(%rbp), %edi
leaq 0x1c1f(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x13b3
movl -0x124(%rbp), %edi
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0x18af
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x16a4
movl $0x0, -0x238(%rbp)
movslq -0x238(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x168d
movl $0x0, -0x23c(%rbp)
movslq -0x23c(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x1662
movl $0x0, -0x240(%rbp)
movslq -0x240(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x1637
movl $0x0, -0x244(%rbp)
movslq -0x244(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x15ff
movq -0x260(%rbp), %rdx
movq -0x268(%rbp), %rsi
movq -0x270(%rbp), %r8
leaq -0x230(%rbp), %rdi
movq -0x130(%rbp), %rax
movslq -0x238(%rbp), %rcx
imulq %rsi, %r8
imulq %rdx, %r8
imulq %r8, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x23c(%rbp), %rcx
imulq %rdx, %rsi
imulq %rsi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x240(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x244(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x1ae2(%rip), %rsi      # 0x308b
movb $0x1, %al
callq 0x1040
movl -0x124(%rbp), %eax
movl %eax, -0x28c(%rbp)
leaq -0x230(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x1060
movl -0x28c(%rbp), %edi
movq -0x288(%rbp), %rsi
movq %rax, %rdx
callq 0x1050
movl -0x244(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x244(%rbp)
jmp 0x151c
movq -0x18(%rbp), %rax
cmpq $0x1, 0x28(%rax)
jbe 0x1621
movl -0x124(%rbp), %edi
leaq 0x1a7b(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
jmp 0x1623
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x14fd
movl -0x124(%rbp), %edi
leaq 0x1a4d(%rip), %rsi      # 0x3091
movl $0x1, %edx
callq 0x1050
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x14de
movl -0x124(%rbp), %edi
leaq 0x1a23(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
movl -0x238(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x238(%rbp)
jmp 0x14bf
movl -0x124(%rbp), %edi
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0x18af
movl $0x0, -0x248(%rbp)
cmpl $0x2, -0x248(%rbp)
jge 0x189d
movl $0x0, -0x24c(%rbp)
movslq -0x24c(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x1872
movl $0x0, -0x250(%rbp)
movslq -0x250(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl 0x38(%rdx), %edx
shll %edx
movslq %edx, %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jae 0x1847
movl $0x0, -0x254(%rbp)
movslq -0x254(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl 0x3c(%rdx), %edx
shll %edx
movslq %edx, %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jae 0x181c
movq -0x260(%rbp), %rdx
movq -0x268(%rbp), %rsi
movq -0x270(%rbp), %r8
leaq -0x230(%rbp), %rdi
movq -0x130(%rbp), %rax
movslq -0x248(%rbp), %rcx
imulq %rsi, %r8
imulq %rdx, %r8
imulq %r8, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x24c(%rbp), %rcx
imulq %rdx, %rsi
imulq %rsi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x250(%rbp), %ecx
movq -0x18(%rbp), %rsi
addl 0x38(%rsi), %ecx
movslq %ecx, %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x254(%rbp), %ecx
movq -0x18(%rbp), %rdx
addl 0x3c(%rdx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x18c5(%rip), %rsi      # 0x308b
movb $0x1, %al
callq 0x1040
movl -0x124(%rbp), %eax
movl %eax, -0x29c(%rbp)
leaq -0x230(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x1060
movl -0x29c(%rbp), %edi
movq -0x298(%rbp), %rsi
movq %rax, %rdx
callq 0x1050
movl -0x254(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x254(%rbp)
jmp 0x1715
movl -0x124(%rbp), %edi
leaq 0x1869(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0x16e4
movl -0x124(%rbp), %edi
leaq 0x183e(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
movl -0x24c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24c(%rbp)
jmp 0x16c5
movl -0x124(%rbp), %edi
leaq 0x1813(%rip), %rsi      # 0x3092
movl $0x1, %edx
callq 0x1050
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x248(%rbp)
jmp 0x16ae
movl -0x124(%rbp), %edi
callq 0x10d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
nopl (%rax,%rax)