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

; 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 [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.reify = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 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 ptr @ast_sibling(ptr noundef) #0

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

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

19:                                               ; preds = %5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = call i32 @ast_id(ptr noundef %20)
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %23, label %24

23:                                               ; preds = %19, %5
  br label %25

24:                                               ; preds = %19
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 211, ptr noundef @__func__.reify)
  br label %25

25:                                               ; preds = %24, %23
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call i32 @ast_id(ptr noundef %26)
  %28 = icmp eq i32 %27, 166
  br i1 %28, label %33, label %29

29:                                               ; preds = %25
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call i32 @ast_id(ptr noundef %30)
  %32 = icmp eq i32 %31, 2
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %25
  br label %35

34:                                               ; preds = %29
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 215, ptr noundef @__func__.reify)
  br label %35

35:                                               ; preds = %34, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %36 = load i8, ptr %10, align 1, !tbaa !9, !range !11, !noundef !12
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call ptr @ast_dup(ptr noundef %39)
  store ptr %40, ptr %11, align 8, !tbaa !5
  br label %43

41:                                               ; preds = %35
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %42, ptr %11, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %41, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call ptr @ast_child(ptr noundef %44)
  store ptr %45, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = call ptr @ast_child(ptr noundef %46)
  store ptr %47, ptr %13, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %56, %43
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %54

51:                                               ; preds = %48
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br label %54

54:                                               ; preds = %51, %48
  %55 = phi i1 [ false, %48 ], [ %53, %51 ]
  br i1 %55, label %56, label %64

56:                                               ; preds = %54
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  call void @reify_one(ptr noundef %57, ptr noundef %11, ptr noundef %58, ptr noundef %59)
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = call ptr @ast_sibling(ptr noundef %60)
  store ptr %61, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = call ptr @ast_sibling(ptr noundef %62)
  store ptr %63, ptr %13, align 8, !tbaa !5
  br label %48, !llvm.loop !13

64:                                               ; preds = %54
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %64
  br label %69

68:                                               ; preds = %64
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 234, ptr noundef @__func__.reify)
  br label %69

69:                                               ; preds = %68, %67
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %73

72:                                               ; preds = %69
  br label %74

73:                                               ; preds = %69
  call void @ponyint_assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i64 noundef 235, ptr noundef @__func__.reify)
  br label %74

74:                                               ; preds = %73, %72
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret ptr %75
}

declare ptr @ast_dup(ptr noundef) #0

declare ptr @ast_child(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @reify_one(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"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 [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.reify = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 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 ptr @ast_sibling(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

; Function Attrs: nounwind uwtable
define dso_local ptr @reify(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i1 noundef zeroext %4) local_unnamed_addr #2 {
  %6 = alloca ptr, align 8
  %7 = tail call i32 @ast_id(ptr noundef %1) #3
  %8 = icmp eq i32 %7, 162
  br i1 %8, label %13, label %9

9:                                                ; preds = %5
  %10 = tail call i32 @ast_id(ptr noundef %1) #3
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 211, ptr noundef nonnull @__func__.reify) #3
  br label %13

13:                                               ; preds = %5, %9, %12
  %14 = tail call i32 @ast_id(ptr noundef %2) #3
  %15 = icmp eq i32 %14, 166
  br i1 %15, label %20, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @ast_id(ptr noundef %2) #3
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 215, ptr noundef nonnull @__func__.reify) #3
  br label %20

20:                                               ; preds = %13, %16, %19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  br i1 %4, label %21, label %23

21:                                               ; preds = %20
  %22 = tail call ptr @ast_dup(ptr noundef %0) #3
  br label %23

23:                                               ; preds = %20, %21
  %storemerge = phi ptr [ %22, %21 ], [ %0, %20 ]
  store ptr %storemerge, ptr %6, align 8, !tbaa !5
  %24 = tail call ptr @ast_child(ptr noundef %1) #3
  %25 = tail call ptr @ast_child(ptr noundef %2) #3
  %26 = icmp ne ptr %24, null
  %27 = icmp ne ptr %25, null
  %28 = select i1 %26, i1 %27, i1 false
  br i1 %28, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %23, %.lr.ph
  %.020 = phi ptr [ %30, %.lr.ph ], [ %25, %23 ]
  %.01819 = phi ptr [ %29, %.lr.ph ], [ %24, %23 ]
  call void @reify_one(ptr noundef %3, ptr noundef nonnull %6, ptr noundef nonnull %.01819, ptr noundef nonnull %.020)
  %29 = call ptr @ast_sibling(ptr noundef nonnull %.01819) #3
  %30 = call ptr @ast_sibling(ptr noundef nonnull %.020) #3
  %31 = icmp ne ptr %29, null
  %32 = icmp ne ptr %30, null
  %33 = select i1 %31, i1 %32, i1 false
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %23
  %.018.lcssa = phi ptr [ %24, %23 ], [ %29, %.lr.ph ]
  %.0.lcssa = phi ptr [ %25, %23 ], [ %30, %.lr.ph ]
  %34 = icmp eq ptr %.018.lcssa, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %._crit_edge
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 234, ptr noundef nonnull @__func__.reify) #3
  br label %36

36:                                               ; preds = %._crit_edge, %35
  %37 = icmp eq ptr %.0.lcssa, null
  br i1 %37, label %39, label %38

38:                                               ; preds = %36
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i64 noundef 235, ptr noundef nonnull @__func__.reify) #3
  br label %39

39:                                               ; preds = %36, %38
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret ptr %40
}

declare ptr @ast_dup(ptr noundef) local_unnamed_addr #0

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @reify_one(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass