// File: knei-knurow[P]lidar-visualizations/src/cloud-writers.cpp
// Function: CloudFileSeriesWriter::write(Cloud const&)
bool CloudFileSeriesWriter::write(const Cloud& cloud) {
  if (clouds_cnt_ == 0) {
    time_begin_ = std::chrono::steady_clock::now();
  }
  auto time_now = std::chrono::steady_clock::now();
  auto time_diff =
      std::chrono::duration_cast<std::chrono::milliseconds>(time_now - time_begin_).count();
  time_begin_ = time_now;

  file_ << "! " << ++clouds_cnt_ << " " << time_diff << "\n";
  if (coord_sys_ == CoordSystem::CART) {
    for (const auto& pt : cloud.pts_cart) {
      file_ << pt.x << " " << pt.y << "\n";
    }
  } else if (coord_sys_ == CoordSystem::CYL) {
    for (const auto& pt : cloud.pts_cyl) {
      file_ << pt.angle << " " << pt.dist << "\n";
    }
  }

  file_.flush();
  status_ = file_.good();
  return status_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, 0x230(%rax)
jne 0x10c20
callq 0x44a0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, 0x240(%rax)
callq 0x44a0
movq -0x80(%rbp), %rsi
movq %rax, -0x20(%rbp)
addq $0x240, %rsi            # imm = 0x240
leaq -0x20(%rbp), %rdi
callq 0xf5e0
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x11540
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xe890
movq -0x80(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, 0x240(%rdi)
addq $0x30, %rdi
leaq 0x2b74(%rip), %rsi      # 0x137e9
callq 0x4360
movq %rax, %rdi
movq -0x80(%rbp), %rax
movq 0x230(%rax), %rsi
addq $0x1, %rsi
movq %rsi, 0x230(%rax)
callq 0x40b0
movq %rax, %rdi
leaq 0x2b48(%rip), %rsi      # 0x137ea
callq 0x4360
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x4640
movq %rax, %rdi
leaq 0x2583(%rip), %rsi      # 0x13240
callq 0x4360
movq -0x80(%rbp), %rax
cmpl $0x0, 0x238(%rax)
jne 0x10d69
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xd7a0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0xd7d0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xdbd0
testb $0x1, %al
jne 0x10d0c
jmp 0x10d64
leaq -0x48(%rbp), %rdi
callq 0xdc30
movq -0x80(%rbp), %rdi
movq %rax, -0x58(%rbp)
addq $0x30, %rdi
movq -0x58(%rbp), %rax
movl (%rax), %esi
callq 0x4600
movq %rax, %rdi
leaq 0x2ab4(%rip), %rsi      # 0x137ea
callq 0x4360
movq %rax, %rdi
movq -0x58(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x4600
movq %rax, %rdi
leaq 0x24ec(%rip), %rsi      # 0x13240
callq 0x4360
leaq -0x48(%rbp), %rdi
callq 0xdc50
jmp 0x10cf9
jmp 0x10e0f
movq -0x80(%rbp), %rax
cmpl $0x1, 0x238(%rax)
jne 0x10e0d
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0xccd0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0xcd00
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xd100
testb $0x1, %al
jne 0x10daf
jmp 0x10e0b
leaq -0x68(%rbp), %rdi
callq 0xd160
movq -0x80(%rbp), %rdi
movq %rax, -0x78(%rbp)
addq $0x30, %rdi
movq -0x78(%rbp), %rax
movss (%rax), %xmm0
callq 0x42b0
movq %rax, %rdi
leaq 0x2a0f(%rip), %rsi      # 0x137ea
callq 0x4360
movq %rax, %rdi
movq -0x78(%rbp), %rax
movss 0x4(%rax), %xmm0
callq 0x42b0
movq %rax, %rdi
leaq 0x2445(%rip), %rsi      # 0x13240
callq 0x4360
leaq -0x68(%rbp), %rdi
callq 0xd180
jmp 0x10d9c
jmp 0x10e0d
jmp 0x10e0f
movq -0x80(%rbp), %rdi
addq $0x30, %rdi
callq 0x4260
movq -0x80(%rbp), %rax
movq %rax, %rdi
addq $0x30, %rdi
movq 0x30(%rax), %rax
addq -0x18(%rax), %rdi
callq 0x45c0
movb %al, %cl
movq -0x80(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x8(%rax)
movb 0x8(%rax), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nop