// File: /workspace/github_cpp_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x4300
testl %eax, %eax
je 0xbd99
leaq 0x10(%r14), %r15
movq %r15, (%r14)
leaq 0x19e2(%rip), %rbx      # 0xd750
leaq 0x19f0(%rip), %rdx      # 0xd765
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7562
movq 0x6249(%rip), %rdi      # 0x11fd0
movl $0x15, %edx
movq %rbx, %rsi
callq 0x43c0
jmp 0xc075
movq %r15, 0x68(%rsp)
movq %rbx, 0x60(%rsp)
movq %r14, 0x70(%rsp)
movq 0xe8(%rsp), %rbp
movq %rbp, %r14
negq %r14
cmovsq %rbp, %r14
movl $0x1, %ebx
cmpq $0xa, %r14
jb 0xbe14
movl $0x4, %ebx
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
movq %r14, %rcx
cmpq $0x63, %rcx
jbe 0xbe0d
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0xbe12
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0xbe14
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %ebx
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0xbdd7
addl $-0x3, %ebx
jmp 0xbe14
addl $-0x2, %ebx
jmp 0xbe14
decl %ebx
shrq $0x3f, %rbp
leal (%rbx,%rbp), %esi
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movl $0x2d, %edx
callq 0x43d0
addq (%r15), %rbp
movq %rbp, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0xc3a9
movq (%r13), %rdi
movl $0x41, %esi
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x4260
movl %eax, %ebp
leaq 0x10(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x74cc
movq 0x70(%rsp), %r14
leaq 0x126c(%rip), %rsi      # 0xd0f2
movq %rsp, %rdi
callq 0x4640
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rsp, %rdi
callq 0x4140
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xbed0
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0xbed8
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x78(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x14eb(%rip), %rsi      # 0xd3e6
callq 0x4640
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xbf27
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xbf2e
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0xbf60
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x4350
movq (%rsp), %rdi
cmpq %rbx, %rdi
movq 0x60(%rsp), %r12
je 0xbf7b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4350
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x41a0
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4170
movq (%r12), %rbx
movq %rbx, %rdi
callq 0x41a0
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4170
leaq 0x1431(%rip), %rsi      # 0xd3e6
movl $0x1, %edx
movl %ebp, %edi
callq 0x4170
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x41a0
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4170
leaq 0x1404(%rip), %rsi      # 0xd3e6
movl $0x1, %edx
movl %ebp, %edi
callq 0x4170
leaq 0xa8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x74cc
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0xc138
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc042
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x4350
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0xc059
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4350
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xc075
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4350
movq %r14, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc0fd
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x4350
jmp 0xc0fd
movq %rax, %r14
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0xc0d0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x4350
jmp 0xc0d0
jmp 0xc0cd
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0xc114
movq 0x10(%rsp), %rsi
jmp 0xc10c
jmp 0xc0e2
movq %rax, %r14
jmp 0xc114
movq %r14, %rcx
movq %rax, %r14
movq (%rcx), %rdi
cmpq %r15, %rdi
je 0xc130
movq (%r15), %rsi
jmp 0xc128
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0xc114
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4350
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xc130
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4350
movq %r14, %rdi
callq 0x45d0