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

; 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.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [24 x i8], align 1
@__func__.expr_cases = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1

declare i32 @ast_id(ptr noundef) #0

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

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

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

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

declare ptr @ast_type(ptr noundef) #0

declare zeroext i1 @is_typecheck_error(ptr noundef) #0

declare i32 @ast_checkflag(ptr noundef, i32 noundef) #0

declare ptr @control_type_add_branch(ptr noundef, ptr noundef, ptr noundef) #0

declare ptr @ast_sibling(ptr noundef) #0

declare void @ast_settype(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_cases(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
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [4 x ptr], align 16
  %11 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call i32 @ast_id(ptr noundef %12)
  %14 = icmp eq i32 %13, 180
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  br label %17

16:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i64 noundef 274, ptr noundef @__func__.expr_cases)
  br label %17

17:                                               ; preds = %16, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call ptr @ast_child(ptr noundef %18)
  store ptr %19, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17
  call void @ponyint_assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i64 noundef 276, ptr noundef @__func__.expr_cases)
  br label %24

24:                                               ; preds = %23, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %47, %24
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %50

28:                                               ; preds = %25
  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 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #3
  store ptr %7, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %10, i64 1
  store ptr %8, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds ptr, ptr %10, i64 2
  store ptr %9, ptr %30, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %10, i64 3
  store ptr null, ptr %31, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 0
  call void @ast_get_children(ptr noundef %32, i64 noundef 3, ptr noundef %33)
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call ptr @ast_type(ptr noundef %34)
  store ptr %35, ptr %11, align 8, !tbaa !5
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = call zeroext i1 @is_typecheck_error(ptr noundef %36)
  br i1 %37, label %47, label %38

38:                                               ; preds = %28
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = call i32 @ast_checkflag(ptr noundef %39, i32 noundef 1048576)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %47, label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = call ptr @control_type_add_branch(ptr noundef %43, ptr noundef %44, ptr noundef %45)
  store ptr %46, ptr %6, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %42, %38, %28
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call ptr @ast_sibling(ptr noundef %48)
  store ptr %49, ptr %5, align 8, !tbaa !5
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %25, !llvm.loop !9

50:                                               ; preds = %25
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %51, ptr noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i1 true
}

declare ptr @ast_child(ptr noundef) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"}


; 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 [74 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [24 x i8], align 1
@__func__.expr_cases = external hidden unnamed_addr constant [11 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1

declare i32 @ast_id(ptr noundef) local_unnamed_addr #0

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

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

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

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

declare ptr @ast_type(ptr noundef) local_unnamed_addr #0

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

declare i32 @ast_checkflag(ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @control_type_add_branch(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #0

declare void @ast_settype(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @expr_cases(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 %1) #3
  %8 = icmp eq i32 %7, 180
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %2, %9
  %11 = tail call ptr @ast_child(ptr noundef %1) #3
  %cond = icmp eq ptr %11, null
  br i1 %cond, label %12, label %.lr.ph

12:                                               ; preds = %10
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i64 noundef 276, ptr noundef nonnull @__func__.expr_cases) #3
  br label %._crit_edge

.lr.ph:                                           ; preds = %10
  %13 = getelementptr inbounds i8, ptr %6, i64 8
  %14 = getelementptr inbounds i8, ptr %6, i64 16
  %15 = getelementptr inbounds i8, ptr %6, i64 24
  br label %16

16:                                               ; preds = %.lr.ph, %26
  %.016 = phi ptr [ %11, %.lr.ph ], [ %27, %26 ]
  %.01115 = phi ptr [ null, %.lr.ph ], [ %.1, %26 ]
  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 !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 16, !tbaa !5
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @ast_get_children(ptr noundef nonnull %.016, i64 noundef 3, ptr noundef nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call ptr @ast_type(ptr noundef %17) #3
  %19 = call zeroext i1 @is_typecheck_error(ptr noundef %18) #3
  br i1 %19, label %26, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 @ast_checkflag(ptr noundef %21, i32 noundef 1048576) #3
  %.not13 = icmp eq i32 %22, 0
  br i1 %.not13, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call ptr @control_type_add_branch(ptr noundef %0, ptr noundef %.01115, ptr noundef %24) #3
  br label %26

26:                                               ; preds = %23, %20, %16
  %.1 = phi ptr [ %.01115, %16 ], [ %.01115, %20 ], [ %25, %23 ]
  %27 = call ptr @ast_sibling(ptr noundef nonnull %.016) #3
  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
  %.not12 = icmp eq ptr %27, null
  br i1 %.not12, label %._crit_edge, label %16, !llvm.loop !9

._crit_edge:                                      ; preds = %26, %12
  %.011.lcssa = phi ptr [ null, %12 ], [ %.1, %26 ]
  call void @ast_settype(ptr noundef %1, ptr noundef %.011.lcssa) #3
  ret i1 true
}

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"}


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