; LLVM IR from ponylang/ponyc :: src/libponyc/pkg (program)

; 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.blake2b_state__ = type { [8 x i64], [2 x i64], [2 x i64], [128 x i8], i64, i64, i8 }
%struct.program_t = type { ptr, ptr, i32, ptr, ptr, i64, i64, ptr }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@__func__.program_signature = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

declare i32 @ast_id(ptr noundef) #1

declare ptr @ast_data(ptr noundef) #1

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @program_signature(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.blake2b_state__, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %14

13:                                               ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 273, ptr noundef @__func__.program_signature)
  br label %14

14:                                               ; preds = %13, %12
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call i32 @ast_id(ptr noundef %15)
  %17 = icmp eq i32 %16, 136
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  br label %20

19:                                               ; preds = %14
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 274, ptr noundef @__func__.program_signature)
  br label %20

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

25:                                               ; preds = %20
  br label %27

26:                                               ; preds = %20
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 277, ptr noundef @__func__.program_signature)
  br label %27

27:                                               ; preds = %26, %25
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.program_t, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %86

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = call ptr @ast_child(ptr noundef %33)
  store ptr %34, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  br label %39

38:                                               ; preds = %32
  call void @ponyint_assert_fail(ptr noundef @.str.14, ptr noundef @.str.1, i64 noundef 282, ptr noundef @__func__.program_signature)
  br label %39

39:                                               ; preds = %38, %37
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.program_t, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  br label %46

45:                                               ; preds = %39
  call void @ponyint_assert_fail(ptr noundef @.str.15, ptr noundef @.str.1, i64 noundef 284, ptr noundef @__func__.program_signature)
  br label %46

46:                                               ; preds = %45, %44
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call ptr @package_dependency_groups(ptr noundef %47)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.program_t, ptr %49, i32 0, i32 0
  store ptr %48, ptr %50, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 248, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %51 = call i32 @blake2b_init(ptr noundef %5, i64 noundef 64)
  store i32 %51, ptr %6, align 4, !tbaa !14
  %52 = load i32, ptr %6, align 4, !tbaa !14
  %53 = load i32, ptr %6, align 4, !tbaa !14
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %46
  br label %57

56:                                               ; preds = %46
  call void @ponyint_assert_fail(ptr noundef @.str.16, ptr noundef @.str.1, i64 noundef 290, ptr noundef @__func__.program_signature)
  br label %57

57:                                               ; preds = %56, %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.program_t, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  store ptr %60, ptr %7, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %64, %57
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %73

64:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call ptr @package_group_list_data(ptr noundef %65)
  store ptr %66, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = call ptr @package_group_signature(ptr noundef %67)
  store ptr %68, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = call i32 @blake2b_update(ptr noundef %5, ptr noundef %69, i64 noundef 64)
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call ptr @package_group_list_next(ptr noundef %71)
  store ptr %72, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %61, !llvm.loop !15

73:                                               ; preds = %61
  %74 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64)
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.program_t, ptr %75, i32 0, i32 1
  store ptr %74, ptr %76, align 8, !tbaa !9
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.program_t, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = call i32 @blake2b_final(ptr noundef %5, ptr noundef %79, i64 noundef 64)
  store i32 %80, ptr %6, align 4, !tbaa !14
  %81 = load i32, ptr %6, align 4, !tbaa !14
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %84

83:                                               ; preds = %73
  br label %85

84:                                               ; preds = %73
  call void @ponyint_assert_fail(ptr noundef @.str.16, ptr noundef @.str.1, i64 noundef 304, ptr noundef @__func__.program_signature)
  br label %85

85:                                               ; preds = %84, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 248, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %86

86:                                               ; preds = %85, %27
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.program_t, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %89
}

declare ptr @ast_child(ptr noundef) #1

declare ptr @package_dependency_groups(ptr noundef) #1

declare i32 @blake2b_init(ptr noundef, i64 noundef) #1

declare ptr @package_group_list_data(ptr noundef) #1

declare ptr @package_group_signature(ptr noundef) #1

declare i32 @blake2b_update(ptr noundef, ptr noundef, i64 noundef) #1

declare ptr @package_group_list_next(ptr noundef) #1

declare i32 @blake2b_final(ptr noundef, ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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, !6, i64 8}
!10 = !{!"program_t", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !6, i64 0}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.blake2b_state__ = type { [8 x i64], [2 x i64], [2 x i64], [128 x i8], i64, i64, i8 }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@__func__.program_signature = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

declare i32 @ast_id(ptr noundef) local_unnamed_addr #1

declare ptr @ast_data(ptr noundef) local_unnamed_addr #1

declare noalias ptr @ponyint_pool_alloc_size(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @program_signature(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.blake2b_state__, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 273, ptr noundef nonnull @__func__.program_signature) #3
  br label %4

4:                                                ; preds = %1, %3
  %5 = tail call i32 @ast_id(ptr noundef %0) #3
  %6 = icmp eq i32 %5, 136
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 274, ptr noundef nonnull @__func__.program_signature) #3
  br label %8

8:                                                ; preds = %4, %7
  %9 = tail call ptr @ast_data(ptr noundef %0) #3
  %.not21 = icmp eq ptr %9, null
  br i1 %.not21, label %10, label %11

10:                                               ; preds = %8
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 277, ptr noundef nonnull @__func__.program_signature) #3
  br label %11

11:                                               ; preds = %8, %10
  %12 = getelementptr inbounds i8, ptr %9, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %38

15:                                               ; preds = %11
  %16 = tail call ptr @ast_child(ptr noundef %0) #3
  %.not22 = icmp eq ptr %16, null
  br i1 %.not22, label %17, label %18

17:                                               ; preds = %15
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i64 noundef 282, ptr noundef nonnull @__func__.program_signature) #3
  br label %18

18:                                               ; preds = %15, %17
  %19 = load ptr, ptr %9, align 8, !tbaa !12
  %20 = icmp eq ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i64 noundef 284, ptr noundef nonnull @__func__.program_signature) #3
  br label %22

22:                                               ; preds = %18, %21
  %23 = tail call ptr @package_dependency_groups(ptr noundef %16) #3
  store ptr %23, ptr %9, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 248, ptr nonnull %2) #3
  %24 = call i32 @blake2b_init(ptr noundef nonnull %2, i64 noundef 64) #3
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i64 noundef 290, ptr noundef nonnull @__func__.program_signature) #3
  br label %27

27:                                               ; preds = %22, %26
  %28 = load ptr, ptr %9, align 8, !tbaa !12
  %.not2324 = icmp eq ptr %28, null
  br i1 %.not2324, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %27, %.lr.ph
  %.025 = phi ptr [ %32, %.lr.ph ], [ %28, %27 ]
  %29 = call ptr @package_group_list_data(ptr noundef nonnull %.025) #3
  %30 = call ptr @package_group_signature(ptr noundef %29) #3
  %31 = call i32 @blake2b_update(ptr noundef nonnull %2, ptr noundef %30, i64 noundef 64) #3
  %32 = call ptr @package_group_list_next(ptr noundef nonnull %.025) #3
  %.not23 = icmp eq ptr %32, null
  br i1 %.not23, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %27
  %33 = call noalias ptr @ponyint_pool_alloc_size(i64 noundef 64) #3
  store ptr %33, ptr %12, align 8, !tbaa !5
  %34 = call i32 @blake2b_final(ptr noundef nonnull %2, ptr noundef %33, i64 noundef 64) #3
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %37, label %36

36:                                               ; preds = %._crit_edge
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.1, i64 noundef 304, ptr noundef nonnull @__func__.program_signature) #3
  br label %37

37:                                               ; preds = %._crit_edge, %36
  call void @llvm.lifetime.end.p0(i64 248, ptr nonnull %2) #3
  %.pre = load ptr, ptr %12, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %37, %11
  %39 = phi ptr [ %.pre, %37 ], [ %13, %11 ]
  ret ptr %39
}

declare ptr @ast_child(ptr noundef) local_unnamed_addr #1

declare ptr @package_dependency_groups(ptr noundef) local_unnamed_addr #1

declare i32 @blake2b_init(ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @package_group_list_data(ptr noundef) local_unnamed_addr #1

declare ptr @package_group_signature(ptr noundef) local_unnamed_addr #1

declare i32 @blake2b_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @package_group_list_next(ptr noundef) local_unnamed_addr #1

declare i32 @blake2b_final(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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, !7, i64 8}
!6 = !{!"program_t", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32, !11, i64 40, !11, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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