; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RNBasics/RNSvd.ll (Z19clr_top_subdiag_eltPdiiS_S_iii)

; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_Z6fhypotdd(double noundef, double noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11rotate_colsiiddPdiiii(i32 noundef, i32 noundef, double noundef, double noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11rotate_rowsiiddPdiiii(i32 noundef, i32 noundef, double noundef, double noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z19clr_top_subdiag_eltPdiiS_S_iii(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) #0 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  store i32 %7, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #2
  %23 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %23, ptr %17, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %171, %8
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load i32, ptr %15, align 4, !tbaa !9
  %27 = load i32, ptr %17, align 4, !tbaa !9
  %28 = mul nsw i32 %26, %27
  %29 = load i32, ptr %17, align 4, !tbaa !9
  %30 = add nsw i32 %28, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %25, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !11
  store double %33, ptr %18, align 8, !tbaa !11
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %15, align 4, !tbaa !9
  %36 = load i32, ptr %17, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  %38 = mul nsw i32 %35, %37
  %39 = load i32, ptr %17, align 4, !tbaa !9
  %40 = add nsw i32 %38, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %34, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  store double %43, ptr %19, align 8, !tbaa !11
  %44 = load double, ptr %18, align 8, !tbaa !11
  %45 = load double, ptr %19, align 8, !tbaa !11
  %46 = call noundef double @_Z6fhypotdd(double noundef %44, double noundef %45)
  store double %46, ptr %20, align 8, !tbaa !11
  %47 = load double, ptr %18, align 8, !tbaa !11
  %48 = load double, ptr %20, align 8, !tbaa !11
  %49 = fdiv double %47, %48
  store double %49, ptr %21, align 8, !tbaa !11
  %50 = load double, ptr %19, align 8, !tbaa !11
  %51 = load double, ptr %20, align 8, !tbaa !11
  %52 = fdiv double %50, %51
  store double %52, ptr %22, align 8, !tbaa !11
  %53 = load double, ptr %20, align 8, !tbaa !11
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %15, align 4, !tbaa !9
  %56 = load i32, ptr %17, align 4, !tbaa !9
  %57 = mul nsw i32 %55, %56
  %58 = load i32, ptr %17, align 4, !tbaa !9
  %59 = add nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %54, i64 %60
  store double %53, ptr %61, align 8, !tbaa !11
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i32, ptr %15, align 4, !tbaa !9
  %64 = load i32, ptr %17, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  %66 = mul nsw i32 %63, %65
  %67 = load i32, ptr %17, align 4, !tbaa !9
  %68 = add nsw i32 %66, %67
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %62, i64 %69
  store double 0.000000e+00, ptr %70, align 8, !tbaa !11
  %71 = load i32, ptr %17, align 4, !tbaa !9
  %72 = load i32, ptr %17, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  %74 = load double, ptr %21, align 8, !tbaa !11
  %75 = load double, ptr %22, align 8, !tbaa !11
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load i32, ptr %17, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  %79 = load i32, ptr %17, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = icmp eq i32 %80, %81
  %83 = zext i1 %82 to i64
  %84 = select i1 %82, i32 1, i32 2
  %85 = load i32, ptr %14, align 4, !tbaa !9
  %86 = load i32, ptr %15, align 4, !tbaa !9
  call void @_Z11rotate_rowsiiddPdiiii(i32 noundef %71, i32 noundef %73, double noundef %74, double noundef %75, ptr noundef %76, i32 noundef %78, i32 noundef %84, i32 noundef %85, i32 noundef %86)
  %87 = load i32, ptr %17, align 4, !tbaa !9
  %88 = load i32, ptr %17, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  %90 = load double, ptr %21, align 8, !tbaa !11
  %91 = load double, ptr %22, align 8, !tbaa !11
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = load i32, ptr %14, align 4, !tbaa !9
  %94 = load i32, ptr %14, align 4, !tbaa !9
  %95 = load i32, ptr %16, align 4, !tbaa !9
  call void @_Z11rotate_colsiiddPdiiii(i32 noundef %87, i32 noundef %89, double noundef %90, double noundef %91, ptr noundef %92, i32 noundef 0, i32 noundef %93, i32 noundef %94, i32 noundef %95)
  %96 = load i32, ptr %17, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  %98 = load i32, ptr %11, align 4, !tbaa !9
  %99 = icmp eq i32 %97, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %24
  br label %174

101:                                              ; preds = %24
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  %103 = load i32, ptr %15, align 4, !tbaa !9
  %104 = load i32, ptr %17, align 4, !tbaa !9
  %105 = mul nsw i32 %103, %104
  %106 = load i32, ptr %17, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  %108 = add nsw i32 %105, %107
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds double, ptr %102, i64 %109
  %111 = load double, ptr %110, align 8, !tbaa !11
  store double %111, ptr %18, align 8, !tbaa !11
  %112 = load ptr, ptr %9, align 8, !tbaa !5
  %113 = load i32, ptr %15, align 4, !tbaa !9
  %114 = load i32, ptr %17, align 4, !tbaa !9
  %115 = mul nsw i32 %113, %114
  %116 = load i32, ptr %17, align 4, !tbaa !9
  %117 = add nsw i32 %116, 2
  %118 = add nsw i32 %115, %117
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds double, ptr %112, i64 %119
  %121 = load double, ptr %120, align 8, !tbaa !11
  store double %121, ptr %19, align 8, !tbaa !11
  %122 = load double, ptr %18, align 8, !tbaa !11
  %123 = load double, ptr %19, align 8, !tbaa !11
  %124 = call noundef double @_Z6fhypotdd(double noundef %122, double noundef %123)
  store double %124, ptr %20, align 8, !tbaa !11
  %125 = load double, ptr %18, align 8, !tbaa !11
  %126 = load double, ptr %20, align 8, !tbaa !11
  %127 = fdiv double %125, %126
  store double %127, ptr %21, align 8, !tbaa !11
  %128 = load double, ptr %19, align 8, !tbaa !11
  %129 = load double, ptr %20, align 8, !tbaa !11
  %130 = fdiv double %128, %129
  store double %130, ptr %22, align 8, !tbaa !11
  %131 = load double, ptr %20, align 8, !tbaa !11
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = load i32, ptr %17, align 4, !tbaa !9
  %135 = mul nsw i32 %133, %134
  %136 = load i32, ptr %17, align 4, !tbaa !9
  %137 = add nsw i32 %136, 1
  %138 = add nsw i32 %135, %137
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds double, ptr %132, i64 %139
  store double %131, ptr %140, align 8, !tbaa !11
  %141 = load ptr, ptr %9, align 8, !tbaa !5
  %142 = load i32, ptr %15, align 4, !tbaa !9
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = mul nsw i32 %142, %143
  %145 = load i32, ptr %17, align 4, !tbaa !9
  %146 = add nsw i32 %145, 2
  %147 = add nsw i32 %144, %146
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds double, ptr %141, i64 %148
  store double 0.000000e+00, ptr %149, align 8, !tbaa !11
  %150 = load i32, ptr %17, align 4, !tbaa !9
  %151 = add nsw i32 %150, 1
  %152 = load i32, ptr %17, align 4, !tbaa !9
  %153 = add nsw i32 %152, 2
  %154 = load double, ptr %21, align 8, !tbaa !11
  %155 = load double, ptr %22, align 8, !tbaa !11
  %156 = load ptr, ptr %9, align 8, !tbaa !5
  %157 = load i32, ptr %17, align 4, !tbaa !9
  %158 = add nsw i32 %157, 1
  %159 = load i32, ptr %14, align 4, !tbaa !9
  %160 = load i32, ptr %15, align 4, !tbaa !9
  call void @_Z11rotate_colsiiddPdiiii(i32 noundef %151, i32 noundef %153, double noundef %154, double noundef %155, ptr noundef %156, i32 noundef %158, i32 noundef 2, i32 noundef %159, i32 noundef %160)
  %161 = load i32, ptr %17, align 4, !tbaa !9
  %162 = add nsw i32 %161, 1
  %163 = load i32, ptr %17, align 4, !tbaa !9
  %164 = add nsw i32 %163, 2
  %165 = load double, ptr %21, align 8, !tbaa !11
  %166 = load double, ptr %22, align 8, !tbaa !11
  %167 = load ptr, ptr %13, align 8, !tbaa !5
  %168 = load i32, ptr %15, align 4, !tbaa !9
  %169 = load i32, ptr %16, align 4, !tbaa !9
  %170 = load i32, ptr %15, align 4, !tbaa !9
  call void @_Z11rotate_rowsiiddPdiiii(i32 noundef %162, i32 noundef %164, double noundef %165, double noundef %166, ptr noundef %167, i32 noundef 0, i32 noundef %168, i32 noundef %169, i32 noundef %170)
  br label %171

171:                                              ; preds = %101
  %172 = load i32, ptr %17, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %17, align 4, !tbaa !9
  br label %24, !llvm.loop !13

174:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  ret void
}

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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 nounwind uwtable
declare dso_local noundef double @_Z6fhypotdd(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11rotate_colsiiddPdiiii(i32 noundef, i32 noundef, double noundef, double noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11rotate_rowsiiddPdiiii(i32 noundef, i32 noundef, double noundef, double noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z19clr_top_subdiag_eltPdiiS_S_iii(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = sext i32 %1 to i64
  %10 = sext i32 %6 to i64
  %sext = sext i32 %2 to i64
  br label %11

11:                                               ; preds = %27, %8
  %indvars.iv = phi i64 [ %indvars.iv.next, %27 ], [ %9, %8 ]
  %indvars84 = trunc i64 %indvars.iv to i32
  %12 = mul nsw i32 %indvars84, %6
  %13 = sext i32 %12 to i64
  %14 = getelementptr double, ptr %0, i64 %indvars.iv
  %15 = getelementptr double, ptr %14, i64 %13
  %16 = load double, ptr %15, align 8, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %indvars = trunc i64 %indvars.iv.next to i32
  %17 = mul nsw i32 %indvars, %6
  %18 = sext i32 %17 to i64
  %19 = getelementptr double, ptr %0, i64 %indvars.iv
  %20 = getelementptr double, ptr %19, i64 %18
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = tail call noundef double @_Z6fhypotdd(double noundef %16, double noundef %21)
  %23 = fdiv double %16, %22
  %24 = fdiv double %21, %22
  store double %22, ptr %15, align 8, !tbaa !5
  store double 0.000000e+00, ptr %20, align 8, !tbaa !5
  %25 = icmp eq i64 %indvars.iv.next, %sext
  %26 = select i1 %25, i32 1, i32 2
  tail call void @_Z11rotate_rowsiiddPdiiii(i32 noundef %indvars84, i32 noundef %indvars, double noundef %23, double noundef %24, ptr noundef %0, i32 noundef %indvars, i32 noundef %26, i32 noundef %5, i32 noundef %6)
  tail call void @_Z11rotate_colsiiddPdiiii(i32 noundef %indvars84, i32 noundef %indvars, double noundef %23, double noundef %24, ptr noundef %3, i32 noundef 0, i32 noundef %5, i32 noundef %5, i32 noundef %7)
  br i1 %25, label %40, label %27

27:                                               ; preds = %11
  %28 = mul nsw i64 %indvars.iv, %10
  %29 = getelementptr double, ptr %0, i64 %28
  %30 = getelementptr double, ptr %29, i64 %indvars.iv.next
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = add nsw i32 %indvars84, 2
  %33 = getelementptr double, ptr %0, i64 %28
  %34 = getelementptr double, ptr %33, i64 %indvars.iv
  %35 = getelementptr i8, ptr %34, i64 16
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = tail call noundef double @_Z6fhypotdd(double noundef %31, double noundef %36)
  %38 = fdiv double %31, %37
  %39 = fdiv double %36, %37
  store double %37, ptr %30, align 8, !tbaa !5
  store double 0.000000e+00, ptr %35, align 8, !tbaa !5
  tail call void @_Z11rotate_colsiiddPdiiii(i32 noundef %indvars, i32 noundef %32, double noundef %38, double noundef %39, ptr noundef nonnull %0, i32 noundef %indvars, i32 noundef 2, i32 noundef %5, i32 noundef %6)
  tail call void @_Z11rotate_rowsiiddPdiiii(i32 noundef %indvars, i32 noundef %32, double noundef %38, double noundef %39, ptr noundef %4, i32 noundef 0, i32 noundef %6, i32 noundef %7, i32 noundef %6)
  br label %11, !llvm.loop !9

40:                                               ; preds = %11
  ret void
}

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass