; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

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

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @r8cmat_zeros_new(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = mul i64 %9, 8
  %11 = call noalias ptr @malloc(i64 noundef %10) #4
  store ptr %11, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %25, %2
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %28

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = mul i64 %18, 8
  %20 = call noalias ptr @malloc(i64 noundef %19) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds ptr, ptr %21, i64 %23
  store ptr %20, ptr %24, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %16
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %7, align 4, !tbaa !5
  br label %12, !llvm.loop !11

28:                                               ; preds = %12
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %51, %28
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %54

33:                                               ; preds = %29
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %47, %33
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %50

38:                                               ; preds = %34
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds ptr, ptr %39, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %43, i64 %45
  store double 0.000000e+00, ptr %46, align 8, !tbaa !13
  br label %47

47:                                               ; preds = %38
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !5
  br label %34, !llvm.loop !15

50:                                               ; preds = %34
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !16

54:                                               ; preds = %29
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %55
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { nounwind 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(readwrite, argmem: write) uwtable
define dso_local noalias noundef ptr @r8cmat_zeros_new(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = sext i32 %1 to i64
  %4 = shl nsw i64 %3, 3
  %5 = tail call noalias ptr @malloc(i64 noundef %4) #3
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph, label %._crit_edge23

.lr.ph:                                           ; preds = %2
  %7 = sext i32 %0 to i64
  %8 = shl nsw i64 %7, 3
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %29

.preheader18:                                     ; preds = %29
  %9 = icmp sgt i32 %0, 0
  %or.cond = and i1 %6, %9
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge23

.preheader.us.preheader:                          ; preds = %.preheader18
  %10 = zext nneg i32 %0 to i64
  %11 = shl nuw nsw i64 %10, 3
  %xtraiter = and i64 %wide.trip.count, 7
  %12 = icmp ult i32 %1, 8
  br i1 %12, label %._crit_edge23.loopexit.unr-lcssa, label %.preheader.us.preheader.new

.preheader.us.preheader.new:                      ; preds = %.preheader.us.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483640
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us, %.preheader.us.preheader.new
  %indvars.iv29 = phi i64 [ 0, %.preheader.us.preheader.new ], [ %indvars.iv.next30.7, %.preheader.us ]
  %niter = phi i64 [ 0, %.preheader.us.preheader.new ], [ %niter.next.7, %.preheader.us ]
  %13 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv29
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30 = or disjoint i64 %indvars.iv29, 1
  %15 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.1 = or disjoint i64 %indvars.iv29, 2
  %17 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.1
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %18, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.2 = or disjoint i64 %indvars.iv29, 3
  %19 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.2
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.3 = or disjoint i64 %indvars.iv29, 4
  %21 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.3
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %22, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.4 = or disjoint i64 %indvars.iv29, 5
  %23 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.4
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %24, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.5 = or disjoint i64 %indvars.iv29, 6
  %25 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %26, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.6 = or disjoint i64 %indvars.iv29, 7
  %27 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv.next30.6
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %28, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.7 = add nuw nsw i64 %indvars.iv29, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge23.loopexit.unr-lcssa, label %.preheader.us, !llvm.loop !11

29:                                               ; preds = %.lr.ph, %29
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %29 ]
  %30 = tail call noalias ptr @malloc(i64 noundef %8) #3
  %31 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv
  store ptr %30, ptr %31, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader18, label %29, !llvm.loop !13

._crit_edge23.loopexit.unr-lcssa:                 ; preds = %.preheader.us, %.preheader.us.preheader
  %indvars.iv29.unr = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next30.7, %.preheader.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge23, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %._crit_edge23.loopexit.unr-lcssa, %.preheader.us.epil
  %indvars.iv29.epil = phi i64 [ %indvars.iv.next30.epil, %.preheader.us.epil ], [ %indvars.iv29.unr, %._crit_edge23.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.epil ], [ 0, %._crit_edge23.loopexit.unr-lcssa ]
  %32 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv29.epil
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %33, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next30.epil = add nuw nsw i64 %indvars.iv29.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge23, label %.preheader.us.epil, !llvm.loop !14

._crit_edge23:                                    ; preds = %._crit_edge23.loopexit.unr-lcssa, %.preheader.us.epil, %2, %.preheader18
  ret ptr %5
}

; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree nounwind memory(readwrite, argmem: write) 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}


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