; 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.program_t = type { ptr, ptr, i32, ptr, ptr, i64, i64, ptr }

@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1
@__func__.use_path = external hidden unnamed_addr constant [9 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 ptr @ast_data(ptr noundef) #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @use_path(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 [4096 x i8], align 16
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = 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
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4096, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call zeroext i1 @is_path_absolute(ptr noundef %18)
  br i1 %19, label %25, label %20

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call ptr @ast_nearest(ptr noundef %21, i32 noundef 137)
  store ptr %22, ptr %12, align 8, !tbaa !5
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = call ptr @package_path(ptr noundef %23)
  store ptr %24, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %25

25:                                               ; preds = %20, %4
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds [4096 x i8], ptr %10, i64 0, i64 0
  call void @path_cat(ptr noundef %26, ptr noundef %27, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds [4096 x i8], ptr %10, i64 0, i64 0
  %32 = call ptr @quoted_locator(ptr noundef %29, ptr noundef %30, ptr noundef %31)
  store ptr %32, ptr %13, align 8, !tbaa !5
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %36

35:                                               ; preds = %25
  store i1 false, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %64

36:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call ptr @ast_nearest(ptr noundef %37, i32 noundef 136)
  store ptr %38, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = call ptr @ast_data(ptr noundef %39)
  store ptr %40, ptr %16, align 8, !tbaa !5
  %41 = load ptr, ptr %16, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.program_t, ptr %41, i32 0, i32 7
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %36
  br label %47

46:                                               ; preds = %36
  call void @ponyint_assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i64 noundef 167, ptr noundef @__func__.use_path)
  br label %47

47:                                               ; preds = %46, %45
  %48 = load ptr, ptr %16, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.program_t, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = call ptr @strlist_find(ptr noundef %50, ptr noundef %51)
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %47
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %63

55:                                               ; preds = %47
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.program_t, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = call ptr @strlist_append(ptr noundef %58, ptr noundef %59)
  %61 = load ptr, ptr %16, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.program_t, ptr %61, i32 0, i32 3
  store ptr %60, ptr %62, align 8, !tbaa !13
  store i1 true, ptr %5, align 1
  store i32 1, ptr %14, align 4
  br label %63

63:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %64

64:                                               ; preds = %63, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4096, ptr %10) #3
  %65 = load i1, ptr %5, align 1
  ret i1 %65
}

declare zeroext i1 @is_path_absolute(ptr noundef) #1

declare ptr @package_path(ptr noundef) #1

declare void @path_cat(ptr noundef, ptr noundef, ptr 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 56}
!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 24}


; 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 [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1
@__func__.use_path = external hidden unnamed_addr constant [9 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 ptr @ast_data(ptr noundef) local_unnamed_addr #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @use_path(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readnone %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca [4096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %5) #3
  %6 = tail call zeroext i1 @is_path_absolute(ptr noundef %1) #3
  br i1 %6, label %10, label %7

7:                                                ; preds = %4
  %8 = tail call ptr @ast_nearest(ptr noundef %0, i32 noundef 137) #3
  %9 = tail call ptr @package_path(ptr noundef %8) #3
  br label %10

10:                                               ; preds = %7, %4
  %.018 = phi ptr [ null, %4 ], [ %9, %7 ]
  call void @path_cat(ptr noundef %.018, ptr noundef %1, ptr noundef nonnull %5) #3
  %11 = call ptr @quoted_locator(ptr noundef %3, ptr noundef %0, ptr noundef nonnull %5)
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %27

13:                                               ; preds = %10
  %14 = call ptr @ast_nearest(ptr noundef %0, i32 noundef 136) #3
  %15 = call ptr @ast_data(ptr noundef %14) #3
  %16 = getelementptr inbounds i8, ptr %15, i64 56
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i64 noundef 167, ptr noundef nonnull @__func__.use_path) #3
  br label %20

20:                                               ; preds = %13, %19
  %21 = getelementptr inbounds i8, ptr %15, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = call ptr @strlist_find(ptr noundef %22, ptr noundef nonnull %11) #3
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %24, label %27

24:                                               ; preds = %20
  %25 = load ptr, ptr %21, align 8, !tbaa !12
  %26 = call ptr @strlist_append(ptr noundef %25, ptr noundef nonnull %11) #3
  store ptr %26, ptr %21, align 8, !tbaa !12
  br label %27

27:                                               ; preds = %24, %20, %10
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %5) #3
  ret i1 %12
}

declare zeroext i1 @is_path_absolute(ptr noundef) local_unnamed_addr #1

declare ptr @package_path(ptr noundef) local_unnamed_addr #1

declare void @path_cat(ptr noundef, ptr noundef, ptr 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 56}
!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 24}


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