; LLVM IR from Tian-Xie/NLS :: NestedLogitModel.ll (ZN5TNest5ClearEv)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5TNest5ClearEv(ptr noundef nonnull align 8 dereferenceable(84) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 0
  store i32 0, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 3
  call void @_ZNSt6vectorI8TProductSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %8 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 4
  %9 = load ptr, ptr %8, align 8, !tbaa !17
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %45

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !18
  br label %12

12:                                               ; preds = %28, %11
  %13 = load i32, ptr %3, align 4, !tbaa !18
  %14 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 6
  %15 = load i32, ptr %14, align 8, !tbaa !19
  %16 = icmp slt i32 %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %31

18:                                               ; preds = %12
  %19 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = load i32, ptr %3, align 4, !tbaa !18
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds ptr, ptr %20, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %18
  call void @_ZdlPvm(ptr noundef %24, i64 noundef 32) #4
  br label %27

27:                                               ; preds = %26, %18
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %3, align 4, !tbaa !18
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !18
  br label %12, !llvm.loop !20

31:                                               ; preds = %17
  %32 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 4
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = icmp eq ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @_ZdlPvm(ptr noundef %33, i64 noundef 8) #4
  br label %36

36:                                               ; preds = %35, %31
  %37 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  %39 = icmp eq ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @_ZdlPvm(ptr noundef %38, i64 noundef 4) #4
  br label %41

41:                                               ; preds = %40, %36
  %42 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 6
  store i32 0, ptr %42, align 8, !tbaa !19
  %43 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 5
  store ptr null, ptr %43, align 8, !tbaa !22
  %44 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 4
  store ptr null, ptr %44, align 8, !tbaa !17
  br label %45

45:                                               ; preds = %41, %1
  %46 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 8
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %92

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !18
  br label %50

50:                                               ; preds = %75, %49
  %51 = load i32, ptr %4, align 4, !tbaa !18
  %52 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 10
  %53 = load i32, ptr %52, align 8, !tbaa !24
  %54 = icmp slt i32 %51, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %78

56:                                               ; preds = %50
  %57 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 9
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = load i32, ptr %4, align 4, !tbaa !18
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i32, ptr %58, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !18
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %74

64:                                               ; preds = %56
  %65 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 8
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  %67 = load i32, ptr %4, align 4, !tbaa !18
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds ptr, ptr %66, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = icmp eq ptr %70, null
  br i1 %71, label %73, label %72

72:                                               ; preds = %64
  call void @_ZdlPvm(ptr noundef %70, i64 noundef 16) #4
  br label %73

73:                                               ; preds = %72, %64
  br label %74

74:                                               ; preds = %73, %56
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %4, align 4, !tbaa !18
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %4, align 4, !tbaa !18
  br label %50, !llvm.loop !26

78:                                               ; preds = %55
  %79 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 8
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = icmp eq ptr %80, null
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  call void @_ZdlPvm(ptr noundef %80, i64 noundef 8) #4
  br label %83

83:                                               ; preds = %82, %78
  %84 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 9
  %85 = load ptr, ptr %84, align 8, !tbaa !25
  %86 = icmp eq ptr %85, null
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  call void @_ZdlPvm(ptr noundef %85, i64 noundef 4) #4
  br label %88

88:                                               ; preds = %87, %83
  %89 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 10
  store i32 0, ptr %89, align 8, !tbaa !24
  %90 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 9
  store ptr null, ptr %90, align 8, !tbaa !25
  %91 = getelementptr inbounds %struct.TNest, ptr %5, i32 0, i32 8
  store ptr null, ptr %91, align 8, !tbaa !23
  br label %92

92:                                               ; preds = %88, %45
  ret void
}

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin nounwind "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 }
attributes #4 = { builtin 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, !11, i64 0}
!10 = !{!"_ZTS5TNest", !11, i64 0, !12, i64 8, !13, i64 16, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64, !6, i64 72, !11, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSSt6vectorI8TProductSaIS0_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseI8TProductSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseI8TProductSaIS0_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI8TProductSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!10, !6, i64 40}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !11, i64 56}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !6, i64 48}
!23 = !{!10, !6, i64 64}
!24 = !{!10, !11, i64 80}
!25 = !{!10, !6, i64 72}
!26 = distinct !{!26, !21}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5TNest5ClearEv(ptr noundef nonnull align 8 dereferenceable(84) %0) local_unnamed_addr #0 align 2 {
  store i32 0, ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZNSt6vectorI8TProductSaIS0_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load ptr, ptr %3, align 8, !tbaa !16
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %26, label %.preheader16

.preheader16:                                     ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = load i32, ptr %5, align 8, !tbaa !17
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge.thread

._crit_edge:                                      ; preds = %15
  %.pre26 = load ptr, ptr %3, align 8, !tbaa !16
  %8 = icmp eq ptr %.pre26, null
  br i1 %8, label %20, label %._crit_edge.thread

.lr.ph:                                           ; preds = %.preheader16, %15
  %9 = phi i32 [ %16, %15 ], [ %6, %.preheader16 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %15 ], [ 0, %.preheader16 ]
  %10 = load ptr, ptr %3, align 8, !tbaa !16
  %11 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  %13 = icmp eq ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %.lr.ph
  tail call void @_ZdlPvm(ptr noundef nonnull %12, i64 noundef 32) #4
  %.pre = load i32, ptr %5, align 8, !tbaa !17
  br label %15

15:                                               ; preds = %.lr.ph, %14
  %16 = phi i32 [ %9, %.lr.ph ], [ %.pre, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !19

._crit_edge.thread:                               ; preds = %.preheader16, %._crit_edge
  %19 = phi ptr [ %.pre26, %._crit_edge ], [ %4, %.preheader16 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %19, i64 noundef 8) #4
  br label %20

20:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  %23 = icmp eq ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  tail call void @_ZdlPvm(ptr noundef nonnull %22, i64 noundef 4) #4
  br label %25

25:                                               ; preds = %24, %20
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %3, i8 0, i64 20, i1 false)
  br label %26

26:                                               ; preds = %25, %1
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  %.not14 = icmp eq ptr %28, null
  br i1 %.not14, label %56, label %.preheader

.preheader:                                       ; preds = %26
  %29 = getelementptr inbounds i8, ptr %0, i64 80
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph20, label %._crit_edge21.thread

.lr.ph20:                                         ; preds = %.preheader
  %32 = getelementptr inbounds i8, ptr %0, i64 72
  br label %34

._crit_edge21:                                    ; preds = %45
  %.pre28 = load ptr, ptr %27, align 8, !tbaa !22
  %33 = icmp eq ptr %.pre28, null
  br i1 %33, label %50, label %._crit_edge21.thread

34:                                               ; preds = %.lr.ph20, %45
  %35 = phi i32 [ %30, %.lr.ph20 ], [ %46, %45 ]
  %indvars.iv23 = phi i64 [ 0, %.lr.ph20 ], [ %indvars.iv.next24, %45 ]
  %36 = load ptr, ptr %32, align 8, !tbaa !24
  %37 = getelementptr inbounds i32, ptr %36, i64 %indvars.iv23
  %38 = load i32, ptr %37, align 4, !tbaa !25
  %.not15 = icmp eq i32 %38, 0
  br i1 %.not15, label %45, label %39

39:                                               ; preds = %34
  %40 = load ptr, ptr %27, align 8, !tbaa !22
  %41 = getelementptr inbounds ptr, ptr %40, i64 %indvars.iv23
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = icmp eq ptr %42, null
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  tail call void @_ZdlPvm(ptr noundef nonnull %42, i64 noundef 16) #4
  %.pre27 = load i32, ptr %29, align 8, !tbaa !23
  br label %45

45:                                               ; preds = %34, %44, %39
  %46 = phi i32 [ %35, %34 ], [ %.pre27, %44 ], [ %35, %39 ]
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next24, %47
  br i1 %48, label %34, label %._crit_edge21, !llvm.loop !26

._crit_edge21.thread:                             ; preds = %.preheader, %._crit_edge21
  %49 = phi ptr [ %.pre28, %._crit_edge21 ], [ %28, %.preheader ]
  tail call void @_ZdlPvm(ptr noundef nonnull %49, i64 noundef 8) #4
  br label %50

50:                                               ; preds = %._crit_edge21.thread, %._crit_edge21
  %51 = getelementptr inbounds i8, ptr %0, i64 72
  %52 = load ptr, ptr %51, align 8, !tbaa !24
  %53 = icmp eq ptr %52, null
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  tail call void @_ZdlPvm(ptr noundef nonnull %52, i64 noundef 4) #4
  br label %55

55:                                               ; preds = %54, %50
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %27, i8 0, i64 20, i1 false)
  br label %56

56:                                               ; preds = %55, %26
  ret void
}

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #1 = { nobuiltin nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind }
attributes #4 = { builtin 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 = !{!"_ZTS5TNest", !7, i64 0, !10, i64 8, !11, i64 16, !15, i64 40, !15, i64 48, !7, i64 56, !15, i64 64, !15, i64 72, !7, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSSt6vectorI8TProductSaIS0_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseI8TProductSaIS0_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseI8TProductSaIS0_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseI8TProductSaIS0_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!6, !15, i64 40}
!17 = !{!6, !7, i64 56}
!18 = !{!15, !15, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !15, i64 48}
!22 = !{!6, !15, i64 64}
!23 = !{!6, !7, i64 80}
!24 = !{!6, !15, i64 72}
!25 = !{!7, !7, i64 0}
!26 = distinct !{!26, !20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass