; 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
@__func__.setannotation = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [24 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 ptr @duplicate(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_annotation(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 void @setannotation(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %6, align 1, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 879, ptr noundef @__func__.setannotation)
  br label %14

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

19:                                               ; preds = %14
  br label %21

20:                                               ; preds = %14
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 881, ptr noundef @__func__.setannotation)
  br label %21

21:                                               ; preds = %20, %19
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call i32 @ast_id(ptr noundef %22)
  %24 = icmp eq i32 %23, 205
  br i1 %24, label %25, label %31

25:                                               ; preds = %21
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @ponyint_assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i64 noundef 886, ptr noundef @__func__.setannotation)
  br label %30

30:                                               ; preds = %29, %28
  br label %31

31:                                               ; preds = %30, %21
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %41

34:                                               ; preds = %31
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i32 @ast_id(ptr noundef %35)
  %37 = icmp eq i32 %36, 205
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  br label %40

39:                                               ; preds = %34
  call void @ponyint_assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i64 noundef 890, ptr noundef @__func__.setannotation)
  br label %40

40:                                               ; preds = %39, %38
  br label %41

41:                                               ; preds = %40, %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = call ptr @ast_annotation(ptr noundef %42)
  store ptr %43, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = icmp eq ptr %44, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %41
  store i32 1, ptr %8, align 4
  br label %107

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

51:                                               ; preds = %48
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ast_t, ptr %52, i32 0, i32 6
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %51
  br label %58

57:                                               ; preds = %51
  call void @ponyint_assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i64 noundef 898, ptr noundef @__func__.setannotation)
  br label %58

58:                                               ; preds = %57, %56
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call zeroext i1 @hasparent(ptr noundef %59)
  br i1 %60, label %61, label %65

61:                                               ; preds = %58
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = call ptr @duplicate(ptr noundef %62, ptr noundef %63)
  store ptr %64, ptr %5, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %61, %58
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %76

68:                                               ; preds = %65
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ast_t, ptr %69, i32 0, i32 6
  %71 = load ptr, ptr %70, align 8, !tbaa !16
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ast_t, ptr %72, i32 0, i32 6
  store ptr %71, ptr %73, align 8, !tbaa !16
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ast_t, ptr %74, i32 0, i32 6
  store ptr null, ptr %75, align 8, !tbaa !16
  br label %82

76:                                               ; preds = %65
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ast_t, ptr %77, i32 0, i32 6
  %79 = load ptr, ptr %78, align 8, !tbaa !16
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ast_t, ptr %80, i32 0, i32 6
  store ptr %79, ptr %81, align 8, !tbaa !16
  br label %82

82:                                               ; preds = %76, %68
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ast_t, ptr %84, i32 0, i32 6
  store ptr %83, ptr %85, align 8, !tbaa !16
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  call void @set_scope_and_parent(ptr noundef %86, ptr noundef %87)
  br label %101

88:                                               ; preds = %48
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %88
  br label %93

92:                                               ; preds = %88
  call void @ponyint_assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i64 noundef 915, ptr noundef @__func__.setannotation)
  br label %93

93:                                               ; preds = %92, %91
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.ast_t, ptr %94, i32 0, i32 6
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ast_t, ptr %97, i32 0, i32 6
  store ptr %96, ptr %98, align 8, !tbaa !16
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.ast_t, ptr %99, i32 0, i32 6
  store ptr null, ptr %100, align 8, !tbaa !16
  br label %101

101:                                              ; preds = %93, %82
  %102 = load i8, ptr %6, align 1, !tbaa !9, !range !14, !noundef !15
  %103 = trunc i8 %102 to i1
  br i1 %103, label %104, label %106

104:                                              ; preds = %101
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ast_free(ptr noundef %105)
  br label %106

106:                                              ; preds = %104, %101
  store i32 0, ptr %8, align 4
  br label %107

107:                                              ; preds = %106, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %108 = load i32, ptr %8, align 4
  switch i32 %108, label %110 [
    i32 0, label %109
    i32 1, label %109
  ]

109:                                              ; preds = %107, %107
  ret void

110:                                              ; preds = %107
  unreachable
}

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

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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !10, i64 60}
!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, !10, i64 60}
!13 = !{!"int", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !6, i64 48}


; 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
@__func__.setannotation = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [36 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 ptr @duplicate(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_annotation(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 void @setannotation(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %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, ptr noundef nonnull @.str.1, i64 noundef 879, ptr noundef nonnull @__func__.setannotation) #2
  br label %5

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

9:                                                ; preds = %5
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 881, ptr noundef nonnull @__func__.setannotation) #2
  br label %10

10:                                               ; preds = %5, %9
  %11 = tail call i32 @ast_id(ptr noundef nonnull %0)
  %12 = icmp ne i32 %11, 205
  %13 = icmp eq ptr %1, null
  %or.cond = or i1 %13, %12
  br i1 %or.cond, label %14, label %.thread

.thread:                                          ; preds = %10
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i64 noundef 886, ptr noundef nonnull @__func__.setannotation) #2
  br label %15

14:                                               ; preds = %10
  br i1 %13, label %.thread35, label %15

15:                                               ; preds = %.thread, %14
  %16 = tail call i32 @ast_id(ptr noundef nonnull %1)
  %17 = icmp eq i32 %16, 205
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i64 noundef 890, ptr noundef nonnull @__func__.setannotation) #2
  br label %19

19:                                               ; preds = %18, %15
  %20 = tail call ptr @ast_annotation(ptr noundef nonnull %0)
  %21 = icmp eq ptr %20, %1
  br i1 %21, label %49, label %24

.thread35:                                        ; preds = %14
  %22 = tail call ptr @ast_annotation(ptr noundef nonnull %0)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %49, label %.thread36

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %1, i64 48
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = icmp eq ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i64 noundef 898, ptr noundef nonnull @__func__.setannotation) #2
  br label %29

29:                                               ; preds = %24, %28
  %30 = tail call zeroext i1 @hasparent(ptr noundef nonnull %1)
  br i1 %30, label %31, label %33

31:                                               ; preds = %29
  %32 = tail call ptr @duplicate(ptr noundef nonnull %0, ptr noundef nonnull %1)
  br label %33

33:                                               ; preds = %31, %29
  %.0 = phi ptr [ %32, %31 ], [ %1, %29 ]
  %.not34 = icmp eq ptr %20, null
  %34 = getelementptr inbounds i8, ptr %.0, i64 48
  br i1 %.not34, label %38, label %35

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %20, i64 48
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  store ptr %37, ptr %34, align 8, !tbaa !14
  store ptr null, ptr %36, align 8, !tbaa !14
  br label %41

38:                                               ; preds = %33
  %39 = getelementptr inbounds i8, ptr %0, i64 48
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  store ptr %40, ptr %34, align 8, !tbaa !14
  br label %41

41:                                               ; preds = %38, %35
  %42 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %.0, ptr %42, align 8, !tbaa !14
  tail call void @set_scope_and_parent(ptr noundef nonnull %.0, ptr noundef nonnull %0)
  br label %46

.thread36:                                        ; preds = %.thread35
  %43 = getelementptr inbounds i8, ptr %22, i64 48
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %44, ptr %45, align 8, !tbaa !14
  store ptr null, ptr %43, align 8, !tbaa !14
  br label %46

46:                                               ; preds = %.thread36, %41
  %47 = phi ptr [ %22, %.thread36 ], [ %20, %41 ]
  br i1 %2, label %48, label %49

48:                                               ; preds = %46
  tail call void @ast_free(ptr noundef %47)
  br label %49

49:                                               ; preds = %.thread35, %46, %48, %19
  ret void
}

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

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


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