; 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
declare dso_local double @r8_normal_01(ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

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

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

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

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

18:                                               ; preds = %68, %3
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %71

22:                                               ; preds = %18
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %33, %22
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %36

27:                                               ; preds = %23
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = sub nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %28, i64 %31
  store double 0.000000e+00, ptr %32, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %27
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %8, align 4, !tbaa !5
  br label %23, !llvm.loop !13

36:                                               ; preds = %23
  %37 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %37, ptr %8, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %50, %36
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %42, label %53

42:                                               ; preds = %38
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = call double @r8_normal_01(ptr noundef %43)
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %45, i64 %48
  store double %44, ptr %49, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %42
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %8, align 4, !tbaa !5
  br label %38, !llvm.loop !15

53:                                               ; preds = %38
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = call ptr @r8vec_house_column(i32 noundef %54, ptr noundef %55, i32 noundef %56)
  store ptr %57, ptr %11, align 8, !tbaa !9
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = load ptr, ptr %6, align 8, !tbaa !9
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = call ptr @r8mat_house_axh_new(i32 noundef %58, ptr noundef %59, ptr noundef %60)
  store ptr %61, ptr %10, align 8, !tbaa !9
  %62 = load ptr, ptr %11, align 8, !tbaa !9
  call void @free(ptr noundef %62) #4
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !9
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  call void @r8mat_copy(i32 noundef %63, i32 noundef %64, ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  call void @free(ptr noundef %67) #4
  br label %68

68:                                               ; preds = %53
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %9, align 4, !tbaa !5
  br label %18, !llvm.loop !16

71:                                               ; preds = %18
  %72 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %72) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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 "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}
!16 = distinct !{!16, !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: nounwind uwtable
declare dso_local double @r8_normal_01(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @r8mat_orth_uniform(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  tail call void @r8mat_identity(i32 noundef %0, ptr noundef %2)
  %4 = sext i32 %0 to i64
  %5 = shl nsw i64 %4, 3
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #4
  %7 = icmp sgt i32 %0, 1
  br i1 %7, label %.preheader32.lr.ph, label %._crit_edge40

.preheader32.lr.ph:                               ; preds = %3
  %invariant.gep34 = getelementptr i8, ptr %6, i64 -8
  %8 = add nuw i32 %0, 1
  %9 = add nsw i32 %0, -1
  %wide.trip.count46 = zext nneg i32 %9 to i64
  %wide.trip.count = zext i32 %8 to i64
  br label %.preheader32

.preheader32:                                     ; preds = %.preheader32.lr.ph, %._crit_edge
  %indvars.iv = phi i64 [ 1, %.preheader32.lr.ph ], [ %indvars.iv.next, %._crit_edge ]
  %indvar = phi i64 [ 0, %.preheader32.lr.ph ], [ %indvar.next, %._crit_edge ]
  %indvars45 = trunc i64 %indvars.iv to i32
  %10 = icmp ugt i32 %indvars45, 1
  br i1 %10, label %.lr.ph.preheader, label %.lr.ph38.preheader

.lr.ph.preheader:                                 ; preds = %.preheader32
  %11 = shl nuw nsw i64 %indvar, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 %11, i1 false), !tbaa !5
  br label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %.preheader32, %.lr.ph.preheader
  br label %.lr.ph38

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %.lr.ph38
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph38 ], [ %indvars.iv, %.lr.ph38.preheader ]
  %12 = tail call double @r8_normal_01(ptr noundef %1)
  %gep35 = getelementptr double, ptr %invariant.gep34, i64 %indvars.iv42
  store double %12, ptr %gep35, align 8, !tbaa !5
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph38, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph38
  %13 = tail call ptr @r8vec_house_column(i32 noundef %0, ptr noundef nonnull %6, i32 noundef %indvars45)
  %14 = tail call ptr @r8mat_house_axh_new(i32 noundef %0, ptr noundef %2, ptr noundef %13)
  tail call void @free(ptr noundef %13) #5
  tail call void @r8mat_copy(i32 noundef %0, i32 noundef %0, ptr noundef %14, ptr noundef %2)
  tail call void @free(ptr noundef %14) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond47.not = icmp eq i64 %indvar.next, %wide.trip.count46
  br i1 %exitcond47.not, label %._crit_edge40, label %.preheader32, !llvm.loop !11

._crit_edge40:                                    ; preds = %._crit_edge, %3
  tail call void @free(ptr noundef %6) #5
  ret void
}

; 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 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 = { 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0) }
attributes #5 = { 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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass