; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8_sign(double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @r8vec_house_column(i32 noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = call ptr @r8vec_zeros_new(i32 noundef %12)
  store ptr %13, ptr %10, align 8, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %20, label %16

16:                                               ; preds = %3
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %16, %3
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %21, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %103

22:                                               ; preds = %16
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = sub nsw i32 %24, %25
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = getelementptr inbounds double, ptr %30, i64 -1
  %32 = call double @r8vec_norm_l2(i32 noundef %26, ptr noundef %31)
  store double %32, ptr %9, align 8, !tbaa !11
  %33 = load double, ptr %9, align 8, !tbaa !11
  %34 = fcmp oeq double %33, 0.000000e+00
  br i1 %34, label %35, label %37

35:                                               ; preds = %22
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %36, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %103

37:                                               ; preds = %22
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %38, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load double, ptr %9, align 8, !tbaa !11
  %45 = call double @llvm.fabs.f64(double %44)
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %46, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = call double @r8_sign(double noundef %51)
  %53 = call double @llvm.fmuladd.f64(double %45, double %52, double %43)
  %54 = load ptr, ptr %10, align 8, !tbaa !9
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %54, i64 %57
  store double %53, ptr %58, align 8, !tbaa !11
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = sub nsw i32 %59, %60
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  %66 = load ptr, ptr %10, align 8, !tbaa !9
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  call void @r8vec_copy(i32 noundef %61, ptr noundef %65, ptr noundef %69)
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = sub nsw i32 %70, %71
  %73 = add nsw i32 %72, 1
  %74 = load ptr, ptr %10, align 8, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %74, i64 %76
  %78 = getelementptr inbounds double, ptr %77, i64 -1
  %79 = call double @r8vec_norm_l2(i32 noundef %73, ptr noundef %78)
  store double %79, ptr %9, align 8, !tbaa !11
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  store i32 %81, ptr %8, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %98, %37
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %86, label %101

86:                                               ; preds = %82
  %87 = load ptr, ptr %10, align 8, !tbaa !9
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !11
  %92 = load double, ptr %9, align 8, !tbaa !11
  %93 = fdiv double %91, %92
  %94 = load ptr, ptr %10, align 8, !tbaa !9
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  store double %93, ptr %97, align 8, !tbaa !11
  br label %98

98:                                               ; preds = %86
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %8, align 4, !tbaa !5
  br label %82, !llvm.loop !13

101:                                              ; preds = %82
  %102 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %102, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %103

103:                                              ; preds = %101, %35, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %104 = load ptr, ptr %4, align 8
  ret ptr %104
}

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_copy(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8vec_zeros_new(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_norm_l2(i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 }

!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"}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

; Function Attrs: nounwind uwtable
declare dso_local double @r8_sign(double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @r8vec_house_column(i32 noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = tail call ptr @r8vec_zeros_new(i32 noundef %0)
  %5 = icmp sgt i32 %2, 0
  %.not = icmp sgt i32 %0, %2
  %or.cond = and i1 %5, %.not
  br i1 %or.cond, label %6, label %.loopexit

6:                                                ; preds = %3
  %7 = add nuw nsw i32 %0, 1
  %8 = sub i32 %7, %2
  %9 = zext nneg i32 %2 to i64
  %10 = getelementptr inbounds double, ptr %1, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 -8
  %12 = tail call double @r8vec_norm_l2(i32 noundef %8, ptr noundef nonnull %11)
  %13 = fcmp oeq double %12, 0.000000e+00
  br i1 %13, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %14 = add nsw i32 %2, -1
  %15 = zext nneg i32 %14 to i64
  %16 = getelementptr inbounds double, ptr %1, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = tail call double @llvm.fabs.f64(double %12)
  %19 = tail call double @r8_sign(double noundef %17)
  %20 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %17)
  %21 = getelementptr inbounds double, ptr %4, i64 %15
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = sub nsw i32 %0, %2
  %23 = getelementptr inbounds double, ptr %4, i64 %9
  tail call void @r8vec_copy(i32 noundef %22, ptr noundef nonnull %10, ptr noundef nonnull %23)
  %24 = add nsw i32 %22, 1
  %25 = getelementptr inbounds i8, ptr %23, i64 -8
  %26 = tail call double @r8vec_norm_l2(i32 noundef %24, ptr noundef nonnull %25)
  %smax = tail call i32 @llvm.smax.i32(i32 %2, i32 %0)
  %27 = sub nsw i32 %smax, %2
  %28 = zext i32 %27 to i64
  %29 = add nuw nsw i64 %28, 1
  %min.iters.check.not = icmp slt i32 %2, %0
  br i1 %min.iters.check.not, label %vector.ph, label %.lr.ph.preheader44

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %29, 8589934590
  %ind.end = add nuw nsw i64 %n.vec, %15
  %broadcast.splatinsert = insertelement <2 x double> poison, double %26, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  %invariant.gep = getelementptr double, ptr %4, i64 %15
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %gep = getelementptr double, ptr %invariant.gep, i64 %index
  %wide.load = load <2 x double>, ptr %gep, align 8, !tbaa !5
  %30 = fdiv <2 x double> %wide.load, %broadcast.splat
  store <2 x double> %30, ptr %gep, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %29, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader44

.lr.ph.preheader44:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ %15, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader44, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader44 ]
  %32 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fdiv double %33, %26
  store double %34, ptr %32, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = trunc nuw i64 %indvars.iv.next to i32
  %36 = icmp slt i32 %35, %0
  br i1 %36, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %middle.block, %6, %3
  ret ptr %4
}

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_copy(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8vec_zeros_new(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_norm_l2(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass