; LLVM IR from Py-Contributors/AlgorithmsAndDataStructure :: C++/Data Structure/Linked List/sparse_matrix.ll (Z15create_row_listPP8row_listiiPA5_i)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17create_value_nodeiiPP8row_list(i32 noundef, i32 noundef, ptr noundef) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z15create_row_listPP8row_listiiPA5_i(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %81, %4
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %84

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %20 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #4
  store ptr %20, ptr %11, align 8, !tbaa !5
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.row_list, ptr %23, i32 0, i32 0
  store i32 %22, ptr %24, align 8, !tbaa !11
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.row_list, ptr %25, i32 0, i32 2
  store ptr null, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.row_list, ptr %27, i32 0, i32 1
  store ptr null, ptr %28, align 8, !tbaa !14
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %19
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %32, ptr %33, align 8, !tbaa !5
  br label %50

34:                                               ; preds = %19
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  store ptr %36, ptr %12, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %42, %34
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %class.row_list, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %46

42:                                               ; preds = %37
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.row_list, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  store ptr %45, ptr %12, align 8, !tbaa !5
  br label %37, !llvm.loop !15

46:                                               ; preds = %37
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.row_list, ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !14
  br label %50

50:                                               ; preds = %46, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %77, %50
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 7, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %80

56:                                               ; preds = %51
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [5 x i32], ptr %57, i64 %59
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [5 x i32], ptr %60, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %76

66:                                               ; preds = %56
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [5 x i32], ptr %67, i64 %69
  %71 = load i32, ptr %13, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [5 x i32], ptr %70, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = load i32, ptr %13, align 4, !tbaa !9
  call void @_Z17create_value_nodeiiPP8row_list(i32 noundef %74, i32 noundef %75, ptr noundef %11)
  br label %76

76:                                               ; preds = %66, %56
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %13, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %13, align 4, !tbaa !9
  br label %51, !llvm.loop !17

80:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %9, align 4, !tbaa !9
  br label %14, !llvm.loop !18

84:                                               ; preds = %18
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #4 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS8row_list", !10, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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 uwtable
declare dso_local void @_Z17create_value_nodeiiPP8row_list(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z15create_row_listPP8row_listiiPA5_i(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph27, label %._crit_edge28

.lr.ph27:                                         ; preds = %4
  %7 = icmp sgt i32 %2, 0
  br i1 %7, label %.lr.ph27.split.us.preheader, label %.lr.ph27.split

.lr.ph27.split.us.preheader:                      ; preds = %.lr.ph27
  %wide.trip.count35 = zext nneg i32 %1 to i64
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph27.split.us

.lr.ph27.split.us:                                ; preds = %.lr.ph27.split.us.preheader, %._crit_edge.us
  %indvars.iv32 = phi i64 [ 0, %.lr.ph27.split.us.preheader ], [ %indvars.iv.next33, %._crit_edge.us ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %8 = call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #5
  store ptr %8, ptr %5, align 8, !tbaa !5
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %9 = trunc nuw nsw i64 %indvars.iv.next33 to i32
  store i32 %9, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  %11 = icmp eq i64 %indvars.iv32, 0
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  br i1 %11, label %.lr.ph.us, label %12

12:                                               ; preds = %.lr.ph27.split.us
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %14, %12
  %.019.us = phi ptr [ %13, %12 ], [ %16, %14 ]
  %15 = getelementptr inbounds i8, ptr %.019.us, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %.not.us = icmp eq ptr %16, null
  br i1 %.not.us, label %17, label %14, !llvm.loop !13

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %.019.us, i64 8
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph27.split.us, %17
  %.sink = phi ptr [ %18, %17 ], [ %0, %.lr.ph27.split.us ]
  store ptr %8, ptr %.sink, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %.lr.ph.us, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph.us ], [ %indvars.iv.next, %24 ]
  %20 = getelementptr inbounds [5 x i32], ptr %3, i64 %indvars.iv32, i64 %indvars.iv
  %21 = load i32, ptr %20, align 4, !tbaa !15
  %.not23.us = icmp eq i32 %21, 0
  br i1 %.not23.us, label %24, label %22

22:                                               ; preds = %19
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_Z17create_value_nodeiiPP8row_list(i32 noundef %21, i32 noundef %23, ptr noundef nonnull %5)
  br label %24

24:                                               ; preds = %22, %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond31.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond31.not, label %._crit_edge.us, label %19, !llvm.loop !16

._crit_edge.us:                                   ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %exitcond36.not = icmp eq i64 %indvars.iv.next33, %wide.trip.count35
  br i1 %exitcond36.not, label %._crit_edge28, label %.lr.ph27.split.us, !llvm.loop !17

._crit_edge28:                                    ; preds = %36, %._crit_edge.us, %4
  ret void

.lr.ph27.split:                                   ; preds = %.lr.ph27, %36
  %.02025 = phi i32 [ %26, %36 ], [ 0, %.lr.ph27 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %25 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #5
  %26 = add nuw nsw i32 %.02025, 1
  store i32 %26, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %25, i64 8
  %28 = icmp eq i32 %.02025, 0
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %27, i8 0, i64 16, i1 false)
  br i1 %28, label %36, label %29

29:                                               ; preds = %.lr.ph27.split
  %30 = load ptr, ptr %0, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %31, %29
  %.019 = phi ptr [ %30, %29 ], [ %33, %31 ]
  %32 = getelementptr inbounds i8, ptr %.019, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %.not = icmp eq ptr %33, null
  br i1 %.not, label %34, label %31, !llvm.loop !13

34:                                               ; preds = %31
  %35 = getelementptr inbounds i8, ptr %.019, i64 8
  br label %36

36:                                               ; preds = %.lr.ph27.split, %34
  %.sink39 = phi ptr [ %35, %34 ], [ %0, %.lr.ph27.split ]
  store ptr %25, ptr %.sink39, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %exitcond.not = icmp eq i32 %26, %1
  br i1 %exitcond.not, label %._crit_edge28, label %.lr.ph27.split, !llvm.loop !17
}

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 0}
!10 = !{!"_ZTS8row_list", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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