; 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_identity_new(i32 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
define dso_local ptr @r8mat_orth_uniform_new(i32 noundef %0, ptr noundef %1) #2 {
  %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
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = call ptr @r8mat_identity_new(i32 noundef %11)
  store ptr %12, ptr %8, align 8, !tbaa !9
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = mul i64 %14, 8
  %16 = call noalias ptr @malloc(i64 noundef %15) #5
  store ptr %16, ptr %5, align 8, !tbaa !9
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %67, %2
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %70

21:                                               ; preds = %17
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %32, %21
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %35

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

32:                                               ; preds = %26
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %6, align 4, !tbaa !5
  br label %22, !llvm.loop !13

35:                                               ; preds = %22
  %36 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %49, %35
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = icmp sle i32 %38, %39
  br i1 %40, label %41, label %52

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

49:                                               ; preds = %41
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %37, !llvm.loop !15

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

67:                                               ; preds = %52
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %17, !llvm.loop !16

70:                                               ; preds = %17
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %71) #4
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  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 %72
}

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_identity_new(i32 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
define dso_local ptr @r8mat_orth_uniform_new(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @r8mat_identity_new(i32 noundef %0)
  %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 = %2
  %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 %3, 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 %3)
  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, %2
  tail call void @free(ptr noundef %6) #5
  ret ptr %3
}

; 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