LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::isUStar()
int MyTar::isUStar(){
    this->inputStream.seekg(0, ios::end);
    int fileSize = this->inputStream.tellg();

    /// If the file is not the mutiple of 512, the file is not USTAR format.
    if(fileSize % this->usBlockSize == 0){
        this->inputStream.seekg(257, ios::beg);
        char buffer[6];

        /// If the USTAR_id != "ustar ", the file is not USTAR format.
        if(this->inputStream.read(buffer, 6)){
            string str(buffer);
            if(str == "ustar "){
                return MyTar::USTAR;
            }
        }
    }

    return MyTar::NO_USTAR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
xorl %ebx, %ebx
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x21e0
movq %r14, %rdi
callq 0x2250
cltd
idivl 0x220(%r14)
testl %edx, %edx
jne 0x264a
xorl %ebx, %ebx
movl $0x101, %esi            # imm = 0x101
movq %r14, %rdi
xorl %edx, %edx
callq 0x21e0
leaq -0x1f(%rbp), %rsi
pushq $0x6
popq %rdx
movq %r14, %rdi
callq 0x21c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x264a
leaq -0x40(%rbp), %r14
leaq -0x1f(%rbp), %rsi
leaq -0x19(%rbp), %rdx
movq %r14, %rdi
callq 0x2d00
leaq 0x1a26(%rip), %rsi      # 0x4055
movq %r14, %rdi
callq 0x2d3b
movl %eax, %r15d
movq %r14, %rdi
callq 0x20c0
testb %r15b, %r15b
je 0x264a
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::startRead()
int MyTar::startRead(){

    /// If the file is not the mutiple of 512, the file is not USTAR format.
    if(MyTar::USTAR != this->isUStar()){
        return MyTar::NO_USTAR;
    }

    /// Make pointer to the first of the tar file.
    this->inputStream.seekg(0, ios::beg);

    while(this->inputStream){
        struct TarHeader buffer;

        if(this->inputStream.read((char*)&buffer, this->usBlockSize)){
            this->tarVector.push_back(buffer);

            int fileSize = this->hex2Dec(buffer.filesize, sizeof(buffer.filesize));

            /* After the header data is the content of the file in tar file.
             * So we need to ignore the block of the content.
             * jumpBock represents how many blocks we need to ignore.
             */
            int jumpBlock = ceil((double)fileSize / (double)this->usBlockSize);
            this->inputStream.seekg(jumpBlock * this->usBlockSize, ios::cur);
        }
    }

    /// If the size of tarVector > 0, the operation of reading successed.
    return this->tarVector.size() > 0 ? MyTar::USTAR : MyTar::NO_USTAR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
callq 0x25b6
testl %eax, %eax
je 0x2728
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21e0
leaq 0x208(%rbx), %r14
leaq -0x228(%rbp), %r12
pushq $0x1
popq %r15
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x2713
movslq 0x220(%rbx), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x269a
movq %r14, %rdi
movq %r12, %rsi
callq 0x2d4c
leaq -0x1ac(%rbp), %rsi
pushq $0xc
popq %rdx
callq 0x273c
cvtsi2sd %eax, %xmm0
movl 0x220(%rbx), %r13d
cvtsi2sd %r13d, %xmm1
divsd %xmm1, %xmm0
callq 0x2030
cvttsd2si %xmm0, %eax
imull %r13d, %eax
movslq %eax, %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x21e0
jmp 0x269a
movq 0x210(%rbx), %rcx
xorl %eax, %eax
cmpq 0x208(%rbx), %rcx
setne %al
jmp 0x272a
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::hex2Dec(char const*, int)
int MyTar::hex2Dec(const char* sizeArray, int length){
    int n = 0;
    int ans = 0;

    /* i = length - 2 beacuse the last char in sizeArray is null.
     * So we need to ignore it.
     */
    for(int i = length - 2; i > -1; i--){
        int num = sizeArray[i] >= 'a' && sizeArray[i] <= 'f' ? sizeArray[i] - 'a' + 10 : sizeArray[i] - '0';

        ans += num * pow(16, n);
        ++n;
    }

    /// return bytes, not bits.
    return ans /= 8;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r14
addl $-0x2, %ebx
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
testl %ebx, %ebx
js 0x27b6
movl %ebx, %eax
movsbl (%r14,%rax), %eax
leal -0x61(%rax), %ecx
leal -0x30(%rax), %edx
addl $-0x57, %eax
cmpb $0x6, %cl
cmovael %edx, %eax
cvtsi2sd %eax, %xmm1
movsd %xmm1, -0x28(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
mulsd 0x18ab(%rip), %xmm0     # 0x4038
callq 0x2160
cvtsi2sd %r15d, %xmm1
mulsd -0x28(%rbp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r15d
movsd -0x20(%rbp), %xmm0
addsd 0x188e(%rip), %xmm0     # 0x4040
decl %ebx
jmp 0x2758
pushq $0x8
popq %rcx
movl %r15d, %eax
cltd
idivl %ecx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::getFileNum()
int MyTar::getFileNum(){

    /// If fileNum > -1, return it directly.
    if(this->fileNum >= 0){
        return this->fileNum;
    }

    /* If the checksum is NULL, the block is NULL.
     * Check until the checksum is not NULL.
     * And return the number of files.
    */
    for(int i = this->tarVector.size() - 1; i > -1; i--){
        bool zeroFlag = true;
        struct TarHeader buffer = this->tarVector.at(i);

        for(int j = 0; j < (int)sizeof(buffer.checksum); j++){
            if(buffer.checksum[j] != 0x00){
                zeroFlag = false;

                break;
            }
        }

        if(!zeroFlag){
            /// Assign the value to the fileNum.
            this->fileNum = i + 1;
            break;
        }
    }

    return this->fileNum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movl 0x224(%rdi), %r14d
testl %r14d, %r14d
jns 0x2b7d
movq %rdi, %rbx
movq 0x210(%rdi), %rax
subq 0x208(%rdi), %rax
leaq 0x208(%rdi), %r15
shrq $0x9, %rax
movl %eax, %r14d
leaq -0x228(%rbp), %r12
leaq -0x1(%r14), %r13
testl %r13d, %r13d
js 0x2b92
movl %r13d, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %r15, %rdi
callq 0x2d92
movl $0x200, %edx            # imm = 0x200
movq %r12, %rdi
movq %rax, %rsi
callq 0x2120
movl $0x94, %eax
cmpq $0x9c, %rax
je 0x2b71
cmpb $0x0, -0x228(%rbp,%rax)
leaq 0x1(%rax), %rax
je 0x2b59
jmp 0x2b76
movq %r13, %r14
jmp 0x2b2a
movl %r14d, 0x224(%rbx)
movl %r14d, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x224(%rbx), %r14d
jmp 0x2b7d
nop
// File: /workspace/github_cpp_makefile_star2_O2/CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::getFileMode[abi:cxx11](int)
string MyTar::getFileMode(int modeNum){
    char r = 'r', w = 'w', x = 'x', no = '-';
    string fileMode[3];

    int index = 2;
    while(modeNum > 0){
        int subMode = modeNum % 10;
        modeNum /= 10;

        /// Check the read priviledge section.
        if(subMode >= 4){
            fileMode[index] += r;
            subMode -= 4;
        }
        else{
            fileMode[index] += no;
        }

        /// Check the write priviledge section.
        if(subMode >= 2){
            fileMode[index] += w;
            subMode -= 2;
        }
        else{
            fileMode[index] += no;
        }

        /// Check the execution priviledge section.
        if(subMode >= 1){
            fileMode[index] += x;
            subMode -= 1;
        }
        else{
            fileMode[index] += no;
        }

        --index;
    }

    return fileMode[0] + fileMode[1] + fileMode[2];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %r14d
movq %rdi, -0x30(%rbp)
pushq $0x10
popq %rax
leaq (%rax,%rbp), %rcx
addq $-0xb0, %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x70, %rax
jne 0x2bba
leaq -0x70(%rbp), %r15
pushq $0xa
popq %r13
pushq $0x2d
popq %rbx
testl %r14d, %r14d
jle 0x2c52
movl %r14d, %eax
xorl %edx, %edx
divl %r13d
movl %edx, %r12d
movl %eax, %r14d
cmpl $0x4, %edx
jb 0x2c0f
movq %r15, %rdi
pushq $0x72
popq %rsi
callq 0x2130
addl $-0x4, %r12d
jmp 0x2c19
movq %r15, %rdi
movl %ebx, %esi
callq 0x2130
cmpl $0x2, %r12d
jb 0x2c30
movq %r15, %rdi
pushq $0x77
popq %rsi
callq 0x2130
addl $-0x2, %r12d
jmp 0x2c3a
movq %r15, %rdi
movl %ebx, %esi
callq 0x2130
movl %ebx, %esi
testl %r12d, %r12d
je 0x2c44
pushq $0x78
popq %rsi
movq %r15, %rdi
callq 0x2130
addq $-0x20, %r15
jmp 0x2be6
leaq -0x90(%rbp), %rdx
leaq -0x50(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2e0c
leaq -0x70(%rbp), %rdx
leaq -0x50(%rbp), %rsi
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x2de3
leaq -0x50(%rbp), %rdi
callq 0x20c0
pushq $0x40
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xb0, %rdi
callq 0x20c0
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x2c89
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20c0
jmp 0x2ccb
jmp 0x2cc8
movq %rax, %rbx
pushq $0x40
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0xb0, %rdi
callq 0x20c0
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x2ccf
movq %rbx, %rdi
callq 0x2260
// File: /workspace/github_cpp_makefile_star2_O2/rthoelen[P]NXCore_Icom/main.cc
// Function: timing_thread(void*)
void *timing_thread(void *t_id)
{
	int i;
	unsigned int seconds = 0;
	char h_buf[20];
	
	
        memset((char *)&h_buf[0], 0, sizeof(h_buf));
	h_buf[0] = 'N';
	h_buf[1] = 'X';
	h_buf[2] = 'D';
	h_buf[3] = 'N';
	h_buf[4] = 0x00;
	h_buf[5] = 0x99;
	h_buf[6] = 0x00;
	h_buf[7] = 'N';
	h_buf[8] = '1';
	h_buf[9] = 'X';
	h_buf[10] = 'D';
	h_buf[11] = 'N';

	for(;;)
	{
		for( i = 0; i < repeater_count; i++)
		{
			repeater[i].time_since_rx++;
			repeater[i].time_since_tx++;

			if(repeater[i].time_since_rx > repeater[i].hold_time)
			{
				repeater[i].time_since_rx = repeater[i].hold_time;
				repeater[i].rx_activity = 0;
			}

			while(tx_busy_sem == 1)
				usleep(1);
			if(repeater[i].time_since_tx > repeater[i].tx_hold_time)
			{
				repeater[i].time_since_tx = repeater[i].tx_hold_time;
				repeater[i].tx_busy = 0;
			}


		}	
		if((++seconds % 30) == 0)
		{
			for( i = 0; i < repeater_count; i++)
				{
					if(repeater[i].stealth)
						sendto(socket_00, h_buf, sizeof(h_buf), 0, (struct sockaddr *)&repeater[i].rpt_addr_00,
							sizeof(repeater[i].rpt_addr_00));
				}
		}


		sleep(1);
	}

	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
andl $0x0, 0x10(%rax)
movl $0x4e44584e, (%rax)     # imm = 0x4E44584E
movb $-0x67, 0x5(%rax)
movl $0x4458314e, 0x7(%rax)  # imm = 0x4458314E
movb $0x4e, 0xb(%rax)
movq $0x0, -0x30(%rbp)
pushq $0x1
popq %r15
pushq $0x14
popq %r12
pushq $0x10
popq %r13
xorl %r14d, %r14d
movslq 0xebc9(%rip), %rcx      # 0x14378
cmpq %rcx, %r14
jge 0x5817
movq 0xeb9d(%rip), %rax      # 0x14358
imulq $0x70, %r14, %rbx
movl 0x18(%rax,%rbx), %edx
movl 0x20(%rax,%rbx), %ecx
leal 0x1(%rdx), %esi
movl %esi, 0x18(%rax,%rbx)
incl 0x1c(%rax,%rbx)
cmpl %ecx, %edx
jl 0x57ec
leaq (%rax,%rbx), %rdx
movl %ecx, 0x18(%rdx)
andl $0x0, 0x28(%rax,%rbx)
jmp 0x57ec
movl %r15d, %edi
callq 0x4410
cmpl $0x1, 0xeb91(%rip)      # 0x14384
je 0x57e4
movq 0xeb5c(%rip), %rax      # 0x14358
movl 0x24(%rax,%rbx), %ecx
cmpl %ecx, 0x1c(%rax,%rbx)
jle 0x5812
leaq (%rax,%rbx), %rdx
movl %ecx, 0x1c(%rdx)
andl $0x0, 0x2c(%rax,%rbx)
incq %r14
jmp 0x57a8
movq -0x30(%rbp), %rax
incl %eax
movq %rax, -0x30(%rbp)
xorl %edx, %edx
pushq $0x1e
popq %rsi
divl %esi
testl %edx, %edx
je 0x5839
movl %r15d, %edi
callq 0x4220
jmp 0x57a5
xorl %r14d, %r14d
xorl %ebx, %ebx
movslq %ecx, %rax
cmpq %rax, %rbx
jge 0x582c
movq 0xeb0b(%rip), %r8       # 0x14358
cmpl $0x0, 0x58(%r8,%r14)
je 0x5875
addq %r14, %r8
movl 0xeb22(%rip), %edi      # 0x14380
leaq -0x50(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movl %r13d, %r9d
callq 0x4050
movl 0xeb03(%rip), %ecx      # 0x14378
incq %rbx
addq $0x70, %r14
jmp 0x583e
// File: /workspace/github_cpp_makefile_star2_O2/gty980218[P]ee450/./scheduler.h
// Function: Scheduler::init_info(int, int, int, sockaddr_in)
void Scheduler::init_info(int i,int cpblt,int ocpt,sockaddr_in addr){
    this->hspt_info[i].cpblt=cpblt;
    this->hspt_info[i].ocpt=ocpt;
    this->hspt_info[i].addr=addr;
    this->hspt_info[i].score=-1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movslq %esi, %rax
imulq $0x28, %rax, %rax
movl %edx, 0x10(%rdi,%rax)
movl %ecx, 0x14(%rdi,%rax)
movq %r8, (%rdi,%rax)
movq %r9, 0x8(%rdi,%rax)
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq %rcx, 0x18(%rdi,%rax)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/gty980218[P]ee450/scheduler.cpp
// Function: main
int main(){
    //initailize UDP sock
    int sock_udp;
    if((sock_udp=socket(PF_INET,SOCK_DGRAM,0))<0){
        fprintf(stderr,"Create UDP socket failed!\n");
        exit(1);
    }
    struct sockaddr_in scheaddr;
    memset(&scheaddr, 0, sizeof(scheaddr));
	scheaddr.sin_family = AF_INET;                          //use IPv4
	scheaddr.sin_port = htons(33188);
	scheaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    if(bind(sock_udp, (struct sockaddr*)& scheaddr, sizeof(scheaddr)) < 0){
        fprintf(stderr,"Binding UDP failed,check the availability of port!\n");
        exit(1);
    }
    cout<<"The Scheduler is up and running."<<endl;
    //initialize sheduler
    init_sche(sock_udp);
    //initialize TCP sock
    int sock_tcp;
    if((sock_tcp=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP))<0){
        fprintf(stderr,"Create TCP socket failed!\n");
        exit(1);
    }
    struct sockaddr_in servaddr;
    memset(&servaddr, 0, sizeof(servaddr));
	servaddr.sin_family = AF_INET;
	servaddr.sin_port = htons(34188); 
	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    if(bind(sock_tcp, (struct sockaddr*)& servaddr, sizeof(servaddr)) < 0){
        fprintf(stderr,"Binding TCP failed,check the availability of port!\n");
        exit(1);
    }
    if(listen(sock_tcp,SOMAXCONN)<0){
        fprintf(stderr,"Listen failed!");
        exit(1);
    }
    //connect tcp
    tcp_conn(sock_tcp,sock_udp);

    close(sock_tcp);
    close(sock_udp); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x2070
testl %eax, %eax
jns 0x2443
movq 0x3ba3(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1bd1(%rip), %rdi      # 0x4010
pushq $0x1a
jmp 0x2477
movl %eax, %ebx
leaq -0x30(%rbp), %rsi
andq $0x0, 0x8(%rsi)
movl $0xa4810002, %eax       # imm = 0xA4810002
movq %rax, (%rsi)
pushq $0x10
popq %rdx
movl %ebx, %edi
callq 0x2040
testl %eax, %eax
jns 0x2488
movq 0x3b6d(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1bb6(%rip), %rdi      # 0x402b
pushq $0x33
popq %rsi
pushq $0x1
popq %rdx
callq 0x2270
pushq $0x1
popq %rdi
callq 0x21a0
movq 0x3b41(%rip), %rdi      # 0x5fd0
leaq 0x1bc9(%rip), %rsi      # 0x405f
callq 0x2160
movq %rax, %rdi
callq 0x20e0
movl %ebx, %edi
callq 0x253e
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
pushq $0x6
popq %rdx
callq 0x2070
testl %eax, %eax
jns 0x24d2
movq 0x3b15(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1bb3(%rip), %rdi      # 0x4080
jmp 0x243f
movl %eax, %r14d
leaq -0x20(%rbp), %rsi
andq $0x0, 0x8(%rsi)
movl $0x8c850002, %eax       # imm = 0x8C850002
movq %rax, (%rsi)
pushq $0x10
popq %rdx
movl %r14d, %edi
callq 0x2040
testl %eax, %eax
jns 0x250b
movq 0x3adc(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b95(%rip), %rdi      # 0x409b
jmp 0x2475
movl %r14d, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x2180
testl %eax, %eax
jns 0x2534
movq 0x3ab5(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1ba2(%rip), %rdi      # 0x40cf
pushq $0xe
jmp 0x2477
movl %r14d, %edi
movl %ebx, %esi
callq 0x278c
// File: /workspace/github_cpp_makefile_star2_O2/gty980218[P]ee450/scheduler.cpp
// Function: tcp_conn(int, int)
void tcp_conn(int sock_tcp,int sock_udp){
    struct sockaddr_in peeraddr;
    socklen_t peerlen=sizeof(peeraddr);
    int conn;
    pid_t pid;

    while(1){
        if((conn=accept(sock_tcp,(struct sockaddr*)&peeraddr,&peerlen))<0){
            fprintf(stderr,"Connetc failed!");
            exit(1);
        }
        reinit();
        pid=fork();                                                     //fork() will copy everything from its parents' process
        if(pid==-1){
            fprintf(stderr,"Child process error!");
        }else if(pid==0){
            close(sock_tcp);
            serve(conn,sock_udp);
            exit(1);
        }else{
            close(conn);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, -0x2c(%rbp)
movl %edi, %r14d
leaq -0x30(%rbp), %r15
movl $0x10, (%r15)
leaq -0x40(%rbp), %r12
pushq $0x1
popq %r13
movl %r14d, %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x20a0
testl %eax, %eax
js 0x2804
movl %eax, %ebx
callq 0x283c
callq 0x2090
cmpl $-0x1, %eax
je 0x27e6
testl %eax, %eax
je 0x2822
movl %ebx, %edi
callq 0x2280
jmp 0x27b6
movq 0x37eb(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x18f7(%rip), %rdi      # 0x40ee
pushq $0x14
popq %rsi
movq %r13, %rdx
callq 0x2270
jmp 0x27b6
movq 0x37cd(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x18c9(%rip), %rdi      # 0x40de
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2270
jmp 0x2834
movl %r14d, %edi
callq 0x2280
movl %ebx, %edi
movl -0x2c(%rbp), %esi
callq 0x2928
pushq $0x1
popq %rdi
callq 0x21a0
// File: /workspace/github_cpp_makefile_star2_O2/gty980218[P]ee450/scheduler.cpp
// Function: reinit()
void reinit(){
    ifstream infile; 
    infile.open("info.txt");  //"info.txt" used for storing changed occupancy info
    assert(infile.is_open());

    string str;
    int i=0;
    while(getline(infile,str)){
        int ocpt=atoi(str.c_str());
        scheduler.hspt_info[i].ocpt=ocpt;
        i++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
leaq -0x240(%rbp), %rbx
movq %rbx, %rdi
callq 0x2190
leaq 0x18a1(%rip), %rsi      # 0x4103
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x20f0
leaq -0x1c8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x28e6
leaq -0x28(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x38f0(%rip), %r15      # 0x6184
leaq -0x38(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28c3
movq -0x38(%rbp), %rdi
callq 0x2200
movl %eax, (%r15)
addq $0x28, %r15
jmp 0x2898
leaq -0x38(%rbp), %rdi
callq 0x20d0
leaq -0x240(%rbp), %rdi
callq 0x2080
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x181f(%rip), %rdi      # 0x410c
leaq 0x1829(%rip), %rsi      # 0x411d
leaq 0x1830(%rip), %rcx      # 0x412b
pushq $0x5c
popq %rdx
callq 0x2100
movq %rax, %rbx
jmp 0x2914
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x20d0
leaq -0x240(%rbp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2240
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::Init()
void ConstructLayer::Init()
{
    if(__type == LayerType::input) 
    {
        InitNeurons();
        InitFilters(); // input layer need to init filters, make all neurons active
    }
    else if(__type == LayerType::output) // output layer, reserved
    {
        InitNeurons();
        InitWeightsAndBias();
    }
    else  // other layer
    {
        InitNeurons();
        InitWeightsAndBias();
    }

    // setup drop out pool
    InitFilters();
    if(__use_drop_out)
    {
        SetupDropOutFilterPool();
    }

    // init batch normalization
    if(__use_batch_normalization)
    {
        InitBatchNormalizationParameters();
    }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0xc(%rdi), %ebp
movq (%rdi), %rax
callq *0xb8(%rax)
movq (%rbx), %rax
cmpl $0x3, %ebp
movl $0x90, %ecx
movl $0xc0, %edx
cmoveq %rcx, %rdx
movq %rbx, %rdi
callq *(%rax,%rdx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
cmpb $0x1, 0x3c8(%rbx)
jne 0x5ac1
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x208(%rax)
cmpb $0x1, 0x210(%rbx)
jne 0x5ad8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5ae0
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::SetNumberOfNeuronsFC(unsigned long)
void  ConstructLayer::SetNumberOfNeuronsFC(size_t n)
{
    if(__type == LayerType::fullyConnected || __type == LayerType::output) {
        __n_neurons_fc = n;
    }
    else {
        std::cout<<"Error: needs to set layer type before setting number of neurons."
            <<std::endl;
        exit(0);
    }
}

// Assembly:
testl $0xfffffffb, 0xc(%rdi)  # imm = 0xFFFFFFFB
jne 0x5fa4
movq %rsi, 0x10(%rdi)
retq
pushq %rax
movq 0x2d02c(%rip), %rdi     # 0x32fd8
leaq 0x1b613(%rip), %rsi     # 0x215c6
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::SetNumberOfKernelsCNN(unsigned long)
void  ConstructLayer::SetNumberOfKernelsCNN(size_t n)
{
    if(__type != LayerType::cnn && __type != LayerType::pooling)
    {
        std::cout<<"Error: needs to set layer type before setting number of kernels."
            <<std::endl;
        exit(0);
    }
    __n_kernels_cnn = n;
}

// Assembly:
movl 0xc(%rdi), %eax
decl %eax
cmpl $0x2, %eax
jae 0x5fd7
movq %rsi, 0x18(%rdi)
retq
pushq %rax
movq 0x2cff9(%rip), %rdi     # 0x32fd8
leaq 0x1b621(%rip), %rsi     # 0x21607
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::SetKernelSizeCNN(std::pair<unsigned long, unsigned long>)
void  ConstructLayer::SetKernelSizeCNN(std::pair<size_t, size_t> s)
{
    // pooling layer also borrowed this function
    if(__type != LayerType::cnn && __type != LayerType::pooling)
    {
        std::cout<<__func__<<" Error: needs to set layer type before setting kernel size."
            <<std::endl;
        exit(0);
    }

    __kernelDim.first = s.first;
    __kernelDim.second = s.second;
}

// Assembly:
movl 0xc(%rdi), %eax
decl %eax
cmpl $0x2, %eax
jae 0x600d
movq %rsi, 0x20(%rdi)
movq %rdx, 0x28(%rdi)
retq
pushq %rax
movq 0x2cfc3(%rip), %rdi     # 0x32fd8
leaq 0x1b62c(%rip), %rsi     # 0x21648
callq 0x4240
leaq 0x1b631(%rip), %rsi     # 0x21659
movq %rax, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::InitNeurons()
void ConstructLayer::InitNeurons()
{
    if(__type == LayerType::cnn)
        InitNeuronsCNN();
    else if(__type == LayerType::pooling)
        InitNeuronsPooling();
    else if(__type == LayerType::input)
        InitNeuronsInputLayer();
    else if(__type == LayerType::fullyConnected)
        InitNeuronsFC();
    else if(__type == LayerType::output)
        InitNeuronsFC();
    else
    {
        std::cout<<"Error: Init neurons, unrecognized layer type."<<std::endl;
        exit(0);
    }
    //std::cout<<"Debug: Layer:"<<GetID()<<" init neruons done."<<std::endl;

    // after initializing all neurons, setup neuron dimension information
    // setup total neuron dimension
    size_t k = __neurons.size();
    size_t i = 0;
    size_t j = 0;
    if(k > 0)
    {
        i = __neurons[0].Dimension().first;
        j = __neurons[0].Dimension().second;

        __neuronDim.k = k;
        __neuronDim.i = i;
        __neuronDim.j = j;
    }

    // setup neuron layer information
    for(size_t kk=0;kk<k;kk++)
    {
        for(size_t ii=0;ii<i;ii++)
            for(size_t jj=0;jj<j;jj++)
            {
                __neurons[kk][ii][jj]->SetLayer(dynamic_cast<Layer*>(this));
                //__neurons[kk][ii][jj]->SetPreviousLayer(__prevLayer); // obsolete
                //__neurons[kk][ii][jj]->SetNextLayer(__nextLayer);     // obsolete
            }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0xc(%rdi), %eax
cmpq $0x4, %rax
ja 0x6166
movq %rdi, %rbx
leaq 0x1b01f(%rip), %rcx     # 0x21094
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x6686
jmp 0x60a4
movq %rbx, %rdi
callq 0x64c4
jmp 0x60a4
movq %rbx, %rdi
callq 0x6188
jmp 0x60a4
movq %rbx, %rdi
callq 0x631c
movq 0x40(%rbx), %rdi
movq 0x48(%rbx), %rcx
movq %rcx, %rax
subq %rdi, %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
movq %rax, %r14
cmpq %rdi, %rcx
je 0x60f1
callq 0x111fe
movq %rax, %r15
movq 0x40(%rbx), %rdi
callq 0x111fe
movq %rdx, %r12
movq %r14, 0x3a8(%rbx)
movq %r15, (%rsp)
movq %r15, 0x398(%rbx)
movq %rdx, 0x3a0(%rbx)
jmp 0x60fc
xorl %r12d, %r12d
movq $0x0, (%rsp)
xorl %eax, %eax
movq %r14, 0x8(%rsp)
cmpq %r14, %rax
je 0x6157
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %rbp
xorl %r14d, %r14d
cmpq (%rsp), %r14
je 0x6148
imulq $0x18, %r14, %r13
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x6143
movq 0x40(%rbx), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r13), %rax
movq (%rax,%r15,8), %rdi
movq %rbx, %rsi
callq 0x1c30c
incq %r15
jmp 0x6121
incq %r14
jmp 0x6114
movq 0x10(%rsp), %rax
incq %rax
movq 0x8(%rsp), %r14
jmp 0x6103
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ce6b(%rip), %rdi     # 0x32fd8
leaq 0x1b521(%rip), %rsi     # 0x21695
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::InitNeuronsFC()
void ConstructLayer::InitNeuronsFC()
{
    __neurons.clear();
    assert(__n_neurons_fc >= 1);
    Pixel2D<Neuron*> image(__n_neurons_fc, 1);
    for(size_t i=0;i<__n_neurons_fc;i++)
    {
        Neuron *n = new Neuron();
        n->SetCoord(i, 0, 0);
        n->SetActuationFuncType(__neuron_actuation_func_type);
        image[i][0] = n;
    }
    __neurons.push_back(image);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
leaq 0x40(%rdi), %rbx
movq %rbx, %rdi
callq 0x11226
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0x6732
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1122e
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq 0x10(%r14), %r15
jae 0x670d
movl $0xa0, %edi
callq 0x4250
movq %rax, %r12
movq %rax, %rdi
callq 0x1bbb8
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1d56c
movl 0x58(%r14), %esi
movq %r12, %rdi
callq 0x1c312
movq 0x8(%rsp), %rax
movq (%rax,%r13), %rax
movq %r12, (%rax)
incq %r15
addq $0x18, %r13
jmp 0x66c2
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x112b2
leaq 0x8(%rsp), %rdi
callq 0x11d84
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x1b051(%rip), %rdi     # 0x2178a
leaq 0x1af9a(%rip), %rsi     # 0x216da
leaq 0x1b057(%rip), %rcx     # 0x2179e
movl $0x1b6, %edx            # imm = 0x1B6
callq 0x4180
jmp 0x6760
movq %rax, %rbx
movq %r12, %rdi
callq 0x4220
jmp 0x6763
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x11d84
movq %rbx, %rdi
callq 0x43b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::ForwardPropagate_Z_ForSample(int)
void ConstructLayer::ForwardPropagate_Z_ForSample(int sample_index)
{
    // forward propagation: 
    //     ---) compute Z, A, A'(Z) for this layer
    //          these works are done neuron by neuron (neuron level)

    // layers needs to finish all z's first 
    // this special treatment is for softmax actuation functions in output layer
    // b/c in softmax, one need all Z's already calculated before updating A and sigma^\prime
    // step 1) finish z
    for(size_t k=0;k<__neurons.size();k++)
    {
        auto dim = __neurons[k].Dimension();
        for(size_t i=0;i<dim.first;i++)
        {
            for(size_t j=0;j<dim.second;j++)
            {
                //cout<<"coord (i, j, k): ("<<i<<", "<<j<<", "<<k<<")"<<endl;
                if(!__neurons[k][i][j]->IsActive()) continue;
                __neurons[k][i][j] -> UpdateZ(sample_index);
            }
        }
    }
    UpdateImagesZ(sample_index);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
xorl %ecx, %ecx
movq 0x40(%r14), %rdi
movq 0x48(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %rcx
jae 0x6f9c
movq %rcx, (%rsp)
imulq $0x18, %rcx, %rbp
addq %rbp, %rdi
callq 0x111fe
movq %rax, 0x8(%rsp)
movq %rdx, %r12
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
je 0x6f90
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %r15
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x6f86
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x1c256
testb %al, %al
je 0x6f81
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
movl %ebx, %esi
callq 0x1bc64
incq %r13
jmp 0x6f4c
movq 0x10(%rsp), %rax
incq %rax
jmp 0x6f39
movq (%rsp), %rcx
incq %rcx
jmp 0x6f07
movq %r14, %rdi
movl %ebx, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6fb4
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::ForwardPropagate_SigmaPrimeAndA_ForSample(int)
void ConstructLayer::ForwardPropagate_SigmaPrimeAndA_ForSample(int sample_index)
{
    // forward propagation: 
    //     ---) compute Z, A, A'(Z) for this layer
    //          these works are done neuron by neuron (neuron level)

    // layers needs to finish all z's first 
    // this special treatment is for softmax actuation functions in output layer
    // b/c in softmax, one need all Z's already calculated before updating A and sigma^\prime
    // step 1) finish z -- done in ForwardPropagate_Z_ForSample(sample_index)

    // step 2) then  finish a and sigma^\prime
    for(size_t k=0;k<__neurons.size();k++)
    {
        auto dim = __neurons[k].Dimension();
        for(size_t i=0;i<dim.first;i++)
        {
            for(size_t j=0;j<dim.second;j++)
            {
                //cout<<"coord (i, j, k): ("<<i<<", "<<j<<", "<<k<<")"<<endl;
                if(!__neurons[k][i][j]->IsActive()) continue;
                __neurons[k][i][j] -> UpdateA(sample_index);
                __neurons[k][i][j] -> UpdateSigmaPrime(sample_index); // sigma^\prime is not needed in layer, but needed in neuron
            }
        }
    }
    UpdateImagesA(sample_index);

    // after finished A and Z matrix, get Sigma^\prime matrix
    UpdateImagesSigmaPrime(sample_index);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
xorl %ecx, %ecx
movq 0x40(%r14), %rdi
movq 0x48(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %rcx
jae 0x742d
movq %rcx, (%rsp)
imulq $0x18, %rcx, %rbp
addq %rbp, %rdi
callq 0x111fe
movq %rax, 0x8(%rsp)
movq %rdx, %r12
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
je 0x7421
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %r15
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x7417
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x1c256
testb %al, %al
je 0x7412
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
movl %ebx, %esi
callq 0x1bd0a
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
movl %ebx, %esi
callq 0x1be06
incq %r13
jmp 0x73c6
movq 0x10(%rsp), %rax
incq %rax
jmp 0x73b3
movq (%rsp), %rcx
incq %rcx
jmp 0x737d
movq %r14, %rdi
movl %ebx, %esi
callq 0x7450
movq %r14, %rdi
movl %ebx, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7806
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::BackwardPropagateForSample(int)
void ConstructLayer::BackwardPropagateForSample(int sample_index)
{
    // backward propagation:
    //     ---) compute delta for this layer
    //     ---) only after all samples in this batch finished forward propagation, one can do this backward propagation

    if(__type == LayerType::output)
    {
        ComputeCostInOutputLayerForCurrentSample(sample_index);
    } 
    else 
    {
        for(size_t k=0;k<__neurons.size();k++)
        {
            auto dim = __neurons[k].Dimension();
            for(size_t i=0;i<dim.first;i++)  {
                for(size_t j=0;j<dim.second;j++) {
                    if(__neurons[k][i][j]->IsActive())
                    {
                        __neurons[k][i][j] -> BackwardPropagateForSample(sample_index);
                        /*
                           if(__type == LayerType::fullyConnected)
                           {
                           cout<<__func__<<" fc layer neuron coord: "<<__neurons[k][i][j]->GetCoord()<<endl;
                           }
                           else if(__type == LayerType::cnn)
                           {
                           cout<<__func__<<" cnn layer neuron coord: "<<__neurons[k][i][j]->GetCoord()<<endl;
                           }
                           */
                    }
                }
            }
        }
        // when propagation for this layer is done, update the Delta matrices
        UpdateImagesDelta(sample_index);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
cmpl $0x4, 0xc(%rdi)
jne 0x7bf1
movq (%r14), %rax
movq 0x58(%rax), %rax
movq %r14, %rdi
movl %ebx, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
xorl %ecx, %ecx
movq 0x40(%r14), %rdi
movq 0x48(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %rcx
jae 0x7c88
movq %rcx, (%rsp)
imulq $0x18, %rcx, %rbp
addq %rbp, %rdi
callq 0x111fe
movq %rax, 0x8(%rsp)
movq %rdx, %r12
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
je 0x7c7c
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %r15
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x7c72
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x1c256
testb %al, %al
je 0x7c6d
movq 0x40(%r14), %rax
movq (%rax,%rbp), %rax
movq (%rax,%r15), %rax
movq (%rax,%r13,8), %rdi
movl %ebx, %esi
callq 0x1c030
incq %r13
jmp 0x7c38
movq 0x10(%rsp), %rax
incq %rax
jmp 0x7c25
movq (%rsp), %rcx
incq %rcx
jmp 0x7bf3
movq %r14, %rdi
movl %ebx, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7ca0
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::BackwardPropagateForBatch()
void ConstructLayer::BackwardPropagateForBatch()
{
    int sample_size = __p_data_interface->GetBatchSize();

#ifdef MULTI_THREAD
    auto process_range = [&](int start, int end)
    {
        for(int i = start;i<end;i++)
        {
            BackwardPropagateForSample(i);
        }
    };

    std::vector<std::thread> vth;
    int Range[NTHREAD+1];
    for(int i=0;i<NTHREAD;i++)
        Range[i] = sample_size/NTHREAD*i;
    Range[NTHREAD] = sample_size;

    for(int i=0;i<NTHREAD;i++)
    {
        vth.push_back(std::thread(process_range, Range[i], Range[i+1]));
    }

    for(auto &i: vth)
        i.join();
#else
    for(int i=0;i<sample_size;i++)
    {
        BackwardPropagateForSample(i);
    }
#endif

    // if use batch normalization, then do the transformation 
    // the gradients on \gamma \beta parameters will also be calculated 
    // in function BatchNormalization_RestoreDelta();
    if(__use_batch_normalization)
    {
        BatchNormalization_RestoreDelta();
    }

    // progress
    //std::cout<<"backward propagate for batch finished. Layer: "<<GetID()<<std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq 0x400(%rdi), %rax
movl (%rax), %ecx
pxor %xmm0, %xmm0
andq $0x0, 0x20(%rsp)
movdqa %xmm0, 0x10(%rsp)
pushq $0x8
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
xorl %edx, %edx
xorl %esi, %esi
cmpq $0x8, %rsi
je 0x8463
movl %edx, 0x30(%rsp,%rsi,4)
incq %rsi
addl %eax, %edx
jmp 0x8452
movl %ecx, 0x50(%rsp)
xorl %ebp, %ebp
leaq 0x2a4c0(%rip), %r14     # 0x32930
leaq 0x8(%rsp), %r15
movq %rsp, %r12
leaq 0x10(%rsp), %r13
cmpq $0x8, %rbp
je 0x84e0
andq $0x0, 0x8(%rsp)
pushq $0x18
popq %rdi
callq 0x4250
movq %r14, (%rax)
movq 0x30(%rsp,%rbp,4), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rax, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4200
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x84c8
movq (%rdi), %rax
callq *0x8(%rax)
movq %r13, %rdi
movq %r15, %rsi
callq 0x1470a
movq %r15, %rdi
callq 0x113c8
incq %rbp
jmp 0x847d
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
cmpq %r15, %r14
je 0x84fd
movq %r14, %rdi
callq 0x4390
addq $0x8, %r14
jmp 0x84ea
cmpb $0x0, 0x210(%rbx)
je 0x8512
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1c8(%rax)
leaq 0x10(%rsp), %rdi
callq 0x113de
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x852f
jmp 0x852f
movq %rax, %rbx
jmp 0x8555
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x8555
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x8555
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x113c8
leaq 0x10(%rsp), %rdi
callq 0x113de
movq %rbx, %rdi
callq 0x43b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::BatchNormalization_GetGradientOnParameters()
void ConstructLayer::BatchNormalization_GetGradientOnParameters()
{
    // 
    // gradients of \partial{C}/\partial{\sigma_B^2}, \partial{C}/\partial{\mu_B}, \partial{C}/\partial{\gamma}, \partial{C}/\partial{\beta}
    // Eq. (16), (17), (19), (20) in notes by Xinzhan Bai
    // This one needs to be done before updating batch normalization deltas

    // clear previous batch
    __v_partial_C_over_partial_sigma_square.clear();
    __v_partial_C_over_partial_mu.clear();
    __v_partial_C_over_partial_gamma.clear();
    __v_partial_C_over_partial_beta.clear();

    if(GetLayerDimension() == LayerDimension::_1D)
        BatchNormalization_GetGradientOnParameters_1DLayer();
    else if(GetLayerDimension() == LayerDimension::_2D)
        BatchNormalization_GetGradientOnParameters_2DLayer();
    else
    {
        std::cout<<"Error: "<<__func__<<" unsupported layer dimension."
            <<std::endl;
        exit(0);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x338, %rdi            # imm = 0x338
callq 0x11394
leaq 0x350(%rbx), %rdi
callq 0x11394
leaq 0x368(%rbx), %rdi
callq 0x11394
leaq 0x380(%rbx), %rdi
callq 0x11394
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x258(%rax)
testl %eax, %eax
je 0x8736
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x258(%rax)
cmpl $0x1, %eax
jne 0x873f
movq %rbx, %rdi
popq %rbx
jmp 0x8e08
movq %rbx, %rdi
popq %rbx
jmp 0x8780
movq 0x2a892(%rip), %rdi     # 0x32fd8
leaq 0x192f8(%rip), %rsi     # 0x21a45
callq 0x4240
leaq 0x192f4(%rip), %rsi     # 0x21a4d
movq %rax, %rdi
callq 0x4240
leaq 0x196da(%rip), %rsi     # 0x21e42
movq %rax, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: inverse_half_cubic(double)
static double inverse_half_cubic(double x)
{
    // a helper: get x^{-3/2}
    assert(x > 0);
    double square_root = sqrt(x);
    return  1./(square_root * square_root * square_root);
}

// Assembly:
pushq %rax
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x96eb
jb 0x96cc
sqrtsd %xmm0, %xmm0
jmp 0x96d1
callq 0x43f8
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x17e2b(%rip), %xmm0    # 0x21510
divsd %xmm1, %xmm0
popq %rax
retq
leaq 0x19dca(%rip), %rdi     # 0x234bc
leaq 0x17fe1(%rip), %rsi     # 0x216da
leaq 0x19dc2(%rip), %rcx     # 0x234c2
movl $0x428, %edx            # imm = 0x428
callq 0x4180
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: inverse_square_root(double)
static double inverse_square_root(double x)
{
    // a helper: get x^{-1/2}
    assert(x > 0);
    double square_root = sqrt(x);
    return 1./square_root;
}

// Assembly:
pushq %rax
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x9734
jb 0x971d
sqrtsd %xmm0, %xmm0
jmp 0x9722
callq 0x43f8
movsd 0x17de6(%rip), %xmm1    # 0x21510
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
popq %rax
retq
leaq 0x19d81(%rip), %rdi     # 0x234bc
leaq 0x17f98(%rip), %rsi     # 0x216da
leaq 0x19d9b(%rip), %rcx     # 0x234e4
movl $0x430, %edx            # imm = 0x430
callq 0x4180
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::BatchNormalization_RestoreDelta_ForSample(int)
void ConstructLayer::BatchNormalization_RestoreDelta_ForSample(int sample_id)
{
    if(__layerDimension == LayerDimension::_1D)
    {
        BatchNormalization_RestoreDelta_ForSample_1DLayer(sample_id);
    }
    else if(__layerDimension == LayerDimension::_2D)
    {
        BatchNormalization_RestoreDelta_ForSample_2DLayer(sample_id);
    }
    else
    {
        std::cout<<"Error: "<<__func__<<" undefined layer dimension."
            <<std::endl;
        exit(0);
    }
}

// Assembly:
movl 0x408(%rdi), %eax
cmpl $0x1, %eax
je 0x9a22
testl %eax, %eax
jne 0x976c
jmp 0x97ae
pushq %rax
movq 0x29864(%rip), %rdi     # 0x32fd8
leaq 0x182ca(%rip), %rsi     # 0x21a45
callq 0x4240
leaq 0x182f1(%rip), %rsi     # 0x21a78
movq %rax, %rdi
callq 0x4240
leaq 0x1830c(%rip), %rsi     # 0x21aa2
movq %rax, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::FillBatchDataToInputLayerA()
void ConstructLayer::FillBatchDataToInputLayerA()
{
    // if this layer is input layer, then fill the 'a' matrix directly with input image data
    std::vector<Matrix> & input_data = __p_data_interface->GetCurrentBatchData();
    //cout<<">>>: "<<input_data.size()<<" samples in current batch from data interface"<<endl;

    // input data whitening
    if(__input_data_batch_whitening)
        Matrix::BatchNormalization(input_data);

    // first clear the previous batch
    __imageA.clear(); // input layer dropout is not used
    __imageAFull.clear();

    // load all batch data to memory, this should be faster
    for(auto &i: input_data)
    {
        Images image_a; // one image

        // input layer only has one kernel
        image_a.OutputImageFromKernel.push_back(i);

        // push this image to images of this batch
        __imageA.push_back(image_a);
        __imageAFull.push_back(image_a);
    }

    std::cout<<">>>: "<<__imageA.size()<<" samples in current batch."<<std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x400(%rdi), %r13
cmpb $0x1, 0x488(%rdi)
jne 0xa330
leaq 0x10(%r13), %rdi
callq 0x1a466
leaq 0x138(%rbx), %r14
movq %r14, %rdi
callq 0x111f6
leaq 0x198(%rbx), %r15
movq %r15, %rdi
callq 0x111f6
movq 0x10(%r13), %r12
movq 0x18(%r13), %rbp
movq %rsp, %r13
cmpq %rbp, %r12
je 0xa39a
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x1139c
movq %r14, %rdi
movq %r13, %rsi
callq 0x11400
movq %r15, %rdi
movq %r13, %rsi
callq 0x11400
movq %r13, %rdi
callq 0x110e4
addq $0x18, %r12
jmp 0xa359
movq 0x28c37(%rip), %rdi     # 0x32fd8
leaq 0x17878(%rip), %rsi     # 0x21c20
callq 0x4240
movq %rax, %rdi
movq 0x140(%rbx), %rax
subq 0x138(%rbx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x41a0
leaq 0x17851(%rip), %rsi     # 0x21c26
movq %rax, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x110e4
movq %rbx, %rdi
callq 0x43b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::ClearUsedSampleForInputLayer_obsolete()
void ConstructLayer::ClearUsedSampleForInputLayer_obsolete()
{
    // this function not needed anymore
    if(__type != LayerType::input)
    {
        std::cout<<"Error: Clear used sample for input layer only works for input layer..."<<std::endl;
        exit(0);
    }
    if(__imageA.size() <= 0)
    {
        std::cout<<"Error: ClearUsedSampleForInputLayer(): __imageA already empty."<<std::endl;
        exit(0);
    }

    __imageA.pop_back();
}

// Assembly:
pushq %rax
cmpl $0x3, 0xc(%rdi)
jne 0xa42c
movq 0x140(%rdi), %rax
cmpq 0x138(%rdi), %rax
je 0xa43c
addq $0x138, %rdi            # imm = 0x138
popq %rax
jmp 0x1142c
movq 0x28ba5(%rip), %rdi     # 0x32fd8
leaq 0x17807(%rip), %rsi     # 0x21c41
jmp 0xa44a
movq 0x28b95(%rip), %rdi     # 0x32fd8
leaq 0x1783e(%rip), %rsi     # 0x21c88
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: filterMatrix(Matrix&, Filter2D&)
static Matrix filterMatrix(Matrix &A, Filter2D &F)
{
    // this function takes out all active elements from A according to F
    //       and return them in another matrix
    //       the filter info is given in matrix F
    auto dimA = A.Dimension();
    auto dimF = F.Dimension();
    assert(dimA == dimF);

    std::vector<std::vector<double>> R;
    for(size_t i=0;i<dimA.first;i++)
    {
        std::vector<double> _tmp_row;
        for(size_t j=0;j<dimA.second;j++)
        {
            if(F[i][j]==1)
            {
                _tmp_row.push_back(A[i][j]);
            }
            else if(F[i][j] != 0)
            {
                std::cout<<"Error: filter matrix element value must be 0 or 1"<<std::endl;
                exit(0);
            }
        }
        if(_tmp_row.size() > 0)
            R.push_back(_tmp_row);
    }
    Matrix Ret(R);
    return Ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rdi, 0x28(%rsp)
movq %rsi, 0x38(%rsp)
movq %rsi, %rdi
callq 0x17a6a
movq %rax, %rbx
movq %rdx, %r13
movq %r14, %rdi
callq 0x1145e
movq %rdx, %rcx
movq %rbx, 0x30(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x175e8
testb %al, %al
je 0xa5bd
leaq 0x40(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
xorl %eax, %eax
leaq 0x10(%rsp), %rbx
cmpq 0x30(%rsp), %rax
je 0xa56d
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
imulq $0x28, %rax, %rbp
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r12, %r13
je 0xa53f
movq (%r14), %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x11440
testq %rdx, (%rax)
je 0xa523
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x17c46
movq (%rax), %rsi
addq %r15, %rsi
movq %rbx, %rdi
callq 0x11d08
jmp 0xa536
movq (%r14), %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x11440
testq %rdx, (%rax)
jne 0xa59b
incq %r12
addq $0x8, %r15
jmp 0xa4ec
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0xa558
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x11d32
movq %rbx, %rdi
callq 0x127dc
movq 0x8(%rsp), %rax
incq %rax
jmp 0xa4c4
leaq 0x40(%rsp), %rsi
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x17906
leaq 0x40(%rsp), %rdi
callq 0x11d5e
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28a36(%rip), %rdi     # 0x32fd8
leaq 0x18ffc(%rip), %rsi     # 0x235a5
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
leaq 0x18faa(%rip), %rdi     # 0x2356e
leaq 0x1710f(%rip), %rsi     # 0x216da
leaq 0x18fa9(%rip), %rcx     # 0x2357b
movl $0x622, %edx            # imm = 0x622
callq 0x4180
movq %rax, %rbx
jmp 0xa5f6
jmp 0xa5e9
jmp 0xa5e9
jmp 0xa5e9
jmp 0xa5e9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x127dc
leaq 0x40(%rsp), %rdi
callq 0x11d5e
movq %rbx, %rdi
callq 0x43b0