// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/formatter.cpp
// Function: get_widths(ash::ResultSet const*, bool)
vector<size_t> get_widths(const ResultSet * rs, bool do_show_headings) {
  vector<size_t> widths;
  const size_t XX = 4;  // The number of spaces between columns.

  // Initialize with the widths of the headings.
  size_t c = 0;
  ResultSet::HeadersType::const_iterator i, e;
  for (i = (rs -> headers).begin(), e = (rs -> headers).end(); i != e; ++i, ++c)
    if (do_show_headings)
      widths.push_back(XX + i -> size());
    else
      widths.push_back(XX);

  // Limit the width of columns containing very wide elements.
  size_t max_w = 80;  // TODO(cpa): make this a flag or configurable.

  // Loop ofer the rs.data looking for max column widths.
  for (size_t r = 0; r < rs -> rows; ++r) {
    for (size_t c = 0; c < rs -> columns; ++c) {
      widths[c] = max(widths[c], min(max_w, XX + (rs -> data[r][c]).size()));
    }
  }

  return widths;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0x68(%rsp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, 0x70(%rsp)
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
andb $0x1, %al
movb %al, 0xe7(%rsp)
movb $0x0, 0xe6(%rsp)
callq 0x9e200
movq $0x4, 0xd8(%rsp)
movq $0x0, 0xd0(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x9e210
jmp 0x9c063
leaq 0xb0(%rsp), %rdi
callq 0x9e210
jmp 0x9c072
movq 0xe8(%rsp), %rdi
callq 0x94ad0
movq %rax, 0x60(%rsp)
jmp 0x9c086
movq 0x60(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x94b00
movq %rax, 0x58(%rsp)
jmp 0x9c0b7
movq 0x58(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x94bd0
movb %al, 0x57(%rsp)
jmp 0x9c0ef
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x9c0fc
jmp 0x9c1b5
testb $0x1, 0xe7(%rsp)
je 0x9c175
leaq 0xc8(%rsp), %rdi
callq 0x9e2a0
movq %rax, 0x48(%rsp)
jmp 0x9c11a
movq 0x48(%rsp), %rdi
callq 0x8280
movq %rax, 0x40(%rsp)
jmp 0x9c12b
movq 0x68(%rsp), %rdi
movq 0x40(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x98(%rsp)
leaq 0x98(%rsp), %rsi
callq 0x9e230
jmp 0x9c150
jmp 0x9c18b
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
callq 0x9e2e0
jmp 0x9c33b
movq 0x68(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x9e230
jmp 0x9c189
jmp 0x9c18b
jmp 0x9c18d
leaq 0xc8(%rsp), %rdi
callq 0x94c10
jmp 0x9c19c
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0x9c0d4
movq $0x50, 0x90(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x9c312
movq $0x0, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x9c2f7
movq 0x68(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x9e2c0
movq %rax, 0x38(%rsp)
jmp 0x9c226
movq 0xe8(%rsp), %rdi
addq $0x18, %rdi
movq 0x88(%rsp), %rsi
callq 0x94620
movq %rax, 0x30(%rsp)
jmp 0x9c246
movq 0x30(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x94640
movq %rax, 0x28(%rsp)
jmp 0x9c25f
movq 0x28(%rsp), %rdi
callq 0x8280
movq %rax, 0x20(%rsp)
jmp 0x9c270
movq 0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x78(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x960d0
movq %rax, 0x18(%rsp)
jmp 0x9c297
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x8cff0
movq %rax, 0x10(%rsp)
jmp 0x9c2ad
movq 0x68(%rsp), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x80(%rsp), %rsi
callq 0x9e2c0
movq %rax, 0x8(%rsp)
jmp 0x9c2d2
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, (%rax)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x9c1f3
jmp 0x9c2f9
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x9c1cd
movb $0x1, 0xe6(%rsp)
testb $0x1, 0xe6(%rsp)
jne 0x9c32e
movq 0x68(%rsp), %rdi
callq 0x9e2e0
movq 0x70(%rsp), %rax
addq $0xf8, %rsp
retq
jmp 0x9c33d
movq 0xc0(%rsp), %rdi
callq 0x87d0
movq %rax, %rdi
callq 0x8cf60
nopw %cs:(%rax,%rax)