; LLVM IR from ponylang/ponyc :: src/libponyc/type (safeto)

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

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.safe_to_move = external hidden unnamed_addr constant [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @safe_to_move(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [3 x ptr], align 16
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 @ast_id(ptr noundef %17)
  switch i32 %18, label %87 [
    i32 84, label %19
    i32 85, label %19
    i32 196, label %19
    i32 87, label %19
    i32 199, label %19
    i32 195, label %20
    i32 192, label %21
    i32 193, label %21
    i32 194, label %21
    i32 178, label %49
    i32 175, label %81
  ]

19:                                               ; preds = %3, %3, %3, %3, %3
  store i1 true, ptr %4, align 1
  br label %89

20:                                               ; preds = %3
  store i1 true, ptr %4, align 1
  br label %89

21:                                               ; preds = %3, %3, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  store ptr %8, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds ptr, ptr %10, i64 1
  store ptr %9, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds ptr, ptr %10, i64 2
  store ptr null, ptr %23, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds [3 x ptr], ptr %10, i64 0, i64 0
  call void @ast_get_children(ptr noundef %24, i64 noundef 2, ptr noundef %25)
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call ptr @ast_type(ptr noundef %26)
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = call i32 @ast_id(ptr noundef %28)
  %30 = icmp ne i32 %29, 151
  br i1 %30, label %31, label %32

31:                                               ; preds = %21
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %48

32:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = call i32 @cap_single(ptr noundef %33)
  store i32 %34, ptr %13, align 4, !tbaa !9
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = call zeroext i1 @safe_field_move(i32 noundef %35, ptr noundef %36, i32 noundef %37)
  br i1 %38, label %39, label %40

39:                                               ; preds = %32
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %47

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = call ptr @ast_type(ptr noundef %41)
  store ptr %42, ptr %14, align 8, !tbaa !5
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = load ptr, ptr %14, align 8, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = call zeroext i1 @safe_field_move(i32 noundef %43, ptr noundef %44, i32 noundef %45)
  store i1 %46, ptr %4, align 1
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %47

47:                                               ; preds = %40, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %48

48:                                               ; preds = %47, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %89

49:                                               ; preds = %3
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call i32 @ast_id(ptr noundef %50)
  %52 = icmp eq i32 %51, 150
  br i1 %52, label %53, label %54

53:                                               ; preds = %49
  br label %55

54:                                               ; preds = %49
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 97, ptr noundef @__func__.safe_to_move)
  br label %55

55:                                               ; preds = %54, %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call ptr @ast_child(ptr noundef %56)
  store ptr %57, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call ptr @ast_child(ptr noundef %58)
  store ptr %59, ptr %16, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %69, %55
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %74

63:                                               ; preds = %60
  %64 = load ptr, ptr %15, align 8, !tbaa !5
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = call zeroext i1 @safe_to_move(ptr noundef %64, ptr noundef %65, i32 noundef %66)
  br i1 %67, label %69, label %68

68:                                               ; preds = %63
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %80

69:                                               ; preds = %63
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = call ptr @ast_sibling(ptr noundef %70)
  store ptr %71, ptr %15, align 8, !tbaa !5
  %72 = load ptr, ptr %16, align 8, !tbaa !5
  %73 = call ptr @ast_sibling(ptr noundef %72)
  store ptr %73, ptr %16, align 8, !tbaa !5
  br label %60, !llvm.loop !11

74:                                               ; preds = %60
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  %76 = icmp eq ptr %75, null
  br i1 %76, label %77, label %78

77:                                               ; preds = %74
  br label %79

78:                                               ; preds = %74
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 110, ptr noundef @__func__.safe_to_move)
  br label %79

79:                                               ; preds = %78, %77
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %80

80:                                               ; preds = %79, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %89

81:                                               ; preds = %3
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = call ptr @ast_child(ptr noundef %82)
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = call zeroext i1 @safe_to_move(ptr noundef %83, ptr noundef %84, i32 noundef %85)
  store i1 %86, ptr %4, align 1
  br label %89

87:                                               ; preds = %3
  br label %88

88:                                               ; preds = %87
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 125, ptr noundef @__func__.safe_to_move)
  store i1 false, ptr %4, align 1
  br label %89

89:                                               ; preds = %88, %81, %80, %48, %20, %19
  %90 = load i1, ptr %4, align 1
  ret i1 %90
}

declare i32 @ast_id(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare void @ast_get_children(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare ptr @ast_type(ptr noundef) #1

declare i32 @cap_single(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @safe_field_move(i32 noundef, ptr noundef, i32 noundef) #0

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

declare ptr @ast_child(ptr noundef) #1

declare ptr @ast_sibling(ptr noundef) #1

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.safe_to_move = external hidden unnamed_addr constant [13 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @safe_to_move(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [3 x ptr], align 16
  br label %tailrecurse

tailrecurse:                                      ; preds = %35, %3
  %.tr = phi ptr [ %0, %3 ], [ %36, %35 ]
  %7 = tail call i32 @ast_id(ptr noundef %.tr) #3
  switch i32 %7, label %37 [
    i32 84, label %.loopexit
    i32 85, label %.loopexit
    i32 196, label %.loopexit
    i32 87, label %.loopexit
    i32 199, label %.loopexit
    i32 195, label %.loopexit
    i32 192, label %8
    i32 193, label %8
    i32 194, label %8
    i32 178, label %22
    i32 175, label %35
  ]

8:                                                ; preds = %tailrecurse, %tailrecurse, %tailrecurse
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  store ptr %4, ptr %6, align 16, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %5, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr null, ptr %10, align 16, !tbaa !5
  call void @ast_get_children(ptr noundef %.tr, i64 noundef 2, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call ptr @ast_type(ptr noundef %11) #3
  %13 = call i32 @ast_id(ptr noundef %12) #3
  %.not25 = icmp eq i32 %13, 151
  br i1 %.not25, label %14, label %21

14:                                               ; preds = %8
  %15 = call i32 @cap_single(ptr noundef %12) #3
  %16 = call zeroext i1 @safe_field_move(i32 noundef %15, ptr noundef %1, i32 noundef %2)
  br i1 %16, label %21, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call ptr @ast_type(ptr noundef %18) #3
  %20 = call zeroext i1 @safe_field_move(i32 noundef %15, ptr noundef %19, i32 noundef %2)
  br label %21

21:                                               ; preds = %17, %14, %8
  %.1 = phi i1 [ false, %8 ], [ %20, %17 ], [ true, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  br label %.loopexit

22:                                               ; preds = %tailrecurse
  %23 = tail call i32 @ast_id(ptr noundef %1) #3
  %24 = icmp eq i32 %23, 150
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 97, ptr noundef nonnull @__func__.safe_to_move) #3
  br label %26

26:                                               ; preds = %22, %25
  %27 = tail call ptr @ast_child(ptr noundef %.tr) #3
  %28 = tail call ptr @ast_child(ptr noundef %1) #3
  %.not33 = icmp eq ptr %27, null
  br i1 %.not33, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %26, %30
  %.035 = phi ptr [ %32, %30 ], [ %28, %26 ]
  %.02334 = phi ptr [ %31, %30 ], [ %27, %26 ]
  %29 = tail call zeroext i1 @safe_to_move(ptr noundef nonnull %.02334, ptr noundef %.035, i32 noundef %2)
  br i1 %29, label %30, label %.loopexit

30:                                               ; preds = %.lr.ph
  %31 = tail call ptr @ast_sibling(ptr noundef nonnull %.02334) #3
  %32 = tail call ptr @ast_sibling(ptr noundef %.035) #3
  %.not = icmp eq ptr %31, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %30, %26
  %.0.lcssa = phi ptr [ %28, %26 ], [ %32, %30 ]
  %33 = icmp eq ptr %.0.lcssa, null
  br i1 %33, label %.loopexit, label %34

34:                                               ; preds = %._crit_edge
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 110, ptr noundef nonnull @__func__.safe_to_move) #3
  br label %.loopexit

35:                                               ; preds = %tailrecurse
  %36 = tail call ptr @ast_child(ptr noundef %.tr) #3
  br label %tailrecurse

37:                                               ; preds = %tailrecurse
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 125, ptr noundef nonnull @__func__.safe_to_move) #3
  br label %.loopexit

.loopexit:                                        ; preds = %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %.lr.ph, %._crit_edge, %34, %37, %21
  %.3 = phi i1 [ false, %37 ], [ %.1, %21 ], [ true, %34 ], [ true, %._crit_edge ], [ false, %.lr.ph ], [ true, %tailrecurse ], [ true, %tailrecurse ], [ true, %tailrecurse ], [ true, %tailrecurse ], [ true, %tailrecurse ], [ true, %tailrecurse ]
  ret i1 %.3
}

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare void @ast_get_children(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare ptr @ast_type(ptr noundef) local_unnamed_addr #1

declare i32 @cap_single(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @safe_field_move(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_child(ptr noundef) local_unnamed_addr #1

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass