; LLVM IR from lynx-family/primjs :: src/napi/napi.ll/ZN4Napi8Function3NewEP10napi_env (PFNS_5ValueERKNS_12CallbackInfoEEPKcPv)

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

%"class.Napi::Function" = type { %"class.Napi::Object" }
%"class.Napi::Object" = type { %"class.Napi::Value" }
%"class.Napi::Value" = type { ptr, ptr }
%class.anon = type { i8 }
%"struct.Napi::details::CallbackData" = type { ptr, ptr }
%struct.napi_env__ = 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, 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, 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, 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, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.51 = external hidden unnamed_addr constant [36 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: mustprogress uwtable
declare hidden void @_ZN4NapiL11CheckStatusEP10napi_env__11napi_statusPKc(ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local { ptr, ptr } @_ZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPv(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca %"class.Napi::Function", align 8
  %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 i32, align 4
  %13 = alloca %class.anon, align 1
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #5
  %15 = getelementptr inbounds %"struct.Napi::details::CallbackData", ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %16, ptr %15, align 16, !tbaa !9
  %17 = getelementptr inbounds %"struct.Napi::details::CallbackData", ptr %14, i32 0, i32 1
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %18, ptr %17, align 8, !tbaa !11
  store ptr %14, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.napi_env__, ptr %19, i32 0, i32 19
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = call noundef i32 %21(ptr noundef %22, ptr noundef %23, i64 noundef -1, ptr noundef @_ZN4Napi7details12CallbackData7WrapperEP10napi_env__P20napi_callback_info__, ptr noundef %25, ptr noundef %11)
  store i32 %26, ptr %12, align 4, !tbaa !14
  %27 = load i32, ptr %12, align 4, !tbaa !14
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %38

29:                                               ; preds = %4
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.napi_env__, ptr %30, i32 0, i32 100
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #4
  %36 = call noundef ptr @"_ZZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPvENK3$_0cvPFvS2_SB_SB_EEv"(ptr noundef nonnull align 1 dereferenceable(1) %13) #4
  %37 = call noundef i32 %32(ptr noundef %33, ptr noundef %34, ptr noundef %35, ptr noundef %36, ptr noundef null, ptr noundef null)
  store i32 %37, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #4
  br label %38

38:                                               ; preds = %29, %4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %12, align 4, !tbaa !14
  call void @_ZN4NapiL11CheckStatusEP10napi_env__11napi_statusPKc(ptr noundef %39, i32 noundef %40, ptr noundef @.str.51)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZN4Napi8FunctionC2EP10napi_env__P12napi_value__(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %41, ptr noundef %42)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %43 = getelementptr inbounds %"class.Napi::Function", ptr %5, i32 0, i32 0
  %44 = getelementptr inbounds %"class.Napi::Object", ptr %43, i32 0, i32 0
  %45 = load { ptr, ptr }, ptr %44, align 8
  ret { ptr, ptr } %45
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4Napi7details12CallbackData7WrapperEP10napi_env__P20napi_callback_info__(ptr noundef, ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPvENK3$_0cvPFvS2_SB_SB_EEv"(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Napi8FunctionC2EP10napi_env__P12napi_value__(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { nobuiltin allocsize(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 = { inlinehint mustprogress 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 #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN4Napi7details12CallbackDataE", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = !{!13, !6, i64 152}
!13 = !{!"_ZTS10napi_env__", !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, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !6, i64 416, !6, i64 424, !6, i64 432, !6, i64 440, !6, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !6, i64 480, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592, !6, i64 600, !6, i64 608, !6, i64 616, !6, i64 624, !6, i64 632, !6, i64 640, !6, i64 648, !6, i64 656, !6, i64 664, !6, i64 672, !6, i64 680, !6, i64 688, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !6, i64 744, !6, i64 752, !6, i64 760, !6, i64 768, !6, i64 776, !6, i64 784, !6, i64 792, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !6, i64 832, !6, i64 840, !6, i64 848, !6, i64 856, !6, i64 864, !6, i64 872, !6, i64 880, !6, i64 888, !6, i64 896, !6, i64 904, !6, i64 912, !6, i64 920, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !6, i64 976, !6, i64 984, !6, i64 992}
!14 = !{!15, !15, i64 0}
!15 = !{!"_ZTS11napi_status", !7, i64 0}
!16 = !{!13, !6, i64 800}


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

%"class.Napi::Function" = type { %"class.Napi::Object" }
%"class.Napi::Object" = type { %"class.Napi::Value" }
%"class.Napi::Value" = type { ptr, ptr }
%class.anon = type { i8 }

@.str.51 = external hidden unnamed_addr constant [36 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 uwtable
declare hidden void @_ZN4NapiL11CheckStatusEP10napi_env__11napi_statusPKc(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local { ptr, ptr } @_ZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPv(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.Napi::Function", align 8
  %6 = alloca ptr, align 8
  %7 = alloca %class.anon, align 1
  %8 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #4
  store ptr %1, ptr %8, align 16, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %3, ptr %9, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store ptr null, ptr %6, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 152
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = call noundef i32 %11(ptr noundef %0, ptr noundef %2, i64 noundef -1, ptr noundef nonnull @_ZN4Napi7details12CallbackData7WrapperEP10napi_env__P20napi_callback_info__, ptr noundef nonnull %8, ptr noundef nonnull %6)
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %4
  %15 = getelementptr inbounds i8, ptr %0, i64 800
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = load ptr, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #5
  %18 = call noundef ptr @"_ZZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPvENK3$_0cvPFvS2_SB_SB_EEv"(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  %19 = call noundef i32 %16(ptr noundef nonnull %0, ptr noundef %17, ptr noundef nonnull %8, ptr noundef %18, ptr noundef null, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #5
  br label %20

20:                                               ; preds = %14, %4
  %.0 = phi i32 [ %19, %14 ], [ %12, %4 ]
  call void @_ZN4NapiL11CheckStatusEP10napi_env__11napi_statusPKc(ptr noundef nonnull %0, i32 noundef %.0, ptr noundef nonnull @.str.51)
  %21 = load ptr, ptr %6, align 8, !tbaa !11
  call void @_ZN4Napi8FunctionC2EP10napi_env__P12napi_value__(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull %0, ptr noundef %21)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  %.fca.0.load = load ptr, ptr %5, align 8
  %.fca.0.insert = insertvalue { ptr, ptr } poison, ptr %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %5, i64 8
  %.fca.1.load = load ptr, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { ptr, ptr } %.fca.0.insert, ptr %.fca.1.load, 1
  ret { ptr, ptr } %.fca.1.insert
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4Napi7details12CallbackData7WrapperEP10napi_env__P20napi_callback_info__(ptr noundef, ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN4Napi8Function3NewEP10napi_env__PFNS_5ValueERKNS_12CallbackInfoEEPKcPvENK3$_0cvPFvS2_SB_SB_EEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Napi8FunctionC2EP10napi_env__P12napi_value__(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { nobuiltin allocsize(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 = { inlinehint mustprogress 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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 = !{!"_ZTSN4Napi7details12CallbackDataE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 152}
!13 = !{!"_ZTS10napi_env__", !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, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376, !7, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !7, i64 496, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !7, i64 536, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !7, i64 576, !7, i64 584, !7, i64 592, !7, i64 600, !7, i64 608, !7, i64 616, !7, i64 624, !7, i64 632, !7, i64 640, !7, i64 648, !7, i64 656, !7, i64 664, !7, i64 672, !7, i64 680, !7, i64 688, !7, i64 696, !7, i64 704, !7, i64 712, !7, i64 720, !7, i64 728, !7, i64 736, !7, i64 744, !7, i64 752, !7, i64 760, !7, i64 768, !7, i64 776, !7, i64 784, !7, i64 792, !7, i64 800, !7, i64 808, !7, i64 816, !7, i64 824, !7, i64 832, !7, i64 840, !7, i64 848, !7, i64 856, !7, i64 864, !7, i64 872, !7, i64 880, !7, i64 888, !7, i64 896, !7, i64 904, !7, i64 912, !7, i64 920, !7, i64 928, !7, i64 936, !7, i64 944, !7, i64 952, !7, i64 960, !7, i64 968, !7, i64 976, !7, i64 984, !7, i64 992}
!14 = !{!13, !7, i64 800}


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