// File: /workspace/github_cpp_makefile_star2_O2/girdhari9[P]mTORRENT/CreateTorrentFile.cpp
// Function: mtorrentFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string mtorrentFile(string SrcFileName, string TorrentFileName, string Tracker1IP, string Tracker1Port){

    struct stat fileStat; 
    int err = stat(SrcFileName.c_str(), &fileStat); 
    if (0 != err){
        string error = "Error occured in file";
        cout<<"Error occured in file";
        return error ;
    } 
    string l = to_string(fileStat.st_size);
    int mtorrentPtr = open(TorrentFileName.c_str(), O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);

    string Tracker1 = Tracker1IP + ":" + Tracker1Port + "\n";
    // string Tracker2 = "127.0.0.1:9001\n";
    write(mtorrentPtr,Tracker1.c_str(),strlen(Tracker1.c_str()));
    // write(mtorrentPtr,Tracker2.c_str(),strlen(Tracker2.c_str()));
    
    write(mtorrentPtr,SrcFileName.c_str(),strlen(SrcFileName.c_str()));
    write(mtorrentPtr,"\n",1);
    write(mtorrentPtr,l.c_str(),strlen(l.c_str()));
    write(mtorrentPtr,"\n",1);

    return CalculateSHA(SrcFileName,mtorrentPtr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x4310
testl %eax, %eax
je 0xa0ab
leaq 0x16c9(%rip), %r14      # 0xb750
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6040
movq 0x5f2a(%rip), %rdi      # 0xffc8
movq %r14, %rsi
callq 0x4330
jmp 0xa1d3
movq 0xd8(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0xa42a
movq (%r13), %rdi
pushq $0x41
popq %rsi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x4270
movl %eax, %ebp
leaq 0x1019(%rip), %rdx      # 0xb0f2
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0xa48a
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq %r15, %rdx
callq 0x62a8
leaq 0x12e7(%rip), %rdx      # 0xb3e6
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x6289
leaq 0x68(%rsp), %rdi
callq 0x4678
leaq 0x48(%rsp), %rdi
callq 0x4678
movq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x41b0
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4180
movq (%r14), %r15
movq %r15, %rdi
callq 0x41b0
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4180
leaq 0x1285(%rip), %rsi      # 0xb3e6
pushq $0x1
popq %rdx
movl %ebp, %edi
callq 0x4180
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x41b0
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4180
leaq 0x125a(%rip), %rsi      # 0xb3e6
pushq $0x1
popq %rdx
movl %ebp, %edi
callq 0x4180
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x4470
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0xa241
leaq 0x28(%rsp), %rdi
callq 0x4678
leaq 0x88(%rsp), %rdi
callq 0x4678
leaq 0x8(%rsp), %rdi
callq 0x4678
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x4678
jmp 0xa222
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x4678
jmp 0xa209
movq %rax, %r14
leaq 0x48(%rsp), %rdi
jmp 0xa22a
jmp 0xa212
movq %rax, %r14
jmp 0xa22f
movq %rax, %r14
movq %rbx, %rdi
jmp 0xa234
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x4678
leaq 0x8(%rsp), %rdi
callq 0x4678
movq %r14, %rdi
callq 0x45b0