; 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 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_remove = external hidden unnamed_addr constant [11 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.43 = 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 zeroext i1 @hasparent(ptr noundef) #2

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

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

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

6:                                                ; preds = %1
  br label %8

7:                                                ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 1532, ptr noundef @__func__.ast_remove)
  br label %8

8:                                                ; preds = %7, %6
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call zeroext i1 @hasparent(ptr noundef %9)
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  br label %13

12:                                               ; preds = %8
  call void @ponyint_assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i64 noundef 1533, ptr noundef @__func__.ast_remove)
  br label %13

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

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 1535, ptr noundef @__func__.ast_remove)
  br label %20

20:                                               ; preds = %19, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call ptr @ast_previous(ptr noundef %21)
  store ptr %22, ptr %3, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %38

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

30:                                               ; preds = %25
  br label %32

31:                                               ; preds = %25
  call void @ponyint_assert_fail(ptr noundef @.str.42, ptr noundef @.str.1, i64 noundef 1543, ptr noundef @__func__.ast_remove)
  br label %32

32:                                               ; preds = %31, %30
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ast_t, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ast_t, ptr %36, i32 0, i32 5
  store ptr %35, ptr %37, align 8, !tbaa !15
  br label %55

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

45:                                               ; preds = %38
  br label %47

46:                                               ; preds = %38
  call void @ponyint_assert_fail(ptr noundef @.str.43, ptr noundef @.str.1, i64 noundef 1548, ptr noundef @__func__.ast_remove)
  br label %47

47:                                               ; preds = %46, %45
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ast_t, ptr %48, i32 0, i32 5
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ast_t, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct.ast_t, ptr %53, i32 0, i32 4
  store ptr %50, ptr %54, align 8, !tbaa !17
  br label %55

55:                                               ; preds = %47, %32
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ast_t, ptr %56, i32 0, i32 3
  store ptr null, ptr %57, align 8, !tbaa !16
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ast_t, ptr %58, i32 0, i32 5
  store ptr null, ptr %59, align 8, !tbaa !15
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ast_free(ptr noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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 24}
!17 = !{!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 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_remove = external hidden unnamed_addr constant [11 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.43 = 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 zeroext i1 @hasparent(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @ast_free(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
define dso_local void @ast_remove(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

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

3:                                                ; preds = %1, %2
  %4 = tail call zeroext i1 @hasparent(ptr noundef %0)
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i64 noundef 1533, ptr noundef nonnull @__func__.ast_remove) #2
  br label %6

6:                                                ; preds = %3, %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.3, ptr noundef nonnull @.str.1, i64 noundef 1535, ptr noundef nonnull @__func__.ast_remove) #2
  br label %11

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

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

17:                                               ; preds = %13
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.42, ptr noundef nonnull @.str.1, i64 noundef 1543, ptr noundef nonnull @__func__.ast_remove) #2
  br label %18

18:                                               ; preds = %13, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %12, i64 40
  store ptr %20, ptr %21, align 8, !tbaa !14
  br label %34

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

28:                                               ; preds = %22
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.43, ptr noundef nonnull @.str.1, i64 noundef 1548, ptr noundef nonnull @__func__.ast_remove) #2
  %.pre = load ptr, ptr %23, align 8, !tbaa !15
  br label %29

29:                                               ; preds = %22, %28
  %30 = phi ptr [ %24, %22 ], [ %.pre, %28 ]
  %31 = getelementptr inbounds i8, ptr %0, i64 40
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %30, i64 32
  store ptr %32, ptr %33, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %29, %18
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %35, align 8, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr null, ptr %36, align 8, !tbaa !14
  tail call void @ast_free(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 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 32}


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