LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: ef-gy[P]libefgy/include/ef.gy/fractions.h
// Function: efgy::math::numeric::fractional<long long>::operator==(efgy::math::numeric::fractional<long long> const&) const
bool operator==(const fractional &b) const {
    if ((numerator == b.numerator) && (denominator == b.denominator)) {
      return true;
    }
#if defined(normalise)
    else {
      return false;
    }
#endif

    fractional p = *this;
    fractional q = b;

    p.minimise();
    q.minimise();

    const fractional &pc = p;
    const fractional &qc = q;

    return (pc.numerator == qc.numerator) && (pc.denominator == qc.denominator);
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x34c18
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x34c18
movb $0x1, -0x1(%rbp)
jmp 0x34c1c
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)
// File: Sooryakiran[P]dotV/src/main.cpp
// Function: generate_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int generate_file(string file_name, string contents){
    /*------------------------------------------------------------------------------------------
    Writes/Rewrites the given contents to the given file. 

    Param : file_name (string), file_name of the output file.
    Param : contents (string), contents of the file to be written.

    Return : 1 if successful, 0 if not.
    ------------------------------------------------------------------------------------------*/
    ofstream fout; 
    fout.open(file_name);
    if(fout){
        fout << contents << endl; 
        fout.close();
        cout<<"[INFO] Code "<<file_name<<" written successfully!"<<endl;
    }
    else{
        cout<<"[ERROR] Unable to write file!"<<endl;
        return 0;
    } 
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x230(%rbp)
movq %rsi, -0x240(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x218(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x5310
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rsi
movl $0x10, %edx
callq 0x50e0
jmp 0x552e
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x5280
movb %al, -0x241(%rbp)
jmp 0x554e
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x555d
jmp 0x5627
movq -0x240(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x51b0
movq %rax, -0x250(%rbp)
jmp 0x5579
movq -0x250(%rbp), %rdi
movq 0x5a31(%rip), %rsi      # 0xafb8
callq 0x5200
jmp 0x558e
leaq -0x218(%rbp), %rdi
callq 0x52a0
jmp 0x559c
movq 0x5a2d(%rip), %rdi      # 0xafd0
leaq 0x2a5a(%rip), %rsi      # 0x8004
callq 0x51d0
movq %rax, -0x258(%rbp)
jmp 0x55b8
movq -0x230(%rbp), %rsi
movq -0x258(%rbp), %rdi
callq 0x51b0
movq %rax, -0x260(%rbp)
jmp 0x55d4
movq -0x260(%rbp), %rdi
leaq 0x2a2f(%rip), %rsi      # 0x8011
callq 0x51d0
movq %rax, -0x268(%rbp)
jmp 0x55f0
movq -0x268(%rbp), %rdi
movq 0x59ba(%rip), %rsi      # 0xafb8
callq 0x5200
jmp 0x5605
jmp 0x566b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x52d0
jmp 0x5694
movq 0x59a2(%rip), %rdi      # 0xafd0
leaq 0x29f3(%rip), %rsi      # 0x8028
callq 0x51d0
movq %rax, -0x270(%rbp)
jmp 0x5643
movq -0x270(%rbp), %rdi
movq 0x5967(%rip), %rsi      # 0xafb8
callq 0x5200
jmp 0x5658
movl $0x0, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
jmp 0x567c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x52d0
movl -0x4(%rbp), %eax
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x220(%rbp), %rdi
callq 0x5320
// File: CYLMos[P]Read_the_tar_file/main.cpp
// Function: main
int main(int argc, char *argv[])
{
    /// If the number of the params is wrong
    if(argc >= 3){
        cout << "Too many params" << endl;
        exit(0);
    }
    else if(argc <= 1){
        cout << "Too less params" << endl;
        exit(0);
    }

    MyTar myTar(argv[1]);

    if(!myTar.startRead()){
	cout << "Not USTART file!" << endl;
	exit(0);
    }
    myTar.showContent();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
jl 0x2578
movq 0x5a82(%rip), %rdi      # 0x7fd8
leaq 0x2aa7(%rip), %rsi      # 0x5004
callq 0x21b0
movq %rax, %rdi
movq 0x5a5c(%rip), %rsi      # 0x7fc8
callq 0x21e0
xorl %edi, %edi
callq 0x2250
cmpl $0x1, -0x8(%rbp)
jg 0x25a7
movq 0x5a53(%rip), %rdi      # 0x7fd8
leaq 0x2a88(%rip), %rsi      # 0x5014
callq 0x21b0
movq %rax, %rdi
movq 0x5a2d(%rip), %rsi      # 0x7fc8
callq 0x21e0
xorl %edi, %edi
callq 0x2250
jmp 0x25a9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x238(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x2680
movq -0x250(%rbp), %rdi
callq 0x2940
movl %eax, -0x248(%rbp)
jmp 0x25d8
movl -0x248(%rbp), %eax
cmpl $0x0, %eax
jne 0x263b
movq 0x59ee(%rip), %rdi      # 0x7fd8
leaq 0x2a33(%rip), %rsi      # 0x5024
callq 0x21b0
movq %rax, -0x258(%rbp)
jmp 0x25ff
movq -0x258(%rbp), %rdi
movq 0x59bb(%rip), %rsi      # 0x7fc8
callq 0x21e0
jmp 0x2614
xorl %edi, %edi
callq 0x2250
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2780
jmp 0x2668
leaq -0x238(%rbp), %rdi
callq 0x2b90
jmp 0x2649
movl $0x0, -0x4(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2780
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x2350
nopw %cs:(%rax,%rax)
nop
// File: CYLMos[P]Read_the_tar_file/MyTar.cpp
// Function: MyTar::MyTar(char const*)
MyTar::MyTar(const char *file){
    this->usBlockSize = 512;  /// Every block in USTAR format is 512 bytes.
    this->fileNum = -1;
    this->inputStream.open(file, ifstream::in | ifstream::binary);

    /// If failed, close the program.
    if(!this->inputStream.is_open()){
        cout << "Open failed!" << endl;
        exit(0);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq %rdi, %rax
movq %rax, -0x40(%rbp)
callq 0x2230
movq -0x30(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movq %rdi, -0x38(%rbp)
callq 0x3450
movq -0x30(%rbp), %rax
movl $0x200, 0x220(%rax)     # imm = 0x200
movl $0xffffffff, 0x224(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x3470
movl %eax, -0x20(%rbp)
jmp 0x26f3
movl -0x20(%rbp), %edx
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x2120
jmp 0x2705
movq -0x48(%rbp), %rdi
callq 0x22f0
movb %al, -0x49(%rbp)
jmp 0x2713
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x276e
jmp 0x271c
movq 0x58b5(%rip), %rdi      # 0x7fd8
leaq 0x290b(%rip), %rsi      # 0x5035
callq 0x21b0
movq %rax, -0x58(%rbp)
jmp 0x2735
movq -0x58(%rbp), %rdi
movq 0x5888(%rip), %rsi      # 0x7fc8
callq 0x21e0
jmp 0x2747
xorl %edi, %edi
callq 0x2250
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x3490
movq -0x40(%rbp), %rdi
callq 0x2060
jmp 0x2774
addq $0x60, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x2350
nopl (%rax)
// File: 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
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x70(%rbp)
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x2290
movq -0x70(%rbp), %rdi
callq 0x2330
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3520
movq -0x70(%rbp), %rcx
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cltd
idivl 0x220(%rcx)
cmpl $0x0, %edx
jne 0x2917
movq -0x70(%rbp), %rdi
movl $0x101, %esi            # imm = 0x101
xorl %edx, %edx
callq 0x2290
movq -0x70(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
movl $0x6, %edx
callq 0x2280
movq %rax, %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x2270
testb $0x1, %al
jne 0x2873
jmp 0x2915
leaq -0x51(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x2360
movq -0x78(%rbp), %rdx
leaq -0x50(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
callq 0x3540
jmp 0x2893
leaq -0x51(%rbp), %rdi
callq 0x2200
leaq 0x279f(%rip), %rsi      # 0x5042
leaq -0x50(%rbp), %rdi
callq 0x35f0
movb %al, -0x79(%rbp)
jmp 0x28b1
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x28ba
jmp 0x28f8
movl $0x1, -0x4(%rbp)
movl $0x1, -0x68(%rbp)
jmp 0x28ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x2200
jmp 0x292a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2100
jmp 0x292a
movl $0x0, -0x68(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2100
movl -0x68(%rbp), %eax
testl %eax, %eax
je 0x2913
jmp 0x2911
jmp 0x291e
jmp 0x2915
jmp 0x2917
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x2350
nopw %cs:(%rax,%rax)
// File: 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
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x27e0
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
je 0x2976
movl $0x0, -0x4(%rbp)
jmp 0x2a8b
movq -0x220(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2290
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x2270
testb $0x1, %al
jne 0x29a4
jmp 0x2a64
movq -0x220(%rbp), %rdi
movslq 0x220(%rdi), %rdx
leaq -0x210(%rbp), %rsi
callq 0x2280
movq %rax, %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x2270
testb $0x1, %al
jne 0x29d6
jmp 0x2a5f
movq -0x220(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
leaq -0x210(%rbp), %rsi
callq 0x3620
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rsi
addq $0x7c, %rsi
movl $0xc, %edx
callq 0x2aa0
movl %eax, %ecx
movq -0x220(%rbp), %rax
movl %ecx, -0x214(%rbp)
cvtsi2sdl -0x214(%rbp), %xmm0
cvtsi2sdl 0x220(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x2030
movq -0x220(%rbp), %rdi
cvttsd2si %xmm0, %eax
movl %eax, -0x218(%rbp)
movl -0x218(%rbp), %eax
imull 0x220(%rdi), %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x2290
jmp 0x2988
movq -0x220(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
callq 0x3690
movq %rax, %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmoval %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopw (%rax,%rax)
// File: 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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
jle 0x2b6f
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x61, %eax
jl 0x2b0d
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x66, %eax
jg 0x2b0d
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x61, %eax
addl $0xa, %eax
movl %eax, -0x28(%rbp)
jmp 0x2b1f
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
subl $0x30, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
cvtsi2sdl -0x24(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x18(%rbp), %esi
movl $0x10, %edi
callq 0x3860
movaps %xmm0, %xmm2
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2aca
movl -0x1c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x1c(%rbp)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x228(%rbp)
cmpl $0x0, 0x224(%rax)
jl 0x3088
movq -0x228(%rbp), %rax
movl 0x224(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x3156
movq -0x228(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
callq 0x3690
subq $0x1, %rax
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jle 0x3146
movq -0x228(%rbp), %rdi
movb $0x1, -0x15(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x3700
movq %rax, %rsi
leaq -0x215(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
callq 0x2170
movl $0x0, -0x21c(%rbp)
cmpl $0x8, -0x21c(%rbp)
jge 0x311b
movslq -0x21c(%rbp), %rax
movsbl -0x181(%rbp,%rax), %eax
cmpl $0x0, %eax
je 0x3108
movb $0x0, -0x15(%rbp)
jmp 0x311b
jmp 0x310a
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x30e5
testb $0x1, -0x15(%rbp)
jne 0x3136
movq -0x228(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, 0x224(%rax)
jmp 0x3146
jmp 0x3138
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x30a2
movq -0x228(%rbp), %rax
movl 0x224(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: rthoelen[P]NXCore_Icom/main.cc
// Function: get_repeater_id(sockaddr_in*)
int get_repeater_id(struct sockaddr_in *addr)
{
	int i;

	for(i = 0; i < repeater_count; i++)
	{	
		if((in_addr_t)addr->sin_addr.s_addr == (in_addr_t)repeater[i].rpt_addr_00.sin_addr.s_addr)
		{
			return i;
		}
	}

	return(-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x23ac0(%rip), %eax     # 0x29498
jge 0x5a0d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x23a90(%rip), %rcx     # 0x29478
movslq -0x14(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x5a00
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5a14
jmp 0x5a02
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x59cf
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: rthoelen[P]NXCore_Icom/main.cc
// Function: tg_lookup(int, int)
int tg_lookup(int GID, int i)
{
	int j;

	j = 0;
	while (repeater[i].tg_list[j] != 0)
	{
		if (repeater[i].tg_list[j++] == GID)
			return(j-1);
	}
	return(-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq 0x22280(%rip), %rax     # 0x29478
movslq -0xc(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movslq -0x10(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x724a
movq 0x22260(%rip), %rax     # 0x29478
movslq -0xc(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x10(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x8(%rbp), %eax
jne 0x7248
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x7251
jmp 0x71f1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: rthoelen[P]NXCore_Icom/main.cc
// Function: tac_lookup(int, int)
int tac_lookup(int GID, int i)
{
        int j;

        j = 0;

        while (repeater[i].tac_list[j] != 0)
        {
                if (repeater[i].tac_list[j++] == GID)
                        return(j-1);
        }
        return(-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq 0x22200(%rip), %rax     # 0x29478
movslq -0xc(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movslq -0x10(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x72ca
movq 0x221e0(%rip), %rax     # 0x29478
movslq -0xc(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x10(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x8(%rbp), %eax
jne 0x72c8
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x72d1
jmp 0x7271
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: 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
movq %r8, -0x10(%rbp)
movq %r9, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movl %edx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %edx
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rsi
movq %rax, %rcx
addq %rsi, %rcx
movl %edx, 0x10(%rcx)
movl -0x24(%rbp), %edx
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rsi
movq %rax, %rcx
addq %rsi, %rcx
movl %edx, 0x14(%rcx)
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq -0x10(%rbp), %rdx
movq %rdx, (%rcx)
movq -0x8(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x1a73(%rip), %xmm0     # 0x4008
movsd %xmm0, 0x18(%rax)
popq %rbp
retq
nopl (%rax)
// File: 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
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x10, -0x1c(%rbp)
movl -0x4(%rbp), %edi
leaq -0x18(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x20c0
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
jge 0x2c0f
movq 0x33e4(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
leaq 0x14e0(%rip), %rsi      # 0x40de
movb $0x0, %al
callq 0x22d0
movl $0x1, %edi
callq 0x2260
callq 0x2c70
callq 0x20a0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x2c3c
movq 0x33af(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
leaq 0x14bb(%rip), %rsi      # 0x40ee
movb $0x0, %al
callq 0x22d0
jmp 0x2c69
cmpl $0x0, -0x24(%rbp)
jne 0x2c5f
movl -0x4(%rbp), %edi
callq 0x23c0
movl -0x20(%rbp), %edi
movl -0x8(%rbp), %esi
callq 0x2e10
movl $0x1, %edi
callq 0x2260
movl -0x20(%rbp), %edi
callq 0x23c0
jmp 0x2c69
jmp 0x2bd5
nop
// File: 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
subq $0x260, %rsp            # imm = 0x260
leaq -0x208(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x2250
movq -0x248(%rbp), %rdi
leaq 0x1467(%rip), %rsi      # 0x4103
movl $0x8, %edx
callq 0x2130
jmp 0x2ca8
leaq -0x208(%rbp), %rdi
callq 0x2340
movb %al, -0x249(%rbp)
jmp 0x2cbc
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0x2cc8
jmp 0x2cca
jmp 0x2d00
leaq 0x143b(%rip), %rdi      # 0x410c
leaq 0x1445(%rip), %rsi      # 0x411d
movl $0x5c, %edx
leaq 0x1447(%rip), %rcx      # 0x412b
callq 0x2140
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x2de9
leaq -0x238(%rbp), %rdi
callq 0x22b0
movl $0x0, -0x23c(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x2070
movq %rax, -0x258(%rbp)
jmp 0x2d32
movq -0x258(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2290
movb %al, -0x259(%rbp)
jmp 0x2d50
movb -0x259(%rbp), %al
testb $0x1, %al
jne 0x2d5c
jmp 0x2dc8
leaq -0x238(%rbp), %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x2320
movl %eax, -0x240(%rbp)
movl -0x240(%rbp), %ecx
movslq -0x23c(%rbp), %rdx
leaq 0x348e(%rip), %rax      # 0x6218
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x2d16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2120
jmp 0x2de9
leaq -0x238(%rbp), %rdi
callq 0x2120
leaq -0x208(%rbp), %rdi
callq 0x2090
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0x208(%rbp), %rdi
callq 0x2090
movq -0x210(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x3, 0xc(%rax)
jne 0x7337
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
jmp 0x737e
movq 0x8(%rsp), %rax
cmpl $0x4, 0xc(%rax)
jne 0x7360
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0xc0(%rax)
jmp 0x737c
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0xc0(%rax)
jmp 0x737e
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
movq 0x8(%rsp), %rax
testb $0x1, 0x3c8(%rax)
je 0x73a8
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x208(%rax)
movq 0x8(%rsp), %rax
testb $0x1, 0x210(%rax)
je 0x73c0
movq 0x8(%rsp), %rdi
callq 0x73d0
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
cmpl $0x0, 0xc(%rax)
je 0x7b97
movq (%rsp), %rax
cmpl $0x4, 0xc(%rax)
jne 0x7ba6
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x7bcf
movq 0x6342b(%rip), %rdi     # 0x6afd8
leaq 0x4a50a(%rip), %rsi     # 0x520be
callq 0x4230
movq %rax, %rdi
movq 0x633ed(%rip), %rsi     # 0x6afb0
callq 0x4260
xorl %edi, %edi
callq 0x4290
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
cmpl $0x1, 0xc(%rax)
je 0x7c30
movq (%rsp), %rax
cmpl $0x2, 0xc(%rax)
je 0x7c30
movq 0x633ca(%rip), %rdi     # 0x6afd8
leaq 0x4a4ea(%rip), %rsi     # 0x520ff
callq 0x4230
movq %rax, %rdi
movq 0x6338c(%rip), %rsi     # 0x6afb0
callq 0x4260
xorl %edi, %edi
callq 0x4290
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x18(%rax)
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x28, %rsp
movq %rsi, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x1, 0xc(%rax)
je 0x7cb6
movq 0x8(%rsp), %rax
cmpl $0x2, 0xc(%rax)
je 0x7cb6
movq 0x63353(%rip), %rdi     # 0x6afd8
leaq 0x4a4b4(%rip), %rsi     # 0x52140
callq 0x4230
movq %rax, %rdi
leaq 0x4a4b6(%rip), %rsi     # 0x52151
callq 0x4230
movq %rax, %rdi
movq 0x63306(%rip), %rsi     # 0x6afb0
callq 0x4260
xorl %edi, %edi
callq 0x4290
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x28(%rax)
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq %rdi, 0x20(%rsp)
addq $0x40, %rdi
callq 0x1f670
movq 0x20(%rsp), %rax
cmpq $0x1, 0x10(%rax)
jb 0x8a1a
jmp 0x8a39
leaq 0x498a0(%rip), %rdi     # 0x522c1
leaq 0x497aa(%rip), %rsi     # 0x521d2
movl $0x1b6, %edx            # imm = 0x1B6
leaq 0x498a1(%rip), %rcx     # 0x522d5
callq 0x4170
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x48(%rsp), %rdi
movl $0x1, %edx
callq 0x1f690
movq $0x0, 0x40(%rsp)
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq 0x10(%rcx), %rax
jae 0x8b34
movl $0xa0, %edi
callq 0x4240
movq %rax, 0x18(%rsp)
jmp 0x8a7f
movq 0x18(%rsp), %rdi
callq 0x474c0
jmp 0x8a8b
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4a1b0
jmp 0x8aad
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rdi
movl 0x58(%rax), %esi
callq 0x48100
jmp 0x8ac1
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x1f5c0
movq %rax, 0x10(%rsp)
jmp 0x8ae1
movq 0x10(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f5f0
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x8a5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
jmp 0x8b58
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
callq 0x4220
jmp 0x8b58
movq 0x20(%rsp), %rdi
addq $0x40, %rdi
leaq 0x48(%rsp), %rsi
callq 0x1f780
jmp 0x8b49
leaq 0x48(%rsp), %rdi
callq 0x1f7f0
addq $0x68, %rsp
retq
leaq 0x48(%rsp), %rdi
callq 0x1f7f0
movq 0x30(%rsp), %rdi
callq 0x43f0
nopl (%rax)
// File: 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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
addq $0x40, %rdi
callq 0x1f630
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0x9b4f
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
callq 0x1f530
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0x9b3a
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x28(%rsp), %rax
jae 0x9b25
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
callq 0x47fe0
testb $0x1, %al
jne 0x9ad9
jmp 0x9b12
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
movl 0x3c(%rsp), %esi
callq 0x47680
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0x9a8e
jmp 0x9b27
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x9a75
jmp 0x9b3c
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x9a20
movq 0x8(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0x9b70
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
// File: 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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
addq $0x40, %rdi
callq 0x1f630
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0xa548
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
callq 0x1f530
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0xa533
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x28(%rsp), %rax
jae 0xa51e
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
callq 0x47fe0
testb $0x1, %al
jne 0xa499
jmp 0xa50b
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
movl 0x3c(%rsp), %esi
callq 0x47750
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
movl 0x3c(%rsp), %esi
callq 0x47940
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0xa44e
jmp 0xa520
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0xa435
jmp 0xa535
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0xa3e0
movq 0x8(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xa570
movq 0x8(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xadc0
addq $0x48, %rsp
retq
nopl (%rax)
// File: 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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x4, 0xc(%rax)
jne 0xb641
movq 0x8(%rsp), %rdi
movl 0x3c(%rsp), %esi
movq (%rdi), %rax
callq *0x58(%rax)
jmp 0xb789
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
addq $0x40, %rdi
callq 0x1f630
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0xb77b
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
callq 0x1f530
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0xb766
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x28(%rsp), %rax
jae 0xb751
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
callq 0x47fe0
testb $0x1, %al
jne 0xb703
jmp 0xb73c
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
movq 0x30(%rsp), %rsi
callq 0x1f650
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x1f5f0
movq (%rax), %rdi
movl 0x3c(%rsp), %esi
callq 0x47c50
jmp 0xb73e
movq 0x10(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0xb6b8
jmp 0xb753
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0xb69f
jmp 0xb768
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0xb64a
movq 0x8(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xb790
addq $0x48, %rsp
retq
nop
// File: xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::TestBatchNormalization_UpdateZ()
void ConstructLayer::TestBatchNormalization_UpdateZ()
{
    // print each matrix, see if batch normalization Z works as expected

    // print Z matrix before normalization
    std::cout<<"Z image before batch normalization: "<<std::endl;
    int id = 0;
    for(auto &i: __imageZ)
    {
        std::cout<<"sample id: "<<id++<<std::endl;
        std::cout<<i<<std::endl;
    }

    /*
       cout<<"average mu_N: "<<endl;
       for(auto &i: __imageAverage_BN)
       cout<<i<<endl;

       cout<<"sigma squared: "<<endl;
       for(auto &i: __imageVariance_BN)
       cout<<i<<endl;

       cout<<"image z after normlization: "<<endl;
       for(auto &i: __imageZ_BN)
       cout<<i<<endl;
       */
    std::cout<<"image y after normalization: "<<std::endl;
    for(auto &i: __imageY_BN)
        std::cout<<i<<std::endl;

    std::cout<<"enter to continue..."<<std::endl;
    getchar();
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, (%rsp)
movq 0x5e8ef(%rip), %rdi     # 0x6afd8
leaq 0x45e34(%rip), %rsi     # 0x52524
callq 0x4230
movq %rax, %rdi
movq 0x5e8b1(%rip), %rsi     # 0x6afb0
callq 0x4260
movq (%rsp), %rax
movl $0x0, 0x4c(%rsp)
addq $0x150, %rax            # imm = 0x150
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x1fc70
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x1fca0
movq %rax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1fcd0
testb $0x1, %al
jne 0xc74e
jmp 0xc7c3
leaq 0x38(%rsp), %rdi
callq 0x1fd10
movq %rax, 0x28(%rsp)
movq 0x5e874(%rip), %rdi     # 0x6afd8
leaq 0x4a193(%rip), %rsi     # 0x568fe
callq 0x4230
movq %rax, %rdi
movl 0x4c(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
callq 0x43e0
movq %rax, %rdi
movq 0x5e821(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x28(%rsp), %rsi
movq 0x5e838(%rip), %rdi     # 0x6afd8
callq 0x3ae90
movq %rax, %rdi
movq 0x5e801(%rip), %rsi     # 0x6afb0
callq 0x4260
leaq 0x38(%rsp), %rdi
callq 0x1fd20
jmp 0xc739
movq 0x5e80e(%rip), %rdi     # 0x6afd8
leaq 0x45d78(%rip), %rsi     # 0x52549
callq 0x4230
movq %rax, %rdi
movq 0x5e7d0(%rip), %rsi     # 0x6afb0
callq 0x4260
movq (%rsp), %rax
addq $0x248, %rax            # imm = 0x248
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
callq 0x1fc70
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rdi
callq 0x1fca0
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1fcd0
testb $0x1, %al
jne 0xc827
jmp 0xc862
leaq 0x18(%rsp), %rdi
callq 0x1fd10
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rsi
movq 0x5e796(%rip), %rdi     # 0x6afd8
callq 0x3ae90
movq %rax, %rdi
movq 0x5e75f(%rip), %rsi     # 0x6afb0
callq 0x4260
leaq 0x18(%rsp), %rdi
callq 0x1fd20
jmp 0xc812
movq 0x5e76f(%rip), %rdi     # 0x6afd8
leaq 0x45cf7(%rip), %rsi     # 0x52567
callq 0x4230
movq %rax, %rdi
movq 0x5e731(%rip), %rsi     # 0x6afb0
callq 0x4260
callq 0x4310
addq $0x58, %rsp
retq
nop
// File: 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:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x400(%rax), %rdi
callq 0x1f310
movl %eax, %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x9c(%rsp)
movq %rax, 0x90(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x1fac0
movl $0x0, 0x4c(%rsp)
cmpl $0x8, 0x4c(%rsp)
jge 0xc913
movl 0x9c(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
imull 0x4c(%rsp), %ecx
movslq 0x4c(%rsp), %rax
movl %ecx, 0x50(%rsp,%rax,4)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0xc8e0
movl 0x9c(%rsp), %eax
movl %eax, 0x70(%rsp)
movl $0x0, 0x48(%rsp)
cmpl $0x8, 0x48(%rsp)
jge 0xc9a8
movslq 0x48(%rsp), %rax
leaq 0x50(%rsp,%rax,4), %rdx
leaq 0x54(%rsp,%rax,4), %rcx
leaq 0x40(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xca60
jmp 0xc950
leaq 0x78(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x1fad0
jmp 0xc961
leaq 0x40(%rsp), %rdi
callq 0x1fb00
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xc926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
jmp 0xca43
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x1fb00
jmp 0xca43
leaq 0x78(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x1fb20
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rdi
callq 0x1fb50
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x1fb80
testb $0x1, %al
jne 0xc9e5
jmp 0xca0e
leaq 0x20(%rsp), %rdi
callq 0x1fbc0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x43c0
jmp 0xca00
jmp 0xca02
leaq 0x20(%rsp), %rdi
callq 0x1fbd0
jmp 0xc9d0
movq 0x8(%rsp), %rax
testb $0x1, 0x210(%rax)
je 0xca31
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq 0x1c8(%rax), %rax
callq *%rax
jmp 0xca2f
jmp 0xca31
leaq 0x78(%rsp), %rdi
callq 0x1fc10
addq $0xa8, %rsp
retq
leaq 0x78(%rsp), %rdi
callq 0x1fc10
movq 0x38(%rsp), %rdi
callq 0x43f0
nopw (%rax,%rax)
// File: 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:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq %rdi, 0x8(%rsp)
addq $0x338, %rdi            # imm = 0x338
callq 0x1fa00
movq 0x8(%rsp), %rdi
addq $0x350, %rdi            # imm = 0x350
callq 0x1fa00
movq 0x8(%rsp), %rdi
addq $0x368, %rdi            # imm = 0x368
callq 0x1fa00
movq 0x8(%rsp), %rdi
addq $0x380, %rdi            # imm = 0x380
callq 0x1fa00
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x258(%rax)
cmpl $0x0, %eax
jne 0xcda1
movq 0x8(%rsp), %rdi
callq 0xcee0
jmp 0xce09
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x258(%rax)
cmpl $0x1, %eax
jne 0xcdc0
movq 0x8(%rsp), %rdi
callq 0xdd70
jmp 0xce07
movq 0x5e211(%rip), %rdi     # 0x6afd8
leaq 0x457ae(%rip), %rsi     # 0x5257c
callq 0x4230
movq %rax, %rdi
leaq 0x457a7(%rip), %rsi     # 0x52584
callq 0x4230
movq %rax, %rdi
leaq 0x45b8d(%rip), %rsi     # 0x52979
callq 0x4230
movq %rax, %rdi
movq 0x5e1b5(%rip), %rsi     # 0x6afb0
callq 0x4260
xorl %edi, %edi
callq 0x4290
jmp 0xce09
addq $0x18, %rsp
retq
nop
// File: 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:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
cmpl $0x0, 0x408(%rax)
jne 0xf01e
movq (%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0xf090
jmp 0xf083
movq (%rsp), %rax
cmpl $0x1, 0x408(%rax)
jne 0xf03a
movq (%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0xf590
jmp 0xf081
movq 0x5bf97(%rip), %rdi     # 0x6afd8
leaq 0x43534(%rip), %rsi     # 0x5257c
callq 0x4230
movq %rax, %rdi
leaq 0x43558(%rip), %rsi     # 0x525af
callq 0x4230
movq %rax, %rdi
leaq 0x43573(%rip), %rsi     # 0x525d9
callq 0x4230
movq %rax, %rdi
movq 0x5bf3b(%rip), %rsi     # 0x6afb0
callq 0x4260
xorl %edi, %edi
callq 0x4290
jmp 0xf083
addq $0x18, %rsp
retq
nopl (%rax,%rax)