; LLVM IR from NOAA-PMEL/Ferret :: fmt/src (deleted_list_init)

; 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.Deleted_List_Header = type { i32, i32, i32, ptr, ptr, ptr, ptr }
%struct.Deleted_List_Node = type { i32, ptr, ptr }

@.str = external hidden unnamed_addr constant [78 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @deleted_list_init_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %13 = call ptr @FerMem_Malloc(i64 noundef 48, ptr noundef @.str, i32 noundef 58)
  store ptr %13, ptr %9, align 8, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %15, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Deleted_List_Header, ptr %17, i32 0, i32 6
  store ptr %16, ptr %18, align 8, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Deleted_List_Header, ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 4, !tbaa !13
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Deleted_List_Header, ptr %25, i32 0, i32 2
  store i32 %24, ptr %26, align 8, !tbaa !14
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Deleted_List_Header, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !13
  store i32 %29, ptr %10, align 4, !tbaa !12
  %30 = load i32, ptr %10, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = mul i64 %31, 8
  %33 = call ptr @FerMem_Malloc(i64 noundef %32, ptr noundef @.str, i32 noundef 65)
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Deleted_List_Header, ptr %34, i32 0, i32 3
  store ptr %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Deleted_List_Header, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load i32, ptr %10, align 4, !tbaa !12
  %40 = sext i32 %39 to i64
  %41 = mul i64 %40, 8
  call void @llvm.memset.p0.i64(ptr align 8 %38, i8 0, i64 %41, i1 false)
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Deleted_List_Header, ptr %42, i32 0, i32 4
  store ptr null, ptr %43, align 8, !tbaa !16
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Deleted_List_Header, ptr %44, i32 0, i32 5
  store ptr null, ptr %45, align 8, !tbaa !17
  %46 = load i32, ptr %10, align 4, !tbaa !12
  store i32 %46, ptr %11, align 4, !tbaa !12
  br label %47

47:                                               ; preds = %127, %4
  %48 = load i32, ptr %11, align 4, !tbaa !12
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %130

50:                                               ; preds = %47
  %51 = call ptr @FerMem_Malloc(i64 noundef 24, ptr noundef @.str, i32 noundef 71)
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Deleted_List_Header, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %11, align 4, !tbaa !12
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %54, i64 %57
  store ptr %51, ptr %58, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Deleted_List_Header, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %11, align 4, !tbaa !12
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds ptr, ptr %61, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  store ptr %66, ptr %12, align 8, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !12
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Deleted_List_Node, ptr %68, i32 0, i32 0
  store i32 %67, ptr %69, align 8, !tbaa !18
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Deleted_List_Header, ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !12
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %72, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !12
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Deleted_List_Header, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 8, !tbaa !14
  %81 = icmp eq i32 %77, %80
  br i1 %81, label %82, label %104

82:                                               ; preds = %50
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Deleted_List_Node, ptr %83, i32 0, i32 1
  store ptr null, ptr %84, align 8, !tbaa !20
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.Deleted_List_Header, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.Deleted_List_Node, ptr %88, i32 0, i32 2
  store ptr %87, ptr %89, align 8, !tbaa !21
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.Deleted_List_Header, ptr %91, i32 0, i32 4
  store ptr %90, ptr %92, align 8, !tbaa !16
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.Deleted_List_Node, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !21
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %103

97:                                               ; preds = %82
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.Deleted_List_Node, ptr %99, i32 0, i32 2
  %101 = load ptr, ptr %100, align 8, !tbaa !21
  %102 = getelementptr inbounds %struct.Deleted_List_Node, ptr %101, i32 0, i32 1
  store ptr %98, ptr %102, align 8, !tbaa !20
  br label %103

103:                                              ; preds = %97, %82
  br label %126

104:                                              ; preds = %50
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.Deleted_List_Node, ptr %105, i32 0, i32 1
  store ptr null, ptr %106, align 8, !tbaa !20
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.Deleted_List_Header, ptr %107, i32 0, i32 5
  %109 = load ptr, ptr %108, align 8, !tbaa !17
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.Deleted_List_Node, ptr %110, i32 0, i32 2
  store ptr %109, ptr %111, align 8, !tbaa !21
  %112 = load ptr, ptr %12, align 8, !tbaa !5
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.Deleted_List_Header, ptr %113, i32 0, i32 5
  store ptr %112, ptr %114, align 8, !tbaa !17
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.Deleted_List_Node, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !21
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %125

119:                                              ; preds = %104
  %120 = load ptr, ptr %12, align 8, !tbaa !5
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.Deleted_List_Node, ptr %121, i32 0, i32 2
  %123 = load ptr, ptr %122, align 8, !tbaa !21
  %124 = getelementptr inbounds %struct.Deleted_List_Node, ptr %123, i32 0, i32 1
  store ptr %120, ptr %124, align 8, !tbaa !20
  br label %125

125:                                              ; preds = %119, %104
  br label %126

126:                                              ; preds = %125, %103
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %11, align 4, !tbaa !12
  %129 = add nsw i32 %128, -1
  store i32 %129, ptr %11, align 4, !tbaa !12
  br label %47, !llvm.loop !22

130:                                              ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

declare ptr @FerMem_Malloc(i64 noundef, ptr noundef, i32 noundef) #2

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

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

attributes #0 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 40}
!10 = !{!"Deleted_List_Header", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 32}
!18 = !{!19, !11, i64 0}
!19 = !{!"Deleted_List_Node", !11, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!19, !6, i64 8}
!21 = !{!19, !6, i64 16}
!22 = distinct !{!22, !23}
!23 = !{!"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"

@.str = external hidden unnamed_addr constant [78 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @deleted_list_init_(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = tail call ptr @FerMem_Malloc(i64 noundef 48, ptr noundef nonnull @.str, i32 noundef 58) #3
  store ptr %5, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %1, ptr %6, align 8, !tbaa !9
  %7 = load i32, ptr %2, align 4, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %7, ptr %8, align 4, !tbaa !13
  %9 = load i32, ptr %3, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %9, ptr %10, align 8, !tbaa !14
  %11 = sext i32 %7 to i64
  %12 = shl nsw i64 %11, 3
  %13 = tail call ptr @FerMem_Malloc(i64 noundef %12, ptr noundef nonnull @.str, i32 noundef 65) #3
  %14 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %13, ptr %14, align 8, !tbaa !15
  tail call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 %12, i1 false)
  %15 = getelementptr inbounds i8, ptr %5, i64 24
  %16 = getelementptr inbounds i8, ptr %5, i64 32
  %17 = icmp sgt i32 %7, 0
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  br i1 %17, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %18 = zext nneg i32 %7 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %38
  %indvars.iv = phi i64 [ %18, %.lr.ph.preheader ], [ %indvars.iv.next, %38 ]
  %19 = tail call ptr @FerMem_Malloc(i64 noundef 24, ptr noundef nonnull @.str, i32 noundef 71) #3
  %20 = load ptr, ptr %14, align 8, !tbaa !15
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv.next
  store ptr %19, ptr %21, align 8, !tbaa !5
  %22 = load ptr, ptr %14, align 8, !tbaa !15
  %23 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv.next
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %25, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds i32, ptr %26, i64 %indvars.iv.next
  %28 = load i32, ptr %27, align 4, !tbaa !12
  %29 = load i32, ptr %10, align 8, !tbaa !14
  %30 = icmp eq i32 %28, %29
  %31 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr null, ptr %31, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %24, i64 16
  br i1 %30, label %33, label %35

33:                                               ; preds = %.lr.ph
  %34 = load ptr, ptr %15, align 8, !tbaa !19
  store ptr %34, ptr %32, align 8, !tbaa !20
  store ptr %24, ptr %15, align 8, !tbaa !19
  %.not44 = icmp eq ptr %34, null
  br i1 %.not44, label %38, label %.sink.split

35:                                               ; preds = %.lr.ph
  %36 = load ptr, ptr %16, align 8, !tbaa !21
  store ptr %36, ptr %32, align 8, !tbaa !20
  store ptr %24, ptr %16, align 8, !tbaa !21
  %.not = icmp eq ptr %36, null
  br i1 %.not, label %38, label %.sink.split

.sink.split:                                      ; preds = %35, %33
  %.sink47 = phi ptr [ %34, %33 ], [ %36, %35 ]
  %37 = getelementptr inbounds i8, ptr %.sink47, i64 8
  store ptr %24, ptr %37, align 8, !tbaa !18
  br label %38

38:                                               ; preds = %.sink.split, %33, %35
  %39 = icmp ugt i64 %indvars.iv, 1
  br i1 %39, label %.lr.ph, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %38, %4
  ret void
}

declare ptr @FerMem_Malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

attributes #0 = { 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 = { "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 nocallback nofree nounwind willreturn memory(argmem: write) }
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 40}
!10 = !{!"Deleted_List_Header", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !11, i64 0}
!17 = !{!"Deleted_List_Node", !11, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!17, !6, i64 8}
!19 = !{!10, !6, i64 24}
!20 = !{!17, !6, i64 16}
!21 = !{!10, !6, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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