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

%struct.pass_opt_t = type { i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i64, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.typecheck_t, ptr, ptr }
%struct.typecheck_t = type { ptr, %struct.typecheck_stats_t, ptr }
%struct.typecheck_stats_t = type { i64, i64, i64, i64 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__func__.reify_defaults = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @reify_defaults(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, ptr noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %15 = zext i1 %2 to i8
  store i8 %15, ptr %8, align 1, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %6, 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 = %4
  %20 = load ptr, ptr %6, 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, %4
  br label %25

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

25:                                               ; preds = %24, %23
  %26 = load ptr, ptr %7, 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 %7, 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 156, ptr noundef @__func__.reify_defaults)
  br label %35

35:                                               ; preds = %34, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i64 @ast_childcount(ptr noundef %36)
  store i64 %37, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call i64 @ast_childcount(ptr noundef %38)
  store i64 %39, ptr %11, align 8, !tbaa !11
  %40 = load i64, ptr %10, align 8, !tbaa !11
  %41 = load i64, ptr %11, align 8, !tbaa !11
  %42 = icmp eq i64 %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %108

44:                                               ; preds = %35
  %45 = load i64, ptr %10, align 8, !tbaa !11
  %46 = load i64, ptr %11, align 8, !tbaa !11
  %47 = icmp ult i64 %45, %46
  br i1 %47, label %48, label %63

48:                                               ; preds = %44
  %49 = load i8, ptr %8, align 1, !tbaa !9, !range !13, !noundef !14
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %62

51:                                               ; preds = %48
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.pass_opt_t, ptr %52, i32 0, i32 36
  %54 = getelementptr inbounds %struct.typecheck_t, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error(ptr noundef %55, ptr noundef %56, ptr noundef @.str.3)
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.pass_opt_t, ptr %57, i32 0, i32 36
  %59 = getelementptr inbounds %struct.typecheck_t, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error_continue(ptr noundef %60, ptr noundef %61, ptr noundef @.str.4)
  br label %62

62:                                               ; preds = %51, %48
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %108

63:                                               ; preds = %44
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call ptr @ast_setid(ptr noundef %64, i32 noundef 166)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load i64, ptr %11, align 8, !tbaa !11
  %68 = call ptr @ast_childidx(ptr noundef %66, i64 noundef %67)
  store ptr %68, ptr %13, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %87, %63
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %88

72:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = call ptr @ast_childidx(ptr noundef %73, i64 noundef 2)
  store ptr %74, ptr %14, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = call i32 @ast_id(ptr noundef %75)
  %77 = icmp eq i32 %76, 2
  br i1 %77, label %78, label %79

78:                                               ; preds = %72
  store i32 3, ptr %12, align 4
  br label %85

79:                                               ; preds = %72
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = call ptr @ast_append(ptr noundef %80, ptr noundef %81)
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = call ptr @ast_sibling(ptr noundef %83)
  store ptr %84, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %85

85:                                               ; preds = %79, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %86 = load i32, ptr %12, align 4
  switch i32 %86, label %110 [
    i32 0, label %87
    i32 3, label %88
  ]

87:                                               ; preds = %85
  br label %69, !llvm.loop !20

88:                                               ; preds = %85, %69
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %106

91:                                               ; preds = %88
  %92 = load i8, ptr %8, align 1, !tbaa !9, !range !13, !noundef !14
  %93 = trunc i8 %92 to i1
  br i1 %93, label %94, label %105

94:                                               ; preds = %91
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.pass_opt_t, ptr %95, i32 0, i32 36
  %97 = getelementptr inbounds %struct.typecheck_t, ptr %96, i32 0, i32 2
  %98 = load ptr, ptr %97, align 8, !tbaa !15
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error(ptr noundef %98, ptr noundef %99, ptr noundef @.str.5)
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.pass_opt_t, ptr %100, i32 0, i32 36
  %102 = getelementptr inbounds %struct.typecheck_t, ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %102, align 8, !tbaa !15
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  call void (ptr, ptr, ptr, ...) @ast_error_continue(ptr noundef %103, ptr noundef %104, ptr noundef @.str.4)
  br label %105

105:                                              ; preds = %94, %91
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %107

106:                                              ; preds = %88
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %107

107:                                              ; preds = %106, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %108

108:                                              ; preds = %107, %62, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %109 = load i1, ptr %5, align 1
  ret i1 %109

110:                                              ; preds = %85
  unreachable
}

declare i32 @ast_id(ptr noundef) #1

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

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

declare i64 @ast_childcount(ptr noundef) #1

declare void @ast_error(ptr noundef, ptr noundef, ptr noundef, ...) #1

declare void @ast_error_continue(ptr noundef, ptr noundef, ptr noundef, ...) #1

declare ptr @ast_setid(ptr noundef, i32 noundef) #1

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

declare ptr @ast_append(ptr noundef, ptr noundef) #1

declare ptr @ast_sibling(ptr noundef) #1

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 216}
!16 = !{!"pass_opt_t", !17, i64 0, !17, i64 4, !10, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !10, i64 12, !10, i64 13, !10, i64 14, !10, i64 15, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !10, i64 20, !10, i64 21, !17, i64 24, !12, i64 32, !10, i64 40, !10, i64 41, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !18, i64 176, !6, i64 224, !6, i64 232}
!17 = !{!"int", !7, i64 0}
!18 = !{!"typecheck_t", !6, i64 0, !19, i64 8, !6, i64 40}
!19 = !{!"typecheck_stats_t", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"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
@__func__.reify_defaults = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @reify_defaults(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = tail call i32 @ast_id(ptr noundef %0) #2
  %6 = icmp eq i32 %5, 162
  br i1 %6, label %11, label %7

7:                                                ; preds = %4
  %8 = tail call i32 @ast_id(ptr noundef %0) #2
  %9 = icmp eq i32 %8, 2
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 152, ptr noundef nonnull @__func__.reify_defaults) #2
  br label %11

11:                                               ; preds = %4, %7, %10
  %12 = tail call i32 @ast_id(ptr noundef %1) #2
  %13 = icmp eq i32 %12, 166
  br i1 %13, label %18, label %14

14:                                               ; preds = %11
  %15 = tail call i32 @ast_id(ptr noundef %1) #2
  %16 = icmp eq i32 %15, 2
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 156, ptr noundef nonnull @__func__.reify_defaults) #2
  br label %18

18:                                               ; preds = %11, %14, %17
  %19 = tail call i64 @ast_childcount(ptr noundef %0) #2
  %20 = tail call i64 @ast_childcount(ptr noundef %1) #2
  %21 = icmp eq i64 %19, %20
  br i1 %21, label %.thread41, label %22

22:                                               ; preds = %18
  %23 = icmp ult i64 %19, %20
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  br i1 %2, label %.thread41.sink.split, label %.thread41

25:                                               ; preds = %22
  %26 = tail call ptr @ast_setid(ptr noundef %1, i32 noundef 166) #2
  %27 = tail call ptr @ast_childidx(ptr noundef %0, i64 noundef %20) #2
  %.not46 = icmp eq ptr %27, null
  br i1 %.not46, label %.thread41, label %.lr.ph

.lr.ph:                                           ; preds = %25, %31
  %.03147 = phi ptr [ %33, %31 ], [ %27, %25 ]
  %28 = tail call ptr @ast_childidx(ptr noundef nonnull %.03147, i64 noundef 2) #2
  %29 = tail call i32 @ast_id(ptr noundef %28) #2
  %30 = icmp eq i32 %29, 2
  br i1 %30, label %34, label %31

31:                                               ; preds = %.lr.ph
  %32 = tail call ptr @ast_append(ptr noundef %1, ptr noundef %28) #2
  %33 = tail call ptr @ast_sibling(ptr noundef nonnull %.03147) #2
  %.not = icmp eq ptr %33, null
  br i1 %.not, label %.thread41, label %.lr.ph

34:                                               ; preds = %.lr.ph
  br i1 %2, label %.thread41.sink.split, label %.thread41

.thread41.sink.split:                             ; preds = %34, %24
  %.str.5.sink = phi ptr [ @.str.3, %24 ], [ @.str.5, %34 ]
  %35 = getelementptr inbounds i8, ptr %3, i64 216
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  tail call void (ptr, ptr, ptr, ...) @ast_error(ptr noundef %36, ptr noundef %1, ptr noundef nonnull %.str.5.sink) #2
  %37 = load ptr, ptr %35, align 8, !tbaa !5
  tail call void (ptr, ptr, ptr, ...) @ast_error_continue(ptr noundef %37, ptr noundef %0, ptr noundef nonnull @.str.4) #2
  br label %.thread41

.thread41:                                        ; preds = %31, %.thread41.sink.split, %25, %34, %24, %18
  %.1 = phi i1 [ true, %18 ], [ false, %24 ], [ false, %34 ], [ true, %25 ], [ false, %.thread41.sink.split ], [ true, %31 ]
  ret i1 %.1
}

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

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

declare i64 @ast_childcount(ptr noundef) local_unnamed_addr #1

declare void @ast_error(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @ast_error_continue(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare ptr @ast_setid(ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare ptr @ast_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_sibling(ptr noundef) local_unnamed_addr #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 = { "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)"}
!5 = !{!6, !12, i64 216}
!6 = !{!"pass_opt_t", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !10, i64 12, !10, i64 13, !10, i64 14, !10, i64 15, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !10, i64 20, !10, i64 21, !7, i64 24, !11, i64 32, !10, i64 40, !10, i64 41, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !13, i64 176, !12, i64 224, !12, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"typecheck_t", !12, i64 0, !14, i64 8, !12, i64 40}
!14 = !{!"typecheck_stats_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}


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