; LLVM IR from ponylang/ponyc :: src/libponyc/ast (ast)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.ast_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i8 }

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [10 x i8], align 1
@__func__.ast_extract_children = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @make_orphan_leave_scope(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ast_extract_children(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @ponyint_assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i64 noundef 1951, ptr noundef @__func__.ast_extract_children)
  br label %15

15:                                               ; preds = %14, %13
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = icmp ugt i64 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @ponyint_assert_fail(ptr noundef @.str.55, ptr noundef @.str.1, i64 noundef 1952, ptr noundef @__func__.ast_extract_children)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @ponyint_assert_fail(ptr noundef @.str.56, ptr noundef @.str.1, i64 noundef 1953, ptr noundef @__func__.ast_extract_children)
  br label %25

25:                                               ; preds = %24, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ast_t, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  store ptr %28, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %76, %25
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %79

34:                                               ; preds = %29
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  br label %39

38:                                               ; preds = %34
  call void @ponyint_assert_fail(ptr noundef @.str.57, ptr noundef @.str.1, i64 noundef 1960, ptr noundef @__func__.ast_extract_children)
  br label %39

39:                                               ; preds = %38, %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ast_t, ptr %40, i32 0, i32 5
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  store ptr %42, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = getelementptr inbounds ptr, ptr %43, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %72

48:                                               ; preds = %39
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %57

51:                                               ; preds = %48
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ast_t, ptr %52, i32 0, i32 5
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ast_t, ptr %55, i32 0, i32 5
  store ptr %54, ptr %56, align 8, !tbaa !15
  br label %63

57:                                               ; preds = %48
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ast_t, ptr %58, i32 0, i32 5
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ast_t, ptr %61, i32 0, i32 4
  store ptr %60, ptr %62, align 8, !tbaa !11
  br label %63

63:                                               ; preds = %57, %51
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  call void @make_orphan_leave_scope(ptr noundef %64)
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ast_t, ptr %65, i32 0, i32 5
  store ptr null, ptr %66, align 8, !tbaa !15
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load i64, ptr %9, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %68, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  store ptr %67, ptr %71, align 8, !tbaa !5
  br label %74

72:                                               ; preds = %39
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %73, ptr %8, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %72, %63
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %75, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %76

76:                                               ; preds = %74
  %77 = load i64, ptr %9, align 8, !tbaa !9
  %78 = add i64 %77, 1
  store i64 %78, ptr %9, align 8, !tbaa !9
  br label %29, !llvm.loop !16

79:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"ast_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !14, i64 60}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !6, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [10 x i8], align 1
@__func__.ast_extract_children = external hidden unnamed_addr constant [21 x i8], align 1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @make_orphan_leave_scope(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ast_extract_children(ptr noundef %0, i64 noundef %1, ptr noundef readonly %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i64 noundef 1951, ptr noundef nonnull @__func__.ast_extract_children) #2
  br label %5

5:                                                ; preds = %3, %4
  %.not24 = icmp eq i64 %1, 0
  br i1 %.not24, label %6, label %7

6:                                                ; preds = %5
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.55, ptr noundef nonnull @.str.1, i64 noundef 1952, ptr noundef nonnull @__func__.ast_extract_children) #2
  br label %7

7:                                                ; preds = %5, %6
  %.not25 = icmp eq ptr %2, null
  br i1 %.not25, label %8, label %9

8:                                                ; preds = %7
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.56, ptr noundef nonnull @.str.1, i64 noundef 1953, ptr noundef nonnull @__func__.ast_extract_children) #2
  br label %9

9:                                                ; preds = %7, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %.not24, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  br label %.lr.ph

._crit_edge:                                      ; preds = %21, %9
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %21
  %.031 = phi ptr [ %15, %21 ], [ %11, %.lr.ph.preheader ]
  %.02230 = phi i64 [ %22, %21 ], [ 0, %.lr.ph.preheader ]
  %.02329 = phi ptr [ %.1, %21 ], [ null, %.lr.ph.preheader ]
  %.not26 = icmp eq ptr %.031, null
  br i1 %.not26, label %12, label %13

12:                                               ; preds = %.lr.ph
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.57, ptr noundef nonnull @.str.1, i64 noundef 1960, ptr noundef nonnull @__func__.ast_extract_children) #2
  br label %13

13:                                               ; preds = %.lr.ph, %12
  %14 = getelementptr inbounds i8, ptr %.031, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds ptr, ptr %2, i64 %.02230
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %.not27 = icmp eq ptr %17, null
  br i1 %.not27, label %21, label %18

18:                                               ; preds = %13
  %.not28 = icmp eq ptr %.02329, null
  %19 = getelementptr inbounds i8, ptr %.02329, i64 40
  %.sink = select i1 %.not28, ptr %10, ptr %19
  store ptr %15, ptr %.sink, align 8, !tbaa !13
  tail call void @make_orphan_leave_scope(ptr noundef nonnull %.031)
  store ptr null, ptr %14, align 8, !tbaa !12
  %20 = load ptr, ptr %16, align 8, !tbaa !13
  store ptr %.031, ptr %20, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %13, %18
  %.1 = phi ptr [ %.02329, %18 ], [ %.031, %13 ]
  %22 = add nuw i64 %.02230, 1
  %exitcond.not = icmp eq i64 %22, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14
}

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 32}
!6 = !{!"ast_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !11, i64 60}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !7, i64 40}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass