; 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.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.ast_swap = external hidden unnamed_addr constant [9 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [14 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 dso_local ptr @ast_dup(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_type(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @hasparent(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @settype(ptr noundef, ptr noundef, i1 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_parent(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_previous(ptr noundef) #2

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

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

9:                                                ; preds = %2
  br label %11

10:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.44, ptr noundef @.str.1, i64 noundef 1560, ptr noundef @__func__.ast_swap)
  br label %11

11:                                               ; preds = %10, %9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %12, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  br label %17

16:                                               ; preds = %11
  call void @ponyint_assert_fail(ptr noundef @.str.45, ptr noundef @.str.1, i64 noundef 1561, ptr noundef @__func__.ast_swap)
  br label %17

17:                                               ; preds = %16, %15
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ast_t, ptr %18, i32 0, i32 8
  %20 = load i8, ptr %19, align 4, !tbaa !9, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17
  call void @ponyint_assert_fail(ptr noundef @.str.46, ptr noundef @.str.1, i64 noundef 1563, ptr noundef @__func__.ast_swap)
  br label %24

24:                                               ; preds = %23, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call ptr @ast_parent(ptr noundef %25)
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  br label %31

30:                                               ; preds = %24
  call void @ponyint_assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i64 noundef 1567, ptr noundef @__func__.ast_swap)
  br label %31

31:                                               ; preds = %30, %29
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ast_t, ptr %32, i32 0, i32 8
  %34 = load i8, ptr %33, align 4, !tbaa !9, !range !13, !noundef !14
  %35 = trunc i8 %34 to i1
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  br label %38

37:                                               ; preds = %31
  call void @ponyint_assert_fail(ptr noundef @.str.27, ptr noundef @.str.1, i64 noundef 1569, ptr noundef @__func__.ast_swap)
  br label %38

38:                                               ; preds = %37, %36
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call zeroext i1 @hasparent(ptr noundef %39)
  br i1 %40, label %41, label %44

41:                                               ; preds = %38
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = call ptr @ast_dup(ptr noundef %42)
  store ptr %43, ptr %4, align 8, !tbaa !5
  br label %52

44:                                               ; preds = %38
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ast_t, ptr %45, i32 0, i32 8
  %47 = load i8, ptr %46, align 4, !tbaa !9, !range !13, !noundef !14
  %48 = trunc i8 %47 to i1
  br i1 %48, label %50, label %49

49:                                               ; preds = %44
  br label %51

50:                                               ; preds = %44
  call void @ponyint_assert_fail(ptr noundef @.str.47, ptr noundef @.str.1, i64 noundef 1576, ptr noundef @__func__.ast_swap)
  br label %51

51:                                               ; preds = %50, %49
  br label %52

52:                                               ; preds = %51, %41
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call ptr @ast_type(ptr noundef %53)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = icmp eq ptr %54, %55
  br i1 %56, label %57, label %60

57:                                               ; preds = %52
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  call void @settype(ptr noundef %58, ptr noundef %59, i1 noundef zeroext false)
  br label %79

60:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = call ptr @ast_previous(ptr noundef %61)
  store ptr %62, ptr %6, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %69

65:                                               ; preds = %60
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ast_t, ptr %67, i32 0, i32 5
  store ptr %66, ptr %68, align 8, !tbaa !15
  br label %73

69:                                               ; preds = %60
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ast_t, ptr %71, i32 0, i32 4
  store ptr %70, ptr %72, align 8, !tbaa !16
  br label %73

73:                                               ; preds = %69, %65
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ast_t, ptr %74, i32 0, i32 5
  %76 = load ptr, ptr %75, align 8, !tbaa !15
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ast_t, ptr %77, i32 0, i32 5
  store ptr %76, ptr %78, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %79

79:                                               ; preds = %73, %57
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  call void @set_scope_and_parent(ptr noundef %80, ptr noundef %81)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ast_t, ptr %82, i32 0, i32 5
  store ptr null, ptr %83, align 8, !tbaa !15
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  call void @make_orphan_leave_scope(ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #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, !12, i64 60}
!10 = !{!"ast_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !12, i64 60}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 32}


; 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.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [13 x i8], align 1
@__func__.ast_swap = external hidden unnamed_addr constant [9 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [14 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 dso_local ptr @ast_dup(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_type(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @hasparent(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @settype(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_parent(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_previous(ptr noundef) local_unnamed_addr #1

; 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_swap(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.44, ptr noundef nonnull @.str.1, i64 noundef 1560, ptr noundef nonnull @__func__.ast_swap) #2
  br label %4

4:                                                ; preds = %2, %3
  %.not28 = icmp eq ptr %0, %1
  br i1 %.not28, label %5, label %6

5:                                                ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.1, i64 noundef 1561, ptr noundef nonnull @__func__.ast_swap) #2
  br label %6

6:                                                ; preds = %4, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 60
  %8 = load i8, ptr %7, align 4, !tbaa !5, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %10, label %11

10:                                               ; preds = %6
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.46, ptr noundef nonnull @.str.1, i64 noundef 1563, ptr noundef nonnull @__func__.ast_swap) #2
  br label %11

11:                                               ; preds = %6, %10
  %12 = tail call ptr @ast_parent(ptr noundef nonnull %0)
  %.not29 = icmp eq ptr %12, null
  br i1 %.not29, label %13, label %14

13:                                               ; preds = %11
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i64 noundef 1567, ptr noundef nonnull @__func__.ast_swap) #2
  br label %14

14:                                               ; preds = %11, %13
  %15 = getelementptr inbounds i8, ptr %12, i64 60
  %16 = load i8, ptr %15, align 4, !tbaa !5, !range !12, !noundef !13
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.1, i64 noundef 1569, ptr noundef nonnull @__func__.ast_swap) #2
  br label %19

19:                                               ; preds = %14, %18
  %20 = tail call zeroext i1 @hasparent(ptr noundef %1)
  br i1 %20, label %21, label %23

21:                                               ; preds = %19
  %22 = tail call ptr @ast_dup(ptr noundef %1)
  br label %28

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %1, i64 60
  %25 = load i8, ptr %24, align 4, !tbaa !5, !range !12, !noundef !13
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.1, i64 noundef 1576, ptr noundef nonnull @__func__.ast_swap) #2
  br label %28

28:                                               ; preds = %27, %23, %21
  %.0 = phi ptr [ %22, %21 ], [ %1, %27 ], [ %1, %23 ]
  %29 = tail call ptr @ast_type(ptr noundef nonnull %12)
  %30 = icmp eq ptr %29, %0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  tail call void @settype(ptr noundef nonnull %12, ptr noundef %.0, i1 noundef zeroext false)
  br label %39

32:                                               ; preds = %28
  %33 = tail call ptr @ast_previous(ptr noundef nonnull %0)
  %.not30 = icmp eq ptr %33, null
  %34 = getelementptr inbounds i8, ptr %12, i64 32
  %35 = getelementptr inbounds i8, ptr %33, i64 40
  %.sink = select i1 %.not30, ptr %34, ptr %35
  store ptr %.0, ptr %.sink, align 8, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %.0, i64 40
  store ptr %37, ptr %38, align 8, !tbaa !15
  br label %39

39:                                               ; preds = %32, %31
  tail call void @set_scope_and_parent(ptr noundef %.0, ptr noundef nonnull %12)
  %40 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr null, ptr %40, align 8, !tbaa !15
  tail call void @make_orphan_leave_scope(ptr noundef nonnull %0)
  ret void
}

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, !11, i64 60}
!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 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass