; 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
declare double @pow(double noundef, double noundef) #2

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

14:                                               ; preds = %64, %2
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %67

18:                                               ; preds = %14
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %60, %18
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %63

23:                                               ; preds = %19
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %42

26:                                               ; preds = %23
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fcmp oeq double %31, 0.000000e+00
  br i1 %32, label %33, label %42

33:                                               ; preds = %26
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = mul nsw i32 %36, %37
  %39 = add nsw i32 %35, %38
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %34, i64 %40
  store double 1.000000e+00, ptr %41, align 8, !tbaa !11
  br label %59

42:                                               ; preds = %26, %23
  %43 = load ptr, ptr %4, 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
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sitofp i32 %48 to double
  %50 = call double @pow(double noundef %47, double noundef %49) #4
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = mul nsw i32 %53, %54
  %56 = add nsw i32 %52, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %51, i64 %57
  store double %50, ptr %58, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %42, %33
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %7, align 4, !tbaa !5
  br label %19, !llvm.loop !13

63:                                               ; preds = %19
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %6, align 4, !tbaa !5
  br label %14, !llvm.loop !15

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

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 "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 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 #4 = { nounwind }
attributes #5 = { 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @r8mat_vand2(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = mul nsw i32 %0, %0
  %4 = zext nneg i32 %3 to i64
  %5 = shl nuw nsw i64 %4, 3
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #3
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.preheader.us.preheader, label %._crit_edge26

.preheader.us.preheader:                          ; preds = %2
  %8 = zext nneg i32 %0 to i64
  %exitcond.peel.not = icmp eq i32 %0, 1
  %9 = add nsw i64 %8, -1
  %xtraiter = and i64 %9, 1
  %10 = icmp eq i32 %0, 2
  %unroll_iter = and i64 %9, -2
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %11

11:                                               ; preds = %._crit_edge.us, %.preheader.us.preheader
  %indvars.iv29 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next30, %._crit_edge.us ]
  %12 = getelementptr inbounds double, ptr %1, i64 %indvars.iv29
  %13 = getelementptr inbounds double, ptr %6, i64 %indvars.iv29
  store double 1.000000e+00, ptr %13, align 8, !tbaa !5
  br i1 %exitcond.peel.not, label %._crit_edge.us, label %.peel.next

.peel.next:                                       ; preds = %11
  %invariant.gep = getelementptr inbounds double, ptr %6, i64 %indvars.iv29
  br i1 %10, label %._crit_edge.us.loopexit.unr-lcssa, label %.peel.next.new

.peel.next.new:                                   ; preds = %.peel.next, %.peel.next.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.peel.next.new ], [ 1, %.peel.next ]
  %niter = phi i64 [ %niter.next.1, %.peel.next.new ], [ 0, %.peel.next ]
  %.pre34 = load double, ptr %12, align 8, !tbaa !5
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = uitofp nneg i32 %14 to double
  %16 = tail call double @pow(double noundef %.pre34, double noundef %15) #4
  %17 = mul nuw nsw i64 %indvars.iv, %8
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %17
  store double %16, ptr %gep, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.pre34.1 = load double, ptr %12, align 8, !tbaa !5
  %18 = trunc nuw nsw i64 %indvars.iv.next to i32
  %19 = uitofp nneg i32 %18 to double
  %20 = tail call double @pow(double noundef %.pre34.1, double noundef %19) #4
  %21 = mul nuw nsw i64 %indvars.iv.next, %8
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %21
  store double %20, ptr %gep.1, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.loopexit.unr-lcssa, label %.peel.next.new, !llvm.loop !9

._crit_edge.us.loopexit.unr-lcssa:                ; preds = %.peel.next.new, %.peel.next
  %indvars.iv.unr = phi i64 [ 1, %.peel.next ], [ %indvars.iv.next.1, %.peel.next.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.loopexit.epilog-lcssa

._crit_edge.us.loopexit.epilog-lcssa:             ; preds = %._crit_edge.us.loopexit.unr-lcssa
  %.pre34.epil = load double, ptr %12, align 8, !tbaa !5
  %22 = trunc nuw nsw i64 %indvars.iv.unr to i32
  %23 = uitofp nneg i32 %22 to double
  %24 = tail call double @pow(double noundef %.pre34.epil, double noundef %23) #4
  %25 = mul nuw nsw i64 %indvars.iv.unr, %8
  %gep.epil = getelementptr inbounds double, ptr %invariant.gep, i64 %25
  store double %24, ptr %gep.epil, align 8, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.loopexit.epilog-lcssa, %._crit_edge.us.loopexit.unr-lcssa, %11
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next30, %8
  br i1 %exitcond33.not, label %._crit_edge26, label %11, !llvm.loop !12

._crit_edge26:                                    ; preds = %._crit_edge.us, %2
  ret ptr %6
}

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nofree nounwind memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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 allocsize(0) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}


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