(command.CommandList
  children: [
    (command.ShFunction
      name: require_pc
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (C {<pkg-config>} {(${ Id.VSub_Number 1)})
                (C {<atf_fail>} {(DQ <'pkg-config could not locate '> (${ Id.VSub_Number 1) <'.pc;'>)} 
                  {(DQ <'maybe need to set PKG_CONFIG_PATH?'>)}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: check_version
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:ver1)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: 
                          (C 
                            {
                              (command_sub
                                left_token: <Id.Left_DollarParen '$('>
                                child: (C {<atf_get_srcdir>})
                              ) <'/detail/version_helper'>
                            }
                          )
                      )
                    }
                  spids: [136]
                )
              ]
            )
            (C {<echo>} {(DQ <'Version reported by builtin PACKAGE_VERSION: '> (${ Id.VSub_Name ver1))})
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<save> <Id.Lit_Colon ':'> <stdout>} {<-e>} {<empty>} {<pkg-config>} {<--modversion>} {(DQ (${ Id.VSub_Number 1))}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:ver2)
                  op: assign_op.Equal
                  rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<stdout>}))}
                  spids: [185]
                )
              ]
            )
            (C {<echo>} {(DQ <'Version reported by pkg-config: '> (${ Id.VSub_Name ver2))})
            (C {<atf_check_equal>} {(${ Id.VSub_Name ver1)} {(${ Id.VSub_Name ver2)})
          ]
        )
    )
    (C {<atf_test_case>} {<version>})
    (command.ShFunction
      name: version_head
      body: 
        (BraceGroup
          children: [
            (C {<atf_set>} {(DQ <descr>)} {(DQ <'Checks that the version in atf-c is correct'>)})
            (C {<atf_set>} {(DQ <require.progs>)} {(DQ <pkg-config>)})
          ]
        )
    )
    (command.ShFunction
      name: version_body
      body: 
        (BraceGroup
          children: [(C {<require_pc>} {(DQ <atf-c>)}) (C {<check_version>} {(DQ <atf-c>)})]
        )
    )
    (C {<atf_test_case>} {<build>})
    (command.ShFunction
      name: build_head
      body: 
        (BraceGroup
          children: [
            (C {<atf_set>} {(DQ <descr>)} {(DQ <'Checks that a test program can be built against'>)} 
              {(DQ <'the C library based on the pkg-config information'>)}
            )
            (C {<atf_set>} {(DQ <require.progs>)} {(DQ <pkg-config>)})
          ]
        )
    )
    (command.ShFunction
      name: build_body
      body: 
        (BraceGroup
          children: [
            (C {<require_pc>} {(DQ <atf-c>)})
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<save> <Id.Lit_Colon ':'> <stdout>} {<-e>} {<empty>} {<pkg-config>} {<--variable> <Id.Lit_Equals '='> <cc>} {<atf-c>}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cc)
                  op: assign_op.Equal
                  rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<stdout>}))}
                  spids: [357]
                )
              ]
            )
            (C {<echo>} {(DQ <'Compiler is: '> (${ Id.VSub_Name cxx))})
            (C {<atf_require_prog>} {(${ Id.VSub_Name cxx)})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<tp.c>})
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 423
                      stdin_parts: [
                        <'#include <stdio.h>\n'>
                        <'\n'>
                        <'#include <atf-c.h>\n'>
                        <'\n'>
                        <'ATF_TC(tc);\n'>
                        <'ATF_TC_HEAD(tc, tc) {\n'>
                        <'    atf_tc_set_md_var(tc, '>
                        <Id.Right_DoubleQuote '"'>
                        <descr>
                        <Id.Right_DoubleQuote '"'>
                        <', '>
                        <Id.Right_DoubleQuote '"'>
                        <'A test case'>
                        <Id.Right_DoubleQuote '"'>
                        <');\n'>
                        <'}\n'>
                        <'ATF_TC_BODY(tc, tc) {\n'>
                        <'    printf('>
                        <Id.Right_DoubleQuote '"'>
                        <Running>
                        <Id.Lit_BadBackslash '\\'>
                        <n>
                        <Id.Right_DoubleQuote '"'>
                        <');\n'>
                        <'}\n'>
                        <'\n'>
                        <'ATF_TP_ADD_TCS(tp) {\n'>
                        <'    ATF_TP_ADD_TC(tp, tc);\n'>
                        <'\n'>
                        <'    return atf_no_error();\n'>
                        <'}\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<save> <Id.Lit_Colon ':'> <stdout>} {<-e>} {<empty>} {<pkg-config>} {<--cflags>} {<atf-c>}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cflags)
                  op: assign_op.Equal
                  rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<stdout>}))}
                  spids: [451]
                )
              ]
            )
            (C {<echo>} {(DQ <'CFLAGS are: '> (${ Id.VSub_Name cflags))})
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<save> <Id.Lit_Colon ':'> <stdout>} {<-e>} {<empty>} {<pkg-config>} {<--libs-only-L>} {<--libs-only-other>} {<atf-c>}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:ldflags)
                  op: assign_op.Equal
                  rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<stdout>}))}
                  spids: [499]
                )
              ]
            )
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<save> <Id.Lit_Colon ':'> <stdout>} {<-e>} {<empty>} {<pkg-config>} {<--libs-only-l>} {<atf-c>}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:libs)
                  op: assign_op.Equal
                  rhs: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<stdout>}))}
                  spids: [532]
                )
              ]
            )
            (C {<echo>} {(DQ <'LDFLAGS are: '> (${ Id.VSub_Name ldflags))})
            (C {<echo>} {(DQ <'LIBS are: '> (${ Id.VSub_Name libs))})
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} {<empty>} {<-e>} {<empty>} 
              {(${ Id.VSub_Name cc)} {(${ Id.VSub_Name cflags)} {<-o>} {<tp.o>} {<-c>} {<tp.c>}
            )
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} {<empty>} {<-e>} {<empty>} 
              {(${ Id.VSub_Name cc)} {(${ Id.VSub_Name ldflags)} {<-o>} {<tp>} {<tp.o>} {(${ Id.VSub_Name libs)}
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:libpath)
                  op: assign_op.Equal
                  rhs: (word.Empty)
                  spids: [630]
                )
              ]
            )
            (command.ForEach
              iter_name: f
              iter_words: [{(${ Id.VSub_Name ldflags)}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.Case
                      to_match: {(${ Id.VSub_Name f)}
                      arms: [
                        (case_arm
                          pat_list: [{<-L> <Id.Lit_Star '*'>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:dir)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (command_sub
                                        left_token: <Id.Left_DollarParen '$('>
                                        child: 
                                          (command.Pipeline
                                            children: [
                                              (C {<echo>} {(${ Id.VSub_Name f)})
                                              (C {<sed>} {<-e>} {(SQ <'s,^-L,,'>)})
                                            ]
                                            negated: F
                                          )
                                      )
                                    }
                                  spids: [661]
                                )
                              ]
                            )
                            (command.If
                              arms: [
                                (if_arm
                                  cond: 
                                    (condition.Shell
                                      commands: [
                                        (command.Sentence
                                          child: 
                                            (C {<Id.Lit_LBracket '['>} {<-z>} 
                                              {(DQ (${ Id.VSub_Name libpath))} {<Id.Lit_RBracket ']'>}
                                            )
                                          terminator: <Id.Op_Semi _>
                                        )
                                      ]
                                    )
                                  action: [
                                    (command.ShAssignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (sh_lhs_expr.Name name:libpath)
                                          op: assign_op.Equal
                                          rhs: {(DQ (${ Id.VSub_Name dir))}
                                          spids: [699]
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [681 696]
                                )
                              ]
                              else_action: [
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name name:libpath)
                                      op: assign_op.Equal
                                      rhs: {(DQ (${ Id.VSub_Name libpath) <':'> (${ Id.VSub_Name dir))}
                                      spids: [710]
                                    )
                                  ]
                                )
                              ]
                            )
                          ]
                          spids: [656 658 725 -1]
                        )
                        (case_arm
                          pat_list: [{<Id.Lit_Star '*'>}]
                          spids: [728 729 732 -1]
                        )
                      ]
                    )
                  ]
                )
            )
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} {<empty>} {<-e>} {<empty>} {<test>} 
              {<-x>} {<tp>}
            )
            (C {<atf_check>} {<-s>} {<eq> <Id.Lit_Colon ':'> <0>} {<-o>} 
              {<match> <Id.Lit_Colon ':'> (SQ <Running>)} {<-e>} {<empty>} {<-x>} {(DQ <'LD_LIBRARY_PATH='> (${ Id.VSub_Name libpath) <' ./tp tc'>)}
            )
          ]
        )
    )
    (command.ShFunction
      name: atf_init_test_cases
      body: 
        (BraceGroup
          children: [(C {<atf_add_test_case>} {<version>}) (C {<atf_add_test_case>} {<build>})]
        )
    )
  ]
)