code: def main(
      compilation_db_path, source_files, verbose, formatter, iwyu_args
  ):
      """Entry point."""
      # Canonicalize compilation database path
      if os.path.isdir(compilation_db_path):
          compilation_db_path = os.path.join(
              compilation_db_path, "compile_commands.json"
          )
  
      compilation_db_path = os.path.realpath(compilation_db_path)
      if not os.path.isfile(compilation_db_path):
          print(
              "ERROR: No such file or directory: '%s'",
              compilation_db_path,
          )
          return 1
  
      # Read compilation db from disk
      with open(compilation_db_path, "r") as fileobj:
          compilation_db = json.load(fileobj)
  
      # expand symlinks
      for entry in compilation_db:
          entry["file"] = os.path.realpath(entry["file"])
  
      # Cross-reference source files with compilation database
      source_files = [os.path.realpath(s) for s in source_files]
      if not source_files:
          # No source files specified, analyze entire compilation database
          entries = compilation_db
      else:
          # Source files specified, analyze the ones appearing in compilation db,
          # warn for the rest.
          entries = []
          for source in source_files:
              matches = [
                  e for e in compilation_db if e["file"] == source
              ]
              if matches:
                  entries.extend(matches)
              else:
                  print("{} not in compilation database".format(source))
                  # TODO: As long as there is no complete compilation database available this check cannot be performed
                  pass
                  # print('WARNING: \'%s\' not found in compilation database.', source)
  
      # Run analysis
      try:
          for entry in entries:
              cwd, compile_command = (
                  entry["directory"],
                  entry["command"],
              )
              run_iwyu(
                  cwd, compile_command, iwyu_args, verbose, formatter
              )
      except OSError as why:
          print("ERROR: Failed to launch include-what-you-use: %s", why)
          return 1
  
      return 0
  
file_path: arrow/cpp/build-support/iwyu/iwyu_tool.py
imports: import os
  import sys
  import json
  import argparse
  import subprocess
  import re
  import logging
label_desc: Use image node_id 5 for calling a global function with example usage: main(compilation_db_path, source_files, verbose, formatter, iwyu_args) and returns: int, int, int