; LLVM IR from opset/openset :: lib/cjson/cjson.ll (ZNK5cjson8getNodesEv)

; 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.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl" }
%"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl" = type { %"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.cjson = type <{ ptr, i64, ptr, ptr, ptr, ptr, i32, [4 x i8], ptr, ptr, ptr, ptr, i8, [7 x i8] }>

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5cjson4sizeEv(ptr noundef nonnull align 8 dereferenceable(89)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5cjson8getNodesEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %12 = call noundef i32 @_ZNK5cjson4sizeEv(ptr noundef nonnull align 8 dereferenceable(89) %11)
  store i32 %12, ptr %5, align 4, !tbaa !9
  store i1 false, ptr %6, align 1
  call void @_ZNSt6vectorIP5cjsonSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  invoke void @_ZNSt6vectorIP5cjsonSaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %14)
          to label %15 unwind label %24

15:                                               ; preds = %2
  %16 = getelementptr inbounds %class.cjson, ptr %11, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp ne i64 %17, 3
  br i1 %18, label %19, label %28

19:                                               ; preds = %15
  %20 = getelementptr inbounds %class.cjson, ptr %11, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp ne i64 %21, 2
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  store i1 true, ptr %6, align 1
  store i32 1, ptr %9, align 4
  br label %50

24:                                               ; preds = %2
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %7, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %8, align 4
  br label %54

28:                                               ; preds = %19, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %29 = getelementptr inbounds %class.cjson, ptr %11, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  store ptr %30, ptr %10, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %45, %28
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %49

34:                                               ; preds = %31
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.cjson, ptr %35, i32 0, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %45

39:                                               ; preds = %34
  invoke void @_ZNSt6vectorIP5cjsonSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %10)
          to label %40 unwind label %41

40:                                               ; preds = %39
  br label %45

41:                                               ; preds = %39
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %7, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %54

45:                                               ; preds = %40, %34
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.cjson, ptr %46, i32 0, i32 10
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  store ptr %48, ptr %10, align 8, !tbaa !5
  br label %31, !llvm.loop !17

49:                                               ; preds = %31
  store i1 true, ptr %6, align 1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %50

50:                                               ; preds = %49, %23
  %51 = load i1, ptr %6, align 1
  br i1 %51, label %53, label %52

52:                                               ; preds = %50
  call void @_ZNSt6vectorIP5cjsonSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %53

53:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void

54:                                               ; preds = %41, %24
  call void @_ZNSt6vectorIP5cjsonSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %7, align 8
  %57 = load i32, ptr %8, align 4
  %58 = insertvalue { ptr, i32 } poison, ptr %56, 0
  %59 = insertvalue { ptr, i32 } %58, i32 %57, 1
  resume { ptr, i32 } %59
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTS5cjson", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88}
!13 = !{!"_ZTSN5cjson7Types_eE", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!12, !6, i64 32}
!16 = !{!12, !6, i64 72}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl" }
%"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl" = type { %"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<cjson *, std::allocator<cjson *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local noundef i32 @_ZNK5cjson4sizeEv(ptr noundef nonnull align 8 dereferenceable(89)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK5cjson8getNodesEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = tail call noundef i32 @_ZNK5cjson4sizeEv(ptr noundef nonnull align 8 dereferenceable(89) %1)
  tail call void @_ZNSt6vectorIP5cjsonSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %5 = sext i32 %4 to i64
  invoke void @_ZNSt6vectorIP5cjsonSaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5)
          to label %6 unwind label %10

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = and i64 %8, -2
  %switch = icmp eq i64 %9, 2
  br i1 %switch, label %12, label %22

10:                                               ; preds = %2
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %23

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %13 = getelementptr inbounds i8, ptr %1, i64 32
  %storemerge12 = load ptr, ptr %13, align 8, !tbaa !13
  store ptr %storemerge12, ptr %3, align 8, !tbaa !13
  %.not913 = icmp eq ptr %storemerge12, null
  br i1 %.not913, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %12, %19
  %storemerge14 = phi ptr [ %storemerge, %19 ], [ %storemerge12, %12 ]
  %14 = getelementptr inbounds i8, ptr %storemerge14, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %.not10 = icmp eq i64 %15, 0
  br i1 %.not10, label %19, label %16

16:                                               ; preds = %.lr.ph
  invoke void @_ZNSt6vectorIP5cjsonSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %._crit_edge15 unwind label %17

._crit_edge15:                                    ; preds = %16
  %.pre = load ptr, ptr %3, align 8, !tbaa !13
  br label %19

17:                                               ; preds = %16
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %23

19:                                               ; preds = %._crit_edge15, %.lr.ph
  %20 = phi ptr [ %.pre, %._crit_edge15 ], [ %storemerge14, %.lr.ph ]
  %21 = getelementptr inbounds i8, ptr %20, i64 72
  %storemerge = load ptr, ptr %21, align 8, !tbaa !13
  store ptr %storemerge, ptr %3, align 8, !tbaa !13
  %.not9 = icmp eq ptr %storemerge, null
  br i1 %.not9, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %19, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %22

22:                                               ; preds = %6, %._crit_edge
  ret void

23:                                               ; preds = %17, %10
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %11, %10 ]
  call void @_ZNSt6vectorIP5cjsonSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIP5cjsonSaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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


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