; LLVM IR from ponylang/ponyc :: src/libponyc/expr (call)

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

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

declare ptr @ast_type(ptr noundef) #1

declare zeroext i1 @is_typecheck_error(ptr noundef) #1

declare i32 @ast_id(ptr noundef) #1

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

declare void @ast_free_unattached(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @check_auto_recover_newref(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [4 x ptr], align 16
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i32 @ast_id(ptr noundef %16)
  %18 = icmp ne i32 %17, 151
  br i1 %18, label %19, label %20

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %91

20:                                               ; preds = %2
  br label %21

21:                                               ; preds = %30, %20
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call i32 @ast_id(ptr noundef %25)
  %27 = icmp ne i32 %26, 177
  br label %28

28:                                               ; preds = %24, %21
  %29 = phi i1 [ false, %21 ], [ %27, %24 ]
  br i1 %29, label %30, label %33

30:                                               ; preds = %28
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call ptr @ast_child(ptr noundef %31)
  store ptr %32, ptr %5, align 8, !tbaa !5
  br label %21, !llvm.loop !9

33:                                               ; preds = %28
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  store i1 false, ptr %3, align 1
  br label %91

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #3
  store ptr %6, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %9, i64 1
  store ptr %7, ptr %38, align 8, !tbaa !5
  %39 = getelementptr inbounds ptr, ptr %9, i64 2
  store ptr %8, ptr %39, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %9, i64 3
  store ptr null, ptr %40, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 0
  call void @ast_get_children(ptr noundef %41, i64 noundef 3, ptr noundef %42)
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #3
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = call i32 @ast_id(ptr noundef %43)
  %45 = icmp ne i32 %44, 188
  br i1 %45, label %46, label %47

46:                                               ; preds = %37
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %90

47:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call ptr @ast_child(ptr noundef %48)
  store ptr %49, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %58

52:                                               ; preds = %47
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = call i32 @ast_id(ptr noundef %53)
  %55 = icmp eq i32 %54, 188
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %57, ptr %6, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %56, %52, %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = call ptr @ast_child(ptr noundef %59)
  store ptr %60, ptr %12, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %87, %58
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %88

64:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = call ptr @ast_type(ptr noundef %65)
  store ptr %66, ptr %13, align 8, !tbaa !5
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = call zeroext i1 @is_typecheck_error(ptr noundef %67)
  br i1 %68, label %69, label %70

69:                                               ; preds = %64
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %85

70:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = call ptr @alias(ptr noundef %71)
  store ptr %72, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = call zeroext i1 @safe_to_autorecover(ptr noundef %73, ptr noundef %74, i32 noundef 0)
  %76 = zext i1 %75 to i8
  store i8 %76, ptr %15, align 1, !tbaa !11
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  call void @ast_free_unattached(ptr noundef %77)
  %78 = load i8, ptr %15, align 1, !tbaa !11, !range !13, !noundef !14
  %79 = trunc i8 %78 to i1
  br i1 %79, label %81, label %80

80:                                               ; preds = %70
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %84

81:                                               ; preds = %70
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = call ptr @ast_sibling(ptr noundef %82)
  store ptr %83, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %84

84:                                               ; preds = %81, %80
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %85

85:                                               ; preds = %84, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %86 = load i32, ptr %10, align 4
  switch i32 %86, label %89 [
    i32 0, label %87
  ]

87:                                               ; preds = %85
  br label %61, !llvm.loop !15

88:                                               ; preds = %61
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %89

89:                                               ; preds = %88, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %90

90:                                               ; preds = %89, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %91

91:                                               ; preds = %90, %36, %19
  %92 = load i1, ptr %3, align 1
  ret i1 %92
}

declare ptr @ast_child(ptr noundef) #1

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

declare ptr @alias(ptr noundef) #1

declare zeroext i1 @safe_to_autorecover(ptr noundef, ptr noundef, i32 noundef) #1

declare ptr @ast_sibling(ptr noundef) #1

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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}


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

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

declare ptr @ast_type(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @is_typecheck_error(ptr noundef) local_unnamed_addr #1

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.end.p0(i64 immarg, ptr nocapture) #0

declare void @ast_free_unattached(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @check_auto_recover_newref(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [4 x ptr], align 16
  %7 = tail call i32 @ast_id(ptr noundef %0) #3
  %.not = icmp ne i32 %7, 151
  %cond3136 = icmp eq ptr %1, null
  %or.cond = or i1 %.not, %cond3136
  br i1 %or.cond, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2, %9
  %.01937 = phi ptr [ %10, %9 ], [ %1, %2 ]
  %8 = tail call i32 @ast_id(ptr noundef nonnull %.01937) #3
  %.not27 = icmp eq i32 %8, 177
  br i1 %.not27, label %.critedge, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @ast_child(ptr noundef nonnull %.01937) #3
  %cond31 = icmp eq ptr %10, null
  br i1 %cond31, label %.loopexit, label %.lr.ph, !llvm.loop !5

.critedge:                                        ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  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 32, ptr nonnull %6) #3
  store ptr %3, ptr %6, align 16, !tbaa !7
  %11 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %4, ptr %11, align 8, !tbaa !7
  %12 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %5, ptr %12, align 16, !tbaa !7
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr null, ptr %13, align 8, !tbaa !7
  call void @ast_get_children(ptr noundef nonnull %.01937, i64 noundef 3, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !7
  %15 = call i32 @ast_id(ptr noundef %14) #3
  %.not28 = icmp eq i32 %15, 188
  br i1 %.not28, label %16, label %.thread

16:                                               ; preds = %.critedge
  %17 = load ptr, ptr %3, align 8, !tbaa !7
  %18 = call ptr @ast_child(ptr noundef %17) #3
  %.not29 = icmp eq ptr %18, null
  br i1 %.not29, label %23, label %19

19:                                               ; preds = %16
  %20 = call i32 @ast_id(ptr noundef nonnull %18) #3
  %21 = icmp eq i32 %20, 188
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store ptr %18, ptr %3, align 8, !tbaa !7
  br label %23

23:                                               ; preds = %22, %19, %16
  %24 = load ptr, ptr %4, align 8, !tbaa !7
  %25 = call ptr @ast_child(ptr noundef %24) #3
  %.not3038 = icmp eq ptr %25, null
  br i1 %.not3038, label %.thread, label %.lr.ph40

.lr.ph40:                                         ; preds = %23, %31
  %.02239 = phi ptr [ %32, %31 ], [ %25, %23 ]
  %26 = call ptr @ast_type(ptr noundef nonnull %.02239) #3
  %27 = call zeroext i1 @is_typecheck_error(ptr noundef %26) #3
  br i1 %27, label %.thread, label %28

28:                                               ; preds = %.lr.ph40
  %29 = call ptr @alias(ptr noundef %26) #3
  %30 = call zeroext i1 @safe_to_autorecover(ptr noundef %0, ptr noundef %29, i32 noundef 0) #3
  call void @ast_free_unattached(ptr noundef %29) #3
  br i1 %30, label %31, label %.thread

31:                                               ; preds = %28
  %32 = call ptr @ast_sibling(ptr noundef nonnull %.02239) #3
  %.not30 = icmp eq ptr %32, null
  br i1 %.not30, label %.thread, label %.lr.ph40, !llvm.loop !11

.thread:                                          ; preds = %31, %.lr.ph40, %28, %23, %.critedge
  %.4 = phi i1 [ false, %.critedge ], [ true, %23 ], [ true, %31 ], [ false, %.lr.ph40 ], [ false, %28 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %.loopexit

.loopexit:                                        ; preds = %9, %2, %.thread
  %.5 = phi i1 [ %.4, %.thread ], [ false, %2 ], [ false, %9 ]
  ret i1 %.5
}

declare ptr @ast_child(ptr noundef) local_unnamed_addr #1

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

declare ptr @alias(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @safe_to_autorecover(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}


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