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

; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.is_result_needed = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_result_needed(ptr noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call ptr @ast_parent(ptr noundef %9)
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call i32 @ast_id(ptr noundef %11)
  switch i32 %12, label %98 [
    i32 175, label %13
    i32 108, label %21
    i32 109, label %21
    i32 116, label %21
    i32 122, label %21
    i32 110, label %30
    i32 118, label %44
    i32 181, label %53
    i32 180, label %62
    i32 111, label %62
    i32 124, label %62
    i32 125, label %62
    i32 107, label %62
    i32 206, label %62
    i32 88, label %65
    i32 90, label %88
    i32 203, label %89
    i32 204, label %89
  ]

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call ptr @ast_sibling(ptr noundef %14)
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

18:                                               ; preds = %13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call zeroext i1 @is_result_needed(ptr noundef %19)
  store i1 %20, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

21:                                               ; preds = %1, %1, %1, %1
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call ptr @ast_child(ptr noundef %22)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

27:                                               ; preds = %21
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call zeroext i1 @is_result_needed(ptr noundef %28)
  store i1 %29, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

30:                                               ; preds = %1
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call ptr @ast_child(ptr noundef %31)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = icmp eq ptr %32, %33
  br i1 %34, label %40, label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call ptr @ast_childidx(ptr noundef %36, i64 noundef 1)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = icmp eq ptr %37, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %35, %30
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

41:                                               ; preds = %35
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = call zeroext i1 @is_result_needed(ptr noundef %42)
  store i1 %43, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

44:                                               ; preds = %1
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call ptr @ast_childidx(ptr noundef %45, i64 noundef 1)
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = icmp eq ptr %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

50:                                               ; preds = %44
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = call zeroext i1 @is_result_needed(ptr noundef %51)
  store i1 %52, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

53:                                               ; preds = %1
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call ptr @ast_childidx(ptr noundef %54, i64 noundef 2)
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = icmp ne ptr %55, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

59:                                               ; preds = %53
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = call zeroext i1 @is_result_needed(ptr noundef %60)
  store i1 %61, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

62:                                               ; preds = %1, %1, %1, %1, %1, %1
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = call zeroext i1 @is_result_needed(ptr noundef %63)
  store i1 %64, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

65:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = call ptr @ast_childidx(ptr noundef %66, i64 noundef 4)
  store ptr %67, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call i32 @ast_id(ptr noundef %68)
  %70 = icmp eq i32 %69, 151
  br i1 %70, label %71, label %72

71:                                               ; preds = %65
  br label %73

72:                                               ; preds = %65
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 96, ptr noundef @__func__.is_result_needed)
  br label %73

73:                                               ; preds = %72, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = call ptr @ast_child(ptr noundef %74)
  %76 = call ptr @ast_name(ptr noundef %75)
  store ptr %76, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = call ptr @ast_childidx(ptr noundef %77, i64 noundef 1)
  %79 = call ptr @ast_name(ptr noundef %78)
  store ptr %79, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = call ptr @stringtab(ptr noundef @.str.2)
  %82 = icmp eq ptr %80, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %73
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = call zeroext i1 @is_numeric_primitive(ptr noundef %84)
  store i1 %85, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %87

86:                                               ; preds = %73
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %87

87:                                               ; preds = %86, %83
  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 %100

88:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

89:                                               ; preds = %1, %1
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = call ptr @ast_childidx(ptr noundef %90, i64 noundef 0)
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = icmp eq ptr %91, %92
  br i1 %93, label %94, label %97

94:                                               ; preds = %89
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = call zeroext i1 @is_result_needed(ptr noundef %95)
  store i1 %96, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

97:                                               ; preds = %89
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

98:                                               ; preds = %1
  br label %99

99:                                               ; preds = %98
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %100

100:                                              ; preds = %99, %97, %94, %88, %87, %62, %59, %58, %50, %49, %41, %40, %27, %26, %18, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %101 = load i1, ptr %2, align 1
  ret i1 %101
}

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

declare ptr @ast_parent(ptr noundef) #2

declare i32 @ast_id(ptr noundef) #2

declare ptr @ast_sibling(ptr noundef) #2

declare ptr @ast_child(ptr noundef) #2

declare ptr @ast_childidx(ptr noundef, i64 noundef) #2

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

declare ptr @ast_name(ptr noundef) #2

declare ptr @stringtab(ptr noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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"}


; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.is_result_needed = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @is_result_needed(ptr noundef %0) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %1
  %.tr = phi ptr [ %0, %1 ], [ %2, %tailrecurse.backedge ]
  %2 = tail call ptr @ast_parent(ptr noundef %.tr) #2
  %3 = tail call i32 @ast_id(ptr noundef %2) #2
  switch i32 %3, label %.loopexit [
    i32 175, label %4
    i32 108, label %6
    i32 109, label %6
    i32 116, label %6
    i32 122, label %6
    i32 110, label %9
    i32 118, label %15
    i32 181, label %18
    i32 180, label %tailrecurse.backedge
    i32 111, label %tailrecurse.backedge
    i32 124, label %tailrecurse.backedge
    i32 125, label %tailrecurse.backedge
    i32 107, label %tailrecurse.backedge
    i32 206, label %tailrecurse.backedge
    i32 88, label %20
    i32 90, label %.loopexit.loopexit
    i32 203, label %34
    i32 204, label %34
  ]

tailrecurse.backedge:                             ; preds = %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse, %4, %6, %12, %15, %18, %34
  br label %tailrecurse

4:                                                ; preds = %tailrecurse
  %5 = tail call ptr @ast_sibling(ptr noundef %.tr) #2
  %.not30 = icmp eq ptr %5, null
  br i1 %.not30, label %tailrecurse.backedge, label %.loopexit

6:                                                ; preds = %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse
  %7 = tail call ptr @ast_child(ptr noundef %2) #2
  %8 = icmp eq ptr %7, %.tr
  br i1 %8, label %.loopexit, label %tailrecurse.backedge

9:                                                ; preds = %tailrecurse
  %10 = tail call ptr @ast_child(ptr noundef %2) #2
  %11 = icmp eq ptr %10, %.tr
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %9
  %13 = tail call ptr @ast_childidx(ptr noundef %2, i64 noundef 1) #2
  %14 = icmp eq ptr %13, %.tr
  br i1 %14, label %.loopexit, label %tailrecurse.backedge

15:                                               ; preds = %tailrecurse
  %16 = tail call ptr @ast_childidx(ptr noundef %2, i64 noundef 1) #2
  %17 = icmp eq ptr %16, %.tr
  br i1 %17, label %.loopexit, label %tailrecurse.backedge

18:                                               ; preds = %tailrecurse
  %19 = tail call ptr @ast_childidx(ptr noundef %2, i64 noundef 2) #2
  %.not = icmp eq ptr %19, %.tr
  br i1 %.not, label %tailrecurse.backedge, label %.loopexit

20:                                               ; preds = %tailrecurse
  %21 = tail call ptr @ast_childidx(ptr noundef %2, i64 noundef 4) #2
  %22 = tail call i32 @ast_id(ptr noundef %21) #2
  %23 = icmp eq i32 %22, 151
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 96, ptr noundef nonnull @__func__.is_result_needed) #2
  br label %25

25:                                               ; preds = %20, %24
  %26 = tail call ptr @ast_child(ptr noundef %21) #2
  %27 = tail call ptr @ast_name(ptr noundef %26) #2
  %28 = tail call ptr @ast_childidx(ptr noundef %21, i64 noundef 1) #2
  %29 = tail call ptr @ast_name(ptr noundef %28) #2
  %30 = tail call ptr @stringtab(ptr noundef nonnull @.str.2) #2
  %31 = icmp eq ptr %27, %30
  br i1 %31, label %32, label %.loopexit

32:                                               ; preds = %25
  %33 = tail call zeroext i1 @is_numeric_primitive(ptr noundef %29)
  br label %.loopexit

34:                                               ; preds = %tailrecurse, %tailrecurse
  %35 = tail call ptr @ast_childidx(ptr noundef %2, i64 noundef 0) #2
  %36 = icmp eq ptr %35, %.tr
  br i1 %36, label %tailrecurse.backedge, label %.loopexit

.loopexit.loopexit:                               ; preds = %tailrecurse
  br label %.loopexit

.loopexit:                                        ; preds = %34, %18, %15, %9, %12, %6, %4, %tailrecurse, %.loopexit.loopexit, %32, %25
  %.1 = phi i1 [ %33, %32 ], [ false, %25 ], [ true, %tailrecurse ], [ false, %34 ], [ true, %18 ], [ true, %15 ], [ false, %9 ], [ false, %12 ], [ true, %6 ], [ false, %4 ], [ false, %.loopexit.loopexit ]
  ret i1 %.1
}

declare ptr @ast_parent(ptr noundef) local_unnamed_addr #1

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #1

declare ptr @ast_child(ptr noundef) local_unnamed_addr #1

declare ptr @ast_childidx(ptr noundef, i64 noundef) local_unnamed_addr #1

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

declare ptr @ast_name(ptr noundef) local_unnamed_addr #1

declare ptr @stringtab(ptr noundef) local_unnamed_addr #1

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

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 = { 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)"}


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