// File: /workspace/github_cpp_makefile_star2_O2/MisakiFx[P]P2PDownload/./client.hpp
// Function: P2PClient::RangeDownload(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, long, long, int*)
void RangeDownload(std::string host, std::string name, int64_t start, int64_t end, int* res)
    {
      *res = 0;
      std::string uri = "/list/" + name;
      std::string realpath = "Download/" + name;
      std::stringstream range_val;
      range_val << "bytes=" << start << "-" << end;
      Client client(host.c_str(), _srv_port);
      Headers header;
      header.insert(std::make_pair("Range", range_val.str().c_str()));
      auto rsp = client.Get(uri.c_str(), header);
      //收到的回复正常
      if(rsp && rsp->status == 206)
      {
        int fd = open(realpath.c_str(), O_CREAT | O_WRONLY, 0664);
        //文件未成功打开
        if(fd < 0)
        {
          std::cerr << "file " << realpath << " open error" << std::endl;
          return;
        }
        lseek(fd, start, SEEK_SET);
        int ret = write(fd, &rsp->body[0], rsp->body.size());
        //文件传输失败
        if(ret < 0)
        {
          std::cerr << "file " << realpath << " write error" << std::endl;
          close(fd);
          return;
        }
        close(fd);
        *res = 1;
        std::cerr << "file " << realpath << " download range: " << range_val.str() << " success" << std::endl;
        return;
      }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %r8, %r13
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
movq %r9, -0x40(%rbp)
andl $0x0, (%r9)
leaq 0xc182(%rip), %rsi      # 0x24dd0
leaq -0xa0(%rbp), %rdi
callq 0x19181
leaq 0xc176(%rip), %rsi      # 0x24dd7
leaq -0x80(%rbp), %rdi
movq %rbx, %rdx
callq 0x19181
leaq -0x2d0(%rbp), %rdi
callq 0x83c0
leaq -0x2c0(%rbp), %rdi
leaq 0xc15a(%rip), %rsi      # 0x24de1
callq 0x8530
movq %rax, %rdi
movq %r14, %rsi
callq 0x8510
leaq 0xc732(%rip), %rsi      # 0x253d0
movq %rax, %rdi
callq 0x8530
movq %rax, %rdi
movq %r13, %rsi
callq 0x8510
movq (%r12), %rsi
movl 0x4(%r15), %edx
leaq -0x148(%rbp), %rdi
movl $0x12c, %ecx            # imm = 0x12C
callq 0x160f4
leaq -0xc8(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0x2b8(%rbp), %r15
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x88a0
movq -0x60(%rbp), %rax
leaq 0xbf75(%rip), %rcx      # 0x24c79
leaq -0x38(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, 0x8(%rsi)
leaq -0xd0(%rbp), %rdi
callq 0x196aa
leaq -0x60(%rbp), %rdi
callq 0x8aa8
movq -0xa0(%rbp), %rdx
xorps %xmm0, %xmm0
leaq -0xf0(%rbp), %r8
movaps %xmm0, (%r8)
movaps %xmm0, 0x10(%r8)
leaq -0x38(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0xd0(%rbp), %rcx
callq 0x162d8
leaq -0xf0(%rbp), %rdi
callq 0x16248
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x18eb5
cmpl $0xce, 0x20(%rax)
jne 0x18eb5
movq -0x80(%rbp), %rdi
pushq $0x41
popq %rsi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x8400
movl %eax, %r12d
testl %eax, %eax
js 0x18e3f
movl %r12d, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x89e0
movq -0x38(%rbp), %rax
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
movl %r12d, %edi
callq 0x8190
testl %eax, %eax
js 0x18e77
movl %r12d, %edi
callq 0x8a60
movq -0x40(%rbp), %rax
movl $0x1, (%rax)
movq 0x1f20d(%rip), %rdi     # 0x37fe8
leaq 0xbfd9(%rip), %rsi      # 0x24dbb
callq 0x8530
leaq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x84b0
leaq 0xc007(%rip), %rsi      # 0x24e01
movq %rax, %rdi
callq 0x8530
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x88a0
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x84b0
leaq 0xbeb1(%rip), %rsi      # 0x24cd5
movq %rax, %rdi
callq 0x8530
movq %rax, %rdi
callq 0x8250
leaq -0x60(%rbp), %rdi
callq 0x8aa8
jmp 0x18eb5
movq 0x1f1a2(%rip), %rdi     # 0x37fe8
leaq 0xbf6e(%rip), %rsi      # 0x24dbb
callq 0x8530
leaq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x84b0
leaq 0xbf83(%rip), %rsi      # 0x24de8
movq %rax, %rdi
callq 0x8530
movq %rax, %rdi
callq 0x8250
jmp 0x18eb5
movq 0x1f16a(%rip), %rdi     # 0x37fe8
leaq 0xbf36(%rip), %rsi      # 0x24dbb
callq 0x8530
leaq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x84b0
leaq 0xbf57(%rip), %rsi      # 0x24df4
movq %rax, %rdi
callq 0x8530
movq %rax, %rdi
callq 0x8250
movl %r12d, %edi
callq 0x8a60
leaq -0x30(%rbp), %rdi
callq 0x140c0
leaq -0xd0(%rbp), %rdi
callq 0x17050
leaq -0x148(%rbp), %rdi
callq 0x8e2c
leaq -0x2d0(%rbp), %rdi
callq 0x8410
leaq -0x80(%rbp), %rdi
callq 0x8aa8
leaq -0xa0(%rbp), %rdi
callq 0x8aa8
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18f4b
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x8aa8
jmp 0x18f4e
jmp 0x18f4b
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x16248
jmp 0x18f57
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x8aa8
jmp 0x18f57
movq %rax, %rbx
jmp 0x18f57
jmp 0x18f71
movq %rax, %rbx
jmp 0x18f80
movq %rax, %rbx
jmp 0x18f89
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x140c0
leaq -0xd0(%rbp), %rdi
callq 0x17050
leaq -0x148(%rbp), %rdi
callq 0x8e2c
jmp 0x18f74
movq %rax, %rbx
leaq -0x2d0(%rbp), %rdi
callq 0x8410
leaq -0x80(%rbp), %rdi
callq 0x8aa8
leaq -0xa0(%rbp), %rdi
callq 0x8aa8
movq %rbx, %rdi
callq 0x8990
nop