; 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.29 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.ast_add_sibling = external hidden unnamed_addr constant [16 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [29 x i8], align 1

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

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

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

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

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

7:                                                ; preds = %2
  br label %9

8:                                                ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.29, ptr noundef @.str.1, i64 noundef 1432, ptr noundef @__func__.ast_add_sibling)
  br label %9

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

12:                                               ; preds = %9
  br label %14

13:                                               ; preds = %9
  call void @ponyint_assert_fail(ptr noundef @.str.30, ptr noundef @.str.1, i64 noundef 1433, ptr noundef @__func__.ast_add_sibling)
  br label %14

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

18:                                               ; preds = %14
  br label %20

19:                                               ; preds = %14
  call void @ponyint_assert_fail(ptr noundef @.str.31, ptr noundef @.str.1, i64 noundef 1434, ptr noundef @__func__.ast_add_sibling)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call zeroext i1 @hasparent(ptr noundef %21)
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

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

25:                                               ; preds = %24, %23
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ast_t, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.ast_t, ptr %28, i32 0, i32 8
  %30 = load i8, ptr %29, align 4, !tbaa !13, !range !14, !noundef !15
  %31 = trunc i8 %30 to i1
  br i1 %31, label %33, label %32

32:                                               ; preds = %25
  br label %34

33:                                               ; preds = %25
  call void @ponyint_assert_fail(ptr noundef @.str.33, ptr noundef @.str.1, i64 noundef 1437, ptr noundef @__func__.ast_add_sibling)
  br label %34

34:                                               ; preds = %33, %32
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call zeroext i1 @hasparent(ptr noundef %35)
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call ptr @ast_dup(ptr noundef %38)
  store ptr %39, ptr %4, align 8, !tbaa !5
  br label %48

40:                                               ; preds = %34
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ast_t, ptr %41, i32 0, i32 8
  %43 = load i8, ptr %42, align 4, !tbaa !13, !range !14, !noundef !15
  %44 = trunc i8 %43 to i1
  br i1 %44, label %46, label %45

45:                                               ; preds = %40
  br label %47

46:                                               ; preds = %40
  call void @ponyint_assert_fail(ptr noundef @.str.34, ptr noundef @.str.1, i64 noundef 1444, ptr noundef @__func__.ast_add_sibling)
  br label %47

47:                                               ; preds = %46, %45
  br label %48

48:                                               ; preds = %47, %37
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ast_t, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  br label %55

54:                                               ; preds = %48
  call void @ponyint_assert_fail(ptr noundef @.str.35, ptr noundef @.str.1, i64 noundef 1447, ptr noundef @__func__.ast_add_sibling)
  br label %55

55:                                               ; preds = %54, %53
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ast_t, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  call void @set_scope_and_parent(ptr noundef %56, ptr noundef %59)
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ast_t, ptr %60, i32 0, i32 5
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ast_t, ptr %63, i32 0, i32 5
  store ptr %62, ptr %64, align 8, !tbaa !16
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.ast_t, ptr %66, i32 0, i32 5
  store ptr %65, ptr %67, align 8, !tbaa !16
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %68
}

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" }

!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, !6, i64 24}
!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 = !{!10, !12, i64 60}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !6, i64 40}


; 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.29 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.ast_add_sibling = external hidden unnamed_addr constant [16 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [29 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 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
define dso_local ptr @ast_add_sibling(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.29, ptr noundef nonnull @.str.1, i64 noundef 1432, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %4

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

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

6:                                                ; preds = %4, %5
  %.not18 = icmp eq ptr %0, %1
  br i1 %.not18, label %7, label %8

7:                                                ; preds = %6
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.31, ptr noundef nonnull @.str.1, i64 noundef 1434, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %8

8:                                                ; preds = %6, %7
  %9 = tail call zeroext i1 @hasparent(ptr noundef %0)
  br i1 %9, label %11, label %10

10:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.32, ptr noundef nonnull @.str.1, i64 noundef 1435, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %11

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

17:                                               ; preds = %11
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.33, ptr noundef nonnull @.str.1, i64 noundef 1437, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %18

18:                                               ; preds = %11, %17
  %19 = tail call zeroext i1 @hasparent(ptr noundef %1)
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call ptr @ast_dup(ptr noundef %1)
  br label %27

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

26:                                               ; preds = %22
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.1, i64 noundef 1444, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %27

27:                                               ; preds = %26, %22, %20
  %.0 = phi ptr [ %21, %20 ], [ %1, %26 ], [ %1, %22 ]
  %28 = getelementptr inbounds i8, ptr %.0, i64 40
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = icmp eq ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.35, ptr noundef nonnull @.str.1, i64 noundef 1447, ptr noundef nonnull @__func__.ast_add_sibling) #2
  br label %32

32:                                               ; preds = %27, %31
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  tail call void @set_scope_and_parent(ptr noundef nonnull %.0, ptr noundef %33)
  %34 = getelementptr inbounds i8, ptr %0, i64 40
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  store ptr %35, ptr %28, align 8, !tbaa !15
  store ptr %.0, ptr %34, align 8, !tbaa !15
  ret ptr %.0
}

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


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