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

; 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.typecheck_t = type { ptr, %struct.typecheck_stats_t, ptr }
%struct.typecheck_stats_t = type { i64, i64, i64, i64 }
%struct.typecheck_frame_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@__func__.ffi_get_decl = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = 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

; 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 zeroext i1 @ffi_get_decl(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  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
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %4
  br label %20

19:                                               ; preds = %4
  call void @ponyint_assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 456, ptr noundef @__func__.ffi_get_decl)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 457, ptr noundef @__func__.ffi_get_decl)
  br label %25

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

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @ponyint_assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i64 noundef 458, ptr noundef @__func__.ffi_get_decl)
  br label %30

30:                                               ; preds = %29, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call ptr @ast_child(ptr noundef %31)
  %33 = call ptr @ast_name(ptr noundef %32)
  store ptr %33, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.typecheck_t, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.typecheck_frame_t, ptr %36, i32 0, i32 22
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  store ptr %38, ptr %11, align 8, !tbaa !5
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %30
  br label %43

42:                                               ; preds = %30
  call void @ponyint_assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 466, ptr noundef @__func__.ffi_get_decl)
  br label %43

43:                                               ; preds = %42, %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = call ptr @ast_get_symtab(ptr noundef %44)
  store ptr %45, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = call ptr @symtab_find(ptr noundef %46, ptr noundef %47, ptr noundef %13)
  store ptr %48, ptr %14, align 8, !tbaa !5
  %49 = load i32, ptr %13, align 4, !tbaa !15
  %50 = icmp eq i32 %49, 7
  br i1 %50, label %51, label %52

51:                                               ; preds = %43
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %86

52:                                               ; preds = %43
  %53 = load i32, ptr %13, align 4, !tbaa !15
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %83

55:                                               ; preds = %52
  %56 = load ptr, ptr %14, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  br label %60

59:                                               ; preds = %55
  call void @ponyint_assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i64 noundef 479, ptr noundef @__func__.ffi_get_decl)
  br label %60

60:                                               ; preds = %59, %58
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.typecheck_t, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.typecheck_frame_t, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.typecheck_t, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.typecheck_frame_t, ptr %69, i32 0, i32 21
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = call zeroext i1 @find_ffi_decl(ptr noundef %61, ptr noundef %66, ptr noundef %71, ptr noundef %14, ptr noundef %72)
  br i1 %73, label %78, label %74

74:                                               ; preds = %60
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = call zeroext i1 @symtab_add(ptr noundef %75, ptr noundef %76, ptr noundef null, i32 noundef 7)
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %86

78:                                               ; preds = %60
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = call zeroext i1 @symtab_add(ptr noundef %79, ptr noundef %80, ptr noundef %81, i32 noundef 6)
  br label %83

83:                                               ; preds = %78, %52
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %84, ptr %85, align 8, !tbaa !5
  store i1 true, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %86

86:                                               ; preds = %83, %74, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %87 = load i1, ptr %5, align 1
  ret i1 %87
}

declare ptr @ast_name(ptr noundef) #0

declare ptr @ast_child(ptr noundef) #0

declare ptr @ast_get_symtab(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @find_ffi_decl(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare zeroext i1 @symtab_add(ptr noundef, ptr noundef, ptr noundef, i32 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 = !{!10, !6, i64 0}
!10 = !{!"typecheck_t", !6, i64 0, !11, i64 8, !6, i64 40}
!11 = !{!"typecheck_stats_t", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 176}
!14 = !{!"typecheck_frame_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !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, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!14, !6, i64 0}
!18 = !{!14, !6, i64 168}


; 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 [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@__func__.ffi_get_decl = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = 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

; 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 noundef zeroext i1 @ffi_get_decl(ptr noundef readonly %0, ptr noundef %1, ptr noundef writeonly %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %7, label %8

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

8:                                                ; preds = %4, %7
  %.not20 = icmp eq ptr %1, null
  br i1 %.not20, label %9, label %10

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

10:                                               ; preds = %8, %9
  %.not21 = icmp eq ptr %2, null
  br i1 %.not21, label %11, label %12

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

12:                                               ; preds = %10, %11
  %13 = tail call ptr @ast_child(ptr noundef %1) #3
  %14 = tail call ptr @ast_name(ptr noundef %13) #3
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 176
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %.not22 = icmp eq ptr %17, null
  br i1 %.not22, label %18, label %19

18:                                               ; preds = %12
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 466, ptr noundef nonnull @__func__.ffi_get_decl) #3
  br label %19

19:                                               ; preds = %12, %18
  %20 = tail call ptr @ast_get_symtab(ptr noundef %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %21 = call ptr @symtab_find(ptr noundef %20, ptr noundef %14, ptr noundef nonnull %5) #3
  store ptr %21, ptr %6, align 8, !tbaa !14
  %22 = load i32, ptr %5, align 4, !tbaa !15
  switch i32 %22, label %37 [
    i32 7, label %39
    i32 0, label %23
  ]

23:                                               ; preds = %19
  %24 = icmp eq ptr %21, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %23
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i64 noundef 479, ptr noundef nonnull @__func__.ffi_get_decl) #3
  br label %26

26:                                               ; preds = %23, %25
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %27, i64 168
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = call zeroext i1 @find_ffi_decl(ptr noundef %1, ptr noundef %28, ptr noundef %30, ptr noundef nonnull %6, ptr noundef %3)
  br i1 %31, label %34, label %32

32:                                               ; preds = %26
  %33 = call zeroext i1 @symtab_add(ptr noundef %20, ptr noundef %14, ptr noundef null, i32 noundef 7) #3
  br label %39

34:                                               ; preds = %26
  %35 = load ptr, ptr %6, align 8, !tbaa !14
  %36 = call zeroext i1 @symtab_add(ptr noundef %20, ptr noundef %14, ptr noundef %35, i32 noundef 6) #3
  %.pre = load ptr, ptr %6, align 8, !tbaa !14
  br label %37

37:                                               ; preds = %19, %34
  %38 = phi ptr [ %21, %19 ], [ %.pre, %34 ]
  store ptr %38, ptr %2, align 8, !tbaa !14
  br label %39

39:                                               ; preds = %19, %37, %32
  %.0 = phi i1 [ true, %37 ], [ false, %32 ], [ false, %19 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  ret i1 %.0
}

declare ptr @ast_name(ptr noundef) local_unnamed_addr #0

declare ptr @ast_child(ptr noundef) local_unnamed_addr #0

declare ptr @ast_get_symtab(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @find_ffi_decl(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare zeroext i1 @symtab_add(ptr noundef, ptr noundef, ptr noundef, i32 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, !7, i64 0}
!6 = !{!"typecheck_t", !7, i64 0, !10, i64 8, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"typecheck_stats_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !7, i64 176}
!13 = !{!"typecheck_frame_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{!13, !7, i64 0}
!18 = !{!13, !7, i64 168}


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