; 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.25 = external hidden unnamed_addr constant [12 x i8], align 1
@__func__.expr_match_capture = external hidden unnamed_addr constant [19 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1

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_setid(ptr noundef, i32 noundef) #0

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

declare ptr @ast_child(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @expr_match_capture(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 [3 x ptr], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %13

12:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i64 noundef 619, ptr noundef @__func__.expr_match_capture)
  br label %13

13:                                               ; preds = %12, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  store ptr %5, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds ptr, ptr %7, i64 1
  store ptr %6, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %7, i64 2
  store ptr null, ptr %15, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds [3 x ptr], ptr %7, i64 0, i64 0
  call void @ast_get_children(ptr noundef %16, i64 noundef 2, ptr noundef %17)
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call ptr @ast_name(ptr noundef %18)
  %20 = call zeroext i1 @is_name_dontcare(ptr noundef %19)
  br i1 %20, label %21, label %24

21:                                               ; preds = %13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call ptr @ast_setid(ptr noundef %22, i32 noundef 183)
  br label %24

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

27:                                               ; preds = %24
  br label %29

28:                                               ; preds = %24
  call void @ponyint_assert_fail(ptr noundef @.str.26, ptr noundef @.str.1, i64 noundef 626, ptr noundef @__func__.expr_match_capture)
  br label %29

29:                                               ; preds = %28, %27
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %30, ptr noundef %31)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call ptr @ast_child(ptr noundef %32)
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %33, ptr noundef %34)
  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 zeroext i1 @is_name_dontcare(ptr noundef) #0

declare ptr @ast_name(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"}


; 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.25 = external hidden unnamed_addr constant [12 x i8], align 1
@__func__.expr_match_capture = external hidden unnamed_addr constant [19 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [13 x i8], align 1

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_setid(ptr noundef, i32 noundef) local_unnamed_addr #0

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

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @expr_match_capture(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [3 x ptr], align 16
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i64 noundef 619, ptr noundef nonnull @__func__.expr_match_capture) #3
  br label %7

7:                                                ; preds = %2, %6
  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 24, ptr nonnull %5) #3
  store ptr %3, ptr %5, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %4, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr null, ptr %9, align 16, !tbaa !5
  call void @ast_get_children(ptr noundef %1, i64 noundef 2, ptr noundef nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call ptr @ast_name(ptr noundef %10) #3
  %12 = call zeroext i1 @is_name_dontcare(ptr noundef %11) #3
  br i1 %12, label %13, label %15

13:                                               ; preds = %7
  %14 = call ptr @ast_setid(ptr noundef %1, i32 noundef 183) #3
  br label %15

15:                                               ; preds = %13, %7
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %.not6 = icmp eq ptr %16, null
  br i1 %.not6, label %17, label %18

17:                                               ; preds = %15
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i64 noundef 626, ptr noundef nonnull @__func__.expr_match_capture) #3
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %15, %17
  %19 = phi ptr [ %16, %15 ], [ %.pre, %17 ]
  call void @ast_settype(ptr noundef %1, ptr noundef %19) #3
  %20 = call ptr @ast_child(ptr noundef %1) #3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ast_settype(ptr noundef %20, ptr noundef %21) #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
  ret i1 true
}

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

declare ptr @ast_name(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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass