// File: /workspace/github_cpp_makefile_star2_O3/hyrise[P]sql-parser/src/util/sqlhelper.cpp
// Function: hsql::printExpression(hsql::Expr*, unsigned long)
void printExpression(Expr* expr, uintmax_t num_indent) {
  if (!expr) return;
  switch (expr->type) {
    case kExprStar:
      inprint("*", num_indent);
      break;
    case kExprColumnRef:
      inprint(expr->name, num_indent);
      if (expr->table) {
        inprint("Table:", num_indent + 1);
        inprint(expr->table, num_indent + 2);
      }
      break;
    // case kExprTableColumnRef: inprint(expr->table, expr->name, num_indent); break;
    case kExprLiteralFloat:
      inprint(expr->fval, num_indent);
      break;
    case kExprLiteralInt:
      inprint(expr->ival, num_indent);
      break;
    case kExprLiteralString:
      inprint(expr->name, num_indent);
      break;
    case kExprLiteralDate:
      inprint(expr->name, num_indent);
      break;
    case kExprLiteralNull:
      inprint("NULL", num_indent);
      break;
    case kExprLiteralInterval:
      inprint("INTERVAL", num_indent);
      inprint(expr->ival, num_indent + 1);
      inprint(expr->datetimeField, num_indent + 1);
      break;
    case kExprFunctionRef:
      inprint(expr->name, num_indent);
      for (Expr* e : *expr->exprList) {
        printExpression(e, num_indent + 1);
      }

      if (expr->windowDescription) {
        printWindowDescription(expr->windowDescription, num_indent + 1);
      }
      break;
    case kExprExtract:
      inprint("EXTRACT", num_indent);
      inprint(expr->datetimeField, num_indent + 1);
      printExpression(expr->expr, num_indent + 1);
      break;
    case kExprCast:
      inprint("CAST", num_indent);
      inprint(expr->columnType, num_indent + 1);
      printExpression(expr->expr, num_indent + 1);
      break;
    case kExprOperator:
      printOperatorExpression(expr, num_indent);
      break;
    case kExprSelect:
      printSelectStatementInfo(expr->select, num_indent);
      break;
    case kExprParameter:
      inprint(expr->ival, num_indent);
      break;
    case kExprArray:
      for (Expr* e : *expr->exprList) {
        printExpression(e, num_indent + 1);
      }
      break;
    case kExprArrayIndex:
      printExpression(expr->expr, num_indent + 1);
      inprint(expr->ival, num_indent);
      break;
    default:
      std::cerr << "Unrecognized expression type " << expr->type << std::endl;
      return;
  }
  if (expr->alias) {
    inprint("Alias", num_indent + 1);
    inprint(expr->alias, num_indent + 2);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x22a19
movq %rdi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x10, %rax
ja 0x22a23
movq %rsi, %r14
leaq 0x10be3(%rip), %rcx     # 0x33420
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rbx), %rdi
jmp 0x22912
movq 0x10(%rbx), %rdi
leaq 0x1(%r14), %rsi
callq 0x12800
movq 0x50(%rbx), %rdi
movq %r14, %rsi
callq 0x12ba0
jmp 0x229e9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12e20
jmp 0x229e9
movq 0x20(%rbx), %rax
movq (%rax), %r12
movq 0x8(%rax), %r13
cmpq %r13, %r12
je 0x229e9
leaq 0x1(%r14), %r15
movq (%r12), %rdi
movq %r15, %rsi
callq 0x12800
addq $0x8, %r12
cmpq %r13, %r12
jne 0x22895
jmp 0x229e9
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq 0x12540
jmp 0x229e9
movsd 0x48(%rbx), %xmm0
movq %r14, %rdi
callq 0x13220
jmp 0x229e9
leaq 0x4b53(%rip), %rdi      # 0x2742c
movq %r14, %rsi
callq 0x13090
movq 0x50(%rbx), %rdi
leaq 0x1(%r14), %r15
movq %r15, %rsi
callq 0x12ba0
leaq 0x60(%rbx), %rdi
movq %r15, %rsi
callq 0x131f0
jmp 0x229e9
leaq 0x10c20(%rip), %rdi     # 0x33529
jmp 0x22912
leaq 0x10e33(%rip), %rdi     # 0x33745
movq %r14, %rsi
callq 0x13090
jmp 0x229e9
leaq 0x491c(%rip), %rdi      # 0x27242
movq %r14, %rsi
callq 0x13090
leaq 0x60(%rbx), %rdi
leaq 0x1(%r14), %r15
movq %r15, %rsi
callq 0x131f0
jmp 0x2295f
leaq 0x4903(%rip), %rdi      # 0x2724a
movq %r14, %rsi
callq 0x13090
leaq 0x68(%rbx), %rdi
leaq 0x1(%r14), %r15
movq %r15, %rsi
callq 0x12fa0
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x12800
jmp 0x229e9
movq 0x30(%rbx), %rdi
movq %r14, %rsi
callq 0x13090
movq 0x20(%rbx), %rax
movq (%rax), %r12
movq 0x8(%rax), %r13
cmpq %r13, %r12
je 0x229a2
leaq 0x1(%r14), %r15
movq (%r12), %rdi
movq %r15, %rsi
callq 0x12800
addq $0x8, %r12
cmpq %r13, %r12
jne 0x2298d
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x229e9
leaq 0x1(%r14), %rsi
callq 0x12e60
jmp 0x229e9
movq 0x30(%rbx), %rdi
movq %r14, %rsi
callq 0x13090
cmpq $0x0, 0x38(%rbx)
je 0x229e9
leaq 0x1(%r14), %rsi
leaq 0x10b54(%rip), %rdi     # 0x3352b
callq 0x13090
movq 0x38(%rbx), %rdi
leaq 0x2(%r14), %rsi
jmp 0x22915
cmpq $0x0, 0x40(%rbx)
je 0x22a19
leaq 0x1(%r14), %rsi
leaq 0x10b23(%rip), %rdi     # 0x3351e
callq 0x13090
movq 0x40(%rbx), %rdi
addq $0x2, %r14
movq %r14, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x13090
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x185c6(%rip), %r14     # 0x3aff0
leaq 0x10b01(%rip), %rsi     # 0x33532
movl $0x1d, %edx
movq %r14, %rdi
callq 0x12a70
movl 0x8(%rbx), %esi
movq %r14, %rdi
callq 0x13080
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x128c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x12060
movq %rax, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x125e0