// File: knei-knurow[P]lidar-visualizations/src/cloud-writers.cpp
// Function: CloudFileSeriesWriter::CloudFileSeriesWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, CoordSystem)
CloudFileSeriesWriter::CloudFileSeriesWriter(const std::string& output_dir, CoordSystem coord_sys) {
  clouds_cnt_ = 0;
  coord_sys_ = coord_sys;

  if (coord_sys_ == CoordSystem::CART) {
    filename_ = generate_filename("txt", output_dir, "cloud-ser-cart");
  } else if (coord_sys_ == CoordSystem::CYL) {
    filename_ = generate_filename("txt", output_dir, "cloud-ser-cyl");
  }

  std::cout << "Starting cloud series: " << filename_ << "." << std::endl;
  file_ = std::ofstream(filename_);
  if (!file_) {
    status_ = false;
    std::cerr << "ERROR: Unable to create cloud series file." << std::endl;
  }
  file_ << "# RPLIDAR SCAN DATA SERIES" << std::endl;
  file_ << "# Software: https://github.com/knei-knurow/lidar-visualizations" << std::endl;
  file_ << "# Authors: Szymon Bednorz, Bartek Dudek" << std::endl;
  file_ << "#" << std::endl;
  file_ << "# Each frame (360 deg full scan) is followed by its number and a "
           "time elapsed from the previous frame (in milliseconds)."
        << std::endl;
  file_ << "#" << std::endl;
  if (coord_sys_ == CoordSystem::CART) {
    file_ << "# X, Y" << std::endl;
  } else if (coord_sys_ == CoordSystem::CYL) {
    file_ << "# Angle, Distance" << std::endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x11520
movq -0x318(%rbp), %rdi
leaq 0xc744(%rip), %rax      # 0x1cbd8
movq %rax, (%rdi)
addq $0x10, %rdi
movq %rdi, -0x320(%rbp)
callq 0x44c0
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x310(%rbp)
callq 0x45e0
jmp 0x104c0
movq -0x318(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0xc370
jmp 0x104d5
movq -0x318(%rbp), %rax
movq $0x0, 0x230(%rax)
movl -0x14(%rbp), %ecx
movl %ecx, 0x238(%rax)
cmpl $0x0, 0x238(%rax)
jne 0x10647
leaq -0x69(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x4620
movq -0x328(%rbp), %rdx
leaq 0x30cb(%rip), %rsi      # 0x135e6
leaq -0x68(%rbp), %rdi
callq 0x4ae0
jmp 0x10526
movq -0x10(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x4620
movq -0x330(%rbp), %rdx
leaq 0x3171(%rip), %rsi      # 0x136c3
leaq -0x90(%rbp), %rdi
callq 0x4ae0
jmp 0x10560
movq -0x338(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rcx
callq 0xf900
jmp 0x10582
movq -0x318(%rbp), %rdi
addq $0x10, %rdi
leaq -0x48(%rbp), %rsi
callq 0x4430
leaq -0x48(%rbp), %rdi
callq 0x4230
leaq -0x90(%rbp), %rdi
callq 0x4230
leaq -0x91(%rbp), %rdi
callq 0x43c0
leaq -0x68(%rbp), %rdi
callq 0x4230
leaq -0x69(%rbp), %rdi
callq 0x43c0
jmp 0x107a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x10abb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x10aaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x10639
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x10624
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4230
leaq -0x91(%rbp), %rdi
callq 0x43c0
leaq -0x68(%rbp), %rdi
callq 0x4230
leaq -0x69(%rbp), %rdi
callq 0x43c0
jmp 0x10aaf
movq -0x318(%rbp), %rax
cmpl $0x1, 0x238(%rax)
jne 0x1079e
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x4620
movq -0x340(%rbp), %rdx
leaq 0x2f6a(%rip), %rsi      # 0x135e6
leaq -0xd8(%rbp), %rdi
callq 0x4ae0
jmp 0x1068a
movq -0x10(%rbp), %rax
movq %rax, -0x350(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x4620
movq -0x348(%rbp), %rdx
leaq 0x301c(%rip), %rsi      # 0x136d2
leaq -0x100(%rbp), %rdi
callq 0x4ae0
jmp 0x106c4
movq -0x350(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x100(%rbp), %rcx
callq 0xf900
jmp 0x106ec
movq -0x318(%rbp), %rdi
addq $0x10, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4430
leaq -0xb8(%rbp), %rdi
callq 0x4230
leaq -0x100(%rbp), %rdi
callq 0x4230
leaq -0x101(%rbp), %rdi
callq 0x43c0
leaq -0xd8(%rbp), %rdi
callq 0x4230
leaq -0xd9(%rbp), %rdi
callq 0x43c0
jmp 0x1079e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x1078d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x10775
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x4230
leaq -0x101(%rbp), %rdi
callq 0x43c0
leaq -0xd8(%rbp), %rdi
callq 0x4230
leaq -0xd9(%rbp), %rdi
callq 0x43c0
jmp 0x10aaf
jmp 0x107a0
movq 0xc829(%rip), %rdi      # 0x1cfd0
leaq 0x2f32(%rip), %rsi      # 0x136e0
callq 0x4360
movq %rax, -0x358(%rbp)
jmp 0x107bc
movq -0x358(%rbp), %rdi
movq -0x318(%rbp), %rsi
addq $0x10, %rsi
callq 0x4330
movq %rax, -0x360(%rbp)
jmp 0x107dc
movq -0x360(%rbp), %rdi
leaq 0x2fcd(%rip), %rsi      # 0x137b7
callq 0x4360
movq %rax, -0x368(%rbp)
jmp 0x107f8
movq -0x368(%rbp), %rdi
movq 0xc7ba(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x1080d
movq -0x318(%rbp), %rsi
addq $0x10, %rsi
leaq -0x308(%rbp), %rdi
movl $0x10, %edx
callq 0x4670
jmp 0x1082b
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq -0x308(%rbp), %rsi
callq 0x4420
jmp 0x10844
leaq -0x308(%rbp), %rdi
callq 0x4510
movq -0x318(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x30(%rax,%rcx), %rdi
callq 0x41b0
movb %al, -0x369(%rbp)
jmp 0x10871
movb -0x369(%rbp), %al
testb $0x1, %al
jne 0x1087d
jmp 0x108d8
movq -0x318(%rbp), %rax
movb $0x0, 0x8(%rax)
movq 0xc761(%rip), %rdi      # 0x1cff0
leaq 0x2e62(%rip), %rsi      # 0x136f8
callq 0x4360
movq %rax, -0x378(%rbp)
jmp 0x108a4
movq -0x378(%rbp), %rdi
movq 0xc70e(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x108b9
jmp 0x108d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x4510
jmp 0x10aaf
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2e39(%rip), %rsi      # 0x13723
callq 0x4360
movq %rax, -0x380(%rbp)
jmp 0x108f8
movq -0x380(%rbp), %rdi
movq 0xc6ba(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x1090d
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d16(%rip), %rsi      # 0x13635
callq 0x4360
movq %rax, -0x388(%rbp)
jmp 0x1092d
movq -0x388(%rbp), %rdi
movq 0xc685(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x10942
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d21(%rip), %rsi      # 0x13675
callq 0x4360
movq %rax, -0x390(%rbp)
jmp 0x10962
movq -0x390(%rbp), %rdi
movq 0xc650(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x10977
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2db5(%rip), %rsi      # 0x1373e
callq 0x4360
movq %rax, -0x398(%rbp)
jmp 0x10997
movq -0x398(%rbp), %rdi
movq 0xc61b(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x109ac
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d82(%rip), %rsi      # 0x13740
callq 0x4360
movq %rax, -0x3a0(%rbp)
jmp 0x109cc
movq -0x3a0(%rbp), %rdi
movq 0xc5e6(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x109e1
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d4b(%rip), %rsi      # 0x1373e
callq 0x4360
movq %rax, -0x3a8(%rbp)
jmp 0x10a01
movq -0x3a8(%rbp), %rdi
movq 0xc5b1(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x10a16
movq -0x318(%rbp), %rax
cmpl $0x0, 0x238(%rax)
jne 0x10a5d
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d81(%rip), %rsi      # 0x137b9
callq 0x4360
movq %rax, -0x3b0(%rbp)
jmp 0x10a46
movq -0x3b0(%rbp), %rdi
movq 0xc56c(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x10a5b
jmp 0x10aa6
movq -0x318(%rbp), %rax
cmpl $0x1, 0x238(%rax)
jne 0x10aa4
movq -0x318(%rbp), %rdi
addq $0x30, %rdi
leaq 0x2d41(%rip), %rsi      # 0x137c0
callq 0x4360
movq %rax, -0x3b8(%rbp)
jmp 0x10a8d
movq -0x3b8(%rbp), %rdi
movq 0xc525(%rip), %rsi      # 0x1cfc0
callq 0x43a0
jmp 0x10aa2
jmp 0x10aa4
jmp 0x10aa6
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
movq -0x310(%rbp), %rdi
callq 0x4510
movq -0x320(%rbp), %rdi
callq 0x4230
movq -0x318(%rbp), %rdi
callq 0x11790
movq -0x20(%rbp), %rdi
callq 0x4610
nopl (%rax)