// File: /workspace/github_cpp_makefile_star2_O1/hyrise[P]sql-parser/src/util/sqlhelper.cpp
// Function: hsql::printSelectStatementInfo(hsql::SelectStatement const*, unsigned long)
void printSelectStatementInfo(const SelectStatement* stmt, uintmax_t num_indent) {
  inprint("SelectStatement", num_indent);
  inprint("Fields:", num_indent + 1);
  for (Expr* expr : *stmt->selectList) printExpression(expr, num_indent + 2);

  if (stmt->fromTable) {
    inprint("Sources:", num_indent + 1);
    printTableRefInfo(stmt->fromTable, num_indent + 2);
  }

  if (stmt->whereClause) {
    inprint("Search Conditions:", num_indent + 1);
    printExpression(stmt->whereClause, num_indent + 2);
  }

  if (stmt->groupBy) {
    inprint("GroupBy:", num_indent + 1);
    for (Expr* expr : *stmt->groupBy->columns) printExpression(expr, num_indent + 2);
    if (stmt->groupBy->having) {
      inprint("Having:", num_indent + 1);
      printExpression(stmt->groupBy->having, num_indent + 2);
    }
  }
  if (stmt->lockings) {
    inprint("Lock Info:", num_indent + 1);
    for (LockingClause* lockingClause : *stmt->lockings) {
      inprint("Type", num_indent + 2);
      if (lockingClause->rowLockMode == RowLockMode::ForUpdate) {
        inprint("FOR UPDATE", num_indent + 3);
      } else if (lockingClause->rowLockMode == RowLockMode::ForNoKeyUpdate) {
        inprint("FOR NO KEY UPDATE", num_indent + 3);
      } else if (lockingClause->rowLockMode == RowLockMode::ForShare) {
        inprint("FOR SHARE", num_indent + 3);
      } else if (lockingClause->rowLockMode == RowLockMode::ForKeyShare) {
        inprint("FOR KEY SHARE", num_indent + 3);
      }
      if (lockingClause->tables) {
        inprint("Target tables:", num_indent + 2);
        for (char* dtable : *lockingClause->tables) {
          inprint(dtable, num_indent + 3);
        }
      }
      if (lockingClause->rowLockWaitPolicy != RowLockWaitPolicy::None) {
        inprint("Waiting policy: ", num_indent + 2);
        if (lockingClause->rowLockWaitPolicy == RowLockWaitPolicy::NoWait)
          inprint("NOWAIT", num_indent + 3);
        else
          inprint("SKIP LOCKED", num_indent + 3);
      }
    }
  }

  if (stmt->setOperations) {
    for (SetOperation* setOperation : *stmt->setOperations) {
      switch (setOperation->setType) {
        case SetType::kSetIntersect:
          inprint("Intersect:", num_indent + 1);
          break;
        case SetType::kSetUnion:
          inprint("Union:", num_indent + 1);
          break;
        case SetType::kSetExcept:
          inprint("Except:", num_indent + 1);
          break;
      }

      printSelectStatementInfo(setOperation->nestedSelectStatement, num_indent + 2);

      if (setOperation->resultOrder) {
        inprint("SetResultOrderBy:", num_indent + 1);
        printOrderBy(setOperation->resultOrder, num_indent + 2);
      }

      if (setOperation->resultLimit) {
        if (setOperation->resultLimit->limit) {
          inprint("SetResultLimit:", num_indent + 1);
          printExpression(setOperation->resultLimit->limit, num_indent + 2);
        }

        if (setOperation->resultLimit->offset) {
          inprint("SetResultOffset:", num_indent + 1);
          printExpression(setOperation->resultLimit->offset, num_indent + 2);
        }
      }
    }
  }

  if (stmt->order) {
    inprint("OrderBy:", num_indent + 1);
    printOrderBy(stmt->order, num_indent + 2);
  }

  if (stmt->limit && stmt->limit->limit) {
    inprint("Limit:", num_indent + 1);
    printExpression(stmt->limit->limit, num_indent + 2);
  }

  if (stmt->limit && stmt->limit->offset) {
    inprint("Offset:", num_indent + 1);
    printExpression(stmt->limit->offset, num_indent + 2);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, %r13
leaq 0x10ff3(%rip), %rdi     # 0x3358b
callq 0x13090
leaq 0x1(%r12), %rsi
leaq 0x10ff2(%rip), %rdi     # 0x3359b
movq %rsi, 0x8(%rsp)
callq 0x13090
movq 0x30(%r13), %rax
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r15, %r14
je 0x225dc
leaq 0x2(%r12), %rbx
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x12800
addq $0x8, %r14
cmpq %r15, %r14
jne 0x225c8
cmpq $0x0, 0x20(%r13)
je 0x22602
leaq 0x10fb9(%rip), %rdi     # 0x335a3
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x20(%r13), %rdi
leaq 0x2(%r12), %rsi
callq 0x12c20
cmpq $0x0, 0x38(%r13)
je 0x22628
leaq 0x10f9c(%rip), %rdi     # 0x335ac
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x38(%r13), %rdi
leaq 0x2(%r12), %rsi
callq 0x12800
cmpq $0x0, 0x40(%r13)
je 0x2269b
leaq 0x10f89(%rip), %rdi     # 0x335bf
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x40(%r13), %rax
movq 0x8(%rax), %rax
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r15, %r14
je 0x2266d
leaq 0x2(%r12), %rbx
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x12800
addq $0x8, %r14
cmpq %r15, %r14
jne 0x22659
movq 0x40(%r13), %rax
cmpq $0x0, 0x10(%rax)
je 0x2269b
leaq 0x10f49(%rip), %rdi     # 0x335c8
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x40(%r13), %rax
movq 0x10(%rax), %rdi
leaq 0x2(%r12), %rsi
callq 0x12800
movq %r12, 0x10(%rsp)
movq %r13, 0x18(%rsp)
cmpq $0x0, 0x68(%r13)
je 0x227bd
leaq 0x10f19(%rip), %rdi     # 0x335d0
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x18(%rsp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rbx
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq %rax, %rbx
je 0x227bd
movq 0x10(%rsp), %rax
leaq 0x2(%rax), %r12
leaq 0x3(%rax), %r13
movq (%rbx), %r15
leaq 0x10ee5(%rip), %rdi     # 0x335db
movq %r12, %rsi
callq 0x13090
movl (%r15), %eax
cmpq $0x3, %rax
ja 0x22741
leaq 0x10d12(%rip), %rcx     # 0x33420
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10ec2(%rip), %rdi     # 0x335e0
jmp 0x22739
leaq 0x10ed6(%rip), %rdi     # 0x335fd
jmp 0x22739
leaq 0x10ed7(%rip), %rdi     # 0x33607
jmp 0x22739
leaq 0x10eb2(%rip), %rdi     # 0x335eb
movq %r13, %rsi
callq 0x13090
cmpq $0x0, 0x8(%r15)
je 0x22779
leaq 0x10ec6(%rip), %rdi     # 0x33615
movq %r12, %rsi
callq 0x13090
movq 0x8(%r15), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r14
cmpq %r14, %rbp
je 0x22779
movq (%rbp), %rdi
movq %r13, %rsi
callq 0x13090
addq $0x8, %rbp
jmp 0x22762
cmpl $0x2, 0x4(%r15)
je 0x227ae
leaq 0x10e9d(%rip), %rdi     # 0x33624
movq %r12, %rsi
callq 0x13090
cmpl $0x0, 0x4(%r15)
je 0x2279f
leaq 0x10e98(%rip), %rdi     # 0x33635
jmp 0x227a6
leaq 0x4cc4(%rip), %rdi      # 0x2746a
movq %r13, %rsi
callq 0x13090
addq $0x8, %rbx
cmpq 0x20(%rsp), %rbx
jne 0x226ec
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
testq %rax, %rax
je 0x228ab
movq (%rax), %r14
movq 0x8(%rax), %r12
cmpq %r12, %r14
je 0x228ab
movq 0x10(%rsp), %rax
leaq 0x2(%rax), %rbx
leaq 0x10cbd(%rip), %r13     # 0x334ac
leaq 0x10e65(%rip), %rbp     # 0x3365b
movq (%r14), %r15
movl 0x8(%r15), %eax
cmpq $0x2, %rax
ja 0x22815
movslq (%r13,%rax,4), %rdi
addq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x12540
cmpq $0x0, 0x18(%r15)
je 0x22841
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0x12e00
movq 0x20(%r15), %rax
testq %rax, %rax
je 0x2289e
cmpq $0x0, 0x8(%rax)
je 0x22872
leaq 0x10e15(%rip), %rdi     # 0x3366d
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x20(%r15), %rax
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0x12800
movq 0x20(%r15), %rax
cmpq $0x0, 0x10(%rax)
je 0x2289e
leaq 0x10df9(%rip), %rdi     # 0x3367d
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x20(%r15), %rax
movq 0x10(%rax), %rdi
movq %rbx, %rsi
callq 0x12800
addq $0x8, %r14
cmpq %r12, %r14
jne 0x227f6
movq 0x18(%rsp), %r14
cmpq $0x0, 0x50(%r14)
movq 0x10(%rsp), %rbx
je 0x228da
leaq 0x10da1(%rip), %rdi     # 0x33664
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x50(%r14), %rdi
leaq 0x2(%rbx), %rsi
callq 0x12e00
movq 0x60(%r14), %rax
testq %rax, %rax
je 0x2290c
cmpq $0x0, 0x8(%rax)
je 0x2290c
leaq 0x10d85(%rip), %rdi     # 0x33676
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x60(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x2(%rbx), %rsi
callq 0x12800
movq 0x60(%r14), %rax
testq %rax, %rax
je 0x2294f
cmpq $0x0, 0x10(%rax)
je 0x2294f
leaq 0x10d63(%rip), %rdi     # 0x33686
movq 0x8(%rsp), %rsi
callq 0x13090
movq 0x60(%r14), %rax
movq 0x10(%rax), %rdi
addq $0x2, %rbx
movq %rbx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12800
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq