; 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.25 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_append = external hidden unnamed_addr constant [11 x i8], align 1
@.str.36 = 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 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
define dso_local ptr @ast_append(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 %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %4, 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.24, ptr noundef @.str.1, i64 noundef 1476, ptr noundef @__func__.ast_append)
  br label %11

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

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11
  call void @ponyint_assert_fail(ptr noundef @.str.36, ptr noundef @.str.1, i64 noundef 1477, ptr noundef @__func__.ast_append)
  br label %16

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

20:                                               ; preds = %16
  br label %22

21:                                               ; preds = %16
  call void @ponyint_assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i64 noundef 1478, ptr noundef @__func__.ast_append)
  br label %22

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

27:                                               ; preds = %22
  br label %29

28:                                               ; preds = %22
  call void @ponyint_assert_fail(ptr noundef @.str.27, ptr noundef @.str.1, i64 noundef 1480, ptr noundef @__func__.ast_append)
  br label %29

29:                                               ; preds = %28, %27
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call zeroext i1 @hasparent(ptr noundef %30)
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @ast_dup(ptr noundef %33)
  store ptr %34, ptr %5, align 8, !tbaa !5
  br label %43

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

40:                                               ; preds = %35
  br label %42

41:                                               ; preds = %35
  call void @ponyint_assert_fail(ptr noundef @.str.28, ptr noundef @.str.1, i64 noundef 1487, ptr noundef @__func__.ast_append)
  br label %42

42:                                               ; preds = %41, %40
  br label %43

43:                                               ; preds = %42, %32
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @set_scope_and_parent(ptr noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ast_t, ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %55

50:                                               ; preds = %43
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ast_t, ptr %52, i32 0, i32 4
  store ptr %51, ptr %53, align 8, !tbaa !15
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %54, ptr %3, align 8
  br label %73

55:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ast_t, ptr %56, i32 0, i32 4
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  store ptr %58, ptr %6, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %64, %55
  %60 = load ptr, ptr %6, 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 = icmp ne ptr %62, null
  br i1 %63, label %64, label %68

64:                                               ; preds = %59
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ast_t, ptr %65, i32 0, i32 5
  %67 = load ptr, ptr %66, align 8, !tbaa !16
  store ptr %67, ptr %6, align 8, !tbaa !5
  br label %59, !llvm.loop !17

68:                                               ; preds = %59
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ast_t, ptr %70, i32 0, i32 5
  store ptr %69, ptr %71, align 8, !tbaa !16
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %72, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %73

73:                                               ; preds = %68, %50
  %74 = load ptr, ptr %3, align 8
  ret ptr %74
}

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 32}
!16 = !{!10, !6, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"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.25 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_append = external hidden unnamed_addr constant [11 x i8], align 1
@.str.36 = 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 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 noundef ptr @ast_append(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.24, ptr noundef nonnull @.str.1, i64 noundef 1476, ptr noundef nonnull @__func__.ast_append) #2
  br label %4

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

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

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

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

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

12:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.1, i64 noundef 1480, ptr noundef nonnull @__func__.ast_append) #2
  br label %13

13:                                               ; preds = %8, %12
  %14 = tail call zeroext i1 @hasparent(ptr noundef %1)
  br i1 %14, label %15, label %17

15:                                               ; preds = %13
  %16 = tail call ptr @ast_dup(ptr noundef %1)
  br label %22

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %1, i64 60
  %19 = load i8, ptr %18, align 4, !tbaa !5, !range !12, !noundef !13
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.1, i64 noundef 1487, ptr noundef nonnull @__func__.ast_append) #2
  br label %22

22:                                               ; preds = %21, %17, %15
  %.021 = phi ptr [ %16, %15 ], [ %1, %21 ], [ %1, %17 ]
  tail call void @set_scope_and_parent(ptr noundef %.021, ptr noundef nonnull %0)
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = icmp eq ptr %24, null
  br i1 %25, label %30, label %.preheader

.preheader:                                       ; preds = %22, %.preheader
  %.0 = phi ptr [ %27, %.preheader ], [ %24, %22 ]
  %26 = getelementptr inbounds i8, ptr %.0, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %.not27 = icmp eq ptr %27, null
  br i1 %.not27, label %28, label %.preheader, !llvm.loop !16

28:                                               ; preds = %.preheader
  %29 = getelementptr inbounds i8, ptr %.0, i64 40
  br label %30

30:                                               ; preds = %22, %28
  %.sink = phi ptr [ %29, %28 ], [ %23, %22 ]
  store ptr %.021, ptr %.sink, align 8, !tbaa !18
  ret ptr %.021
}

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 32}
!15 = !{!6, !7, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass