; LLVM IR from LithoSimulator/K-Litho :: K-Litho-TCC/source.ll (Z21createCrossQuadrupoleRSt6vectorIfSaIfEEiR15CrossQuadrupole)

; 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"

%struct.CrossQuadrupole = type { float, float }

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z21createCrossQuadrupoleRSt6vectorIfSaIfEEiR15CrossQuadrupole(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, ptr noundef nonnull align 4 dereferenceable(8) %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 i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca [4 x [2 x i32]], align 16
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.CrossQuadrupole, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = sub nsw i32 %23, 1
  %25 = sdiv i32 %24, 2
  %26 = sitofp i32 %25 to float
  %27 = fmul float %22, %26
  %28 = fptosi float %27 to i32
  store i32 %28, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.CrossQuadrupole, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !14
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = sdiv i32 %33, 2
  %35 = sitofp i32 %34 to float
  %36 = fmul float %31, %35
  %37 = fptosi float %36 to i32
  store i32 %37, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sub nsw i32 %38, 1
  %40 = sdiv i32 %39, 2
  store i32 %40, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sub nsw i32 %41, 1
  %43 = sdiv i32 %42, 2
  store i32 %43, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %138, %3
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %141

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %134, %49
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %137

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #4
  %56 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %56, ptr %14, align 4, !tbaa !9
  %57 = getelementptr inbounds i32, ptr %14, i64 1
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = add nsw i32 %58, %59
  store i32 %60, ptr %57, align 4, !tbaa !9
  %61 = getelementptr inbounds [2 x i32], ptr %14, i64 1
  %62 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %62, ptr %61, align 4, !tbaa !9
  %63 = getelementptr inbounds i32, ptr %61, i64 1
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = sub nsw i32 %64, %65
  store i32 %66, ptr %63, align 4, !tbaa !9
  %67 = getelementptr inbounds [2 x i32], ptr %14, i64 2
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = add nsw i32 %68, %69
  store i32 %70, ptr %67, align 4, !tbaa !9
  %71 = getelementptr inbounds i32, ptr %67, i64 1
  %72 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %72, ptr %71, align 4, !tbaa !9
  %73 = getelementptr inbounds [2 x i32], ptr %14, i64 3
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = sub nsw i32 %74, %75
  store i32 %76, ptr %73, align 4, !tbaa !9
  %77 = getelementptr inbounds i32, ptr %73, i64 1
  %78 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %78, ptr %77, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #4
  store i8 0, ptr %15, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %116, %55
  %80 = load i32, ptr %16, align 4, !tbaa !9
  %81 = icmp slt i32 %80, 4
  br i1 %81, label %83, label %82

82:                                               ; preds = %79
  store i32 8, ptr %12, align 4
  br label %119

83:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = load i32, ptr %16, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [4 x [2 x i32]], ptr %14, i64 0, i64 %86
  %88 = getelementptr inbounds [2 x i32], ptr %87, i64 0, i64 0
  %89 = load i32, ptr %88, align 8, !tbaa !9
  %90 = sub nsw i32 %84, %89
  %91 = sitofp i32 %90 to double
  store double %91, ptr %17, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = load i32, ptr %16, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [4 x [2 x i32]], ptr %14, i64 0, i64 %94
  %96 = getelementptr inbounds [2 x i32], ptr %95, i64 0, i64 1
  %97 = load i32, ptr %96, align 4, !tbaa !9
  %98 = sub nsw i32 %92, %97
  %99 = sitofp i32 %98 to double
  store double %99, ptr %18, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %100 = load double, ptr %17, align 8, !tbaa !17
  %101 = load double, ptr %17, align 8, !tbaa !17
  %102 = load double, ptr %18, align 8, !tbaa !17
  %103 = load double, ptr %18, align 8, !tbaa !17
  %104 = fmul double %102, %103
  %105 = call double @llvm.fmuladd.f64(double %100, double %101, double %104)
  %106 = call double @sqrt(double noundef %105) #4
  store double %106, ptr %19, align 8, !tbaa !17
  %107 = load double, ptr %19, align 8, !tbaa !17
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = sitofp i32 %108 to double
  %110 = fcmp ole double %107, %109
  br i1 %110, label %111, label %112

111:                                              ; preds = %83
  store i8 1, ptr %15, align 1, !tbaa !15
  store i32 8, ptr %12, align 4
  br label %113

112:                                              ; preds = %83
  store i32 0, ptr %12, align 4
  br label %113

113:                                              ; preds = %112, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  %114 = load i32, ptr %12, align 4
  switch i32 %114, label %119 [
    i32 0, label %115
  ]

115:                                              ; preds = %113
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %16, align 4, !tbaa !9
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %16, align 4, !tbaa !9
  br label %79, !llvm.loop !19

119:                                              ; preds = %113, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %120

120:                                              ; preds = %119
  %121 = load i8, ptr %15, align 1, !tbaa !15, !range !21, !noundef !22
  %122 = trunc i8 %121 to i1
  %123 = zext i1 %122 to i64
  %124 = select i1 %122, double 1.000000e+00, double 0.000000e+00
  %125 = fptrunc double %124 to float
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = load i32, ptr %11, align 4, !tbaa !9
  %128 = load i32, ptr %5, align 4, !tbaa !9
  %129 = mul nsw i32 %127, %128
  %130 = load i32, ptr %13, align 4, !tbaa !9
  %131 = add nsw i32 %129, %130
  %132 = sext i32 %131 to i64
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %126, i64 noundef %132) #4
  store float %125, ptr %133, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #4
  br label %134

134:                                              ; preds = %120
  %135 = load i32, ptr %13, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %13, align 4, !tbaa !9
  br label %50, !llvm.loop !24

137:                                              ; preds = %54
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %11, align 4, !tbaa !9
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %11, align 4, !tbaa !9
  br label %44, !llvm.loop !25

141:                                              ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %7) #4
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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, !13, i64 4}
!12 = !{!"_ZTS15CrossQuadrupole", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!13, !13, i64 0}
!24 = distinct !{!24, !20}
!25 = distinct !{!25, !20}


; 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 nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z21createCrossQuadrupoleRSt6vectorIfSaIfEEiR15CrossQuadrupole(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #0 {
  %4 = add nsw i32 %1, -1
  %5 = sdiv i32 %4, 2
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.preheader.lr.ph, label %._crit_edge49

.preheader.lr.ph:                                 ; preds = %3
  %7 = load float, ptr %2, align 4, !tbaa !5
  %8 = sitofp i32 %5 to float
  %9 = fmul float %7, %8
  %10 = fptosi float %9 to i32
  %11 = getelementptr inbounds i8, ptr %2, i64 4
  %12 = load float, ptr %11, align 4, !tbaa !10
  %13 = fmul float %12, %8
  %14 = fptosi float %13 to i32
  %15 = add nsw i32 %5, %14
  %16 = sub nsw i32 %5, %14
  %17 = sitofp i32 %10 to double
  %18 = zext nneg i32 %1 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %._crit_edge.us ], [ 0, %.preheader.lr.ph ]
  %19 = mul nuw nsw i64 %indvars.iv52, %18
  %20 = trunc nuw nsw i64 %indvars.iv52 to i32
  %21 = sub nsw i32 %20, %15
  %22 = sitofp i32 %21 to double
  %23 = fmul double %22, %22
  %24 = sub nsw i32 %20, %16
  %25 = sitofp i32 %24 to double
  %26 = fmul double %25, %25
  %27 = sub nsw i32 %20, %5
  %28 = sitofp i32 %27 to double
  %29 = fmul double %28, %28
  br label %30

30:                                               ; preds = %.preheader.us, %50
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %50 ]
  %31 = trunc nuw nsw i64 %indvars.iv to i32
  %32 = sub nsw i32 %31, %5
  %33 = sitofp i32 %32 to double
  %34 = tail call double @llvm.fmuladd.f64(double %33, double %33, double %23)
  %sqrt.us = tail call double @llvm.sqrt.f64(double %34)
  %35 = fcmp ugt double %sqrt.us, %17
  br i1 %35, label %36, label %50

36:                                               ; preds = %30
  %37 = tail call double @llvm.fmuladd.f64(double %33, double %33, double %26)
  %sqrt.us.1 = tail call double @llvm.sqrt.f64(double %37)
  %38 = fcmp ugt double %sqrt.us.1, %17
  br i1 %38, label %39, label %50

39:                                               ; preds = %36
  %40 = sub nsw i32 %31, %15
  %41 = sitofp i32 %40 to double
  %42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %29)
  %sqrt.us.2 = tail call double @llvm.sqrt.f64(double %42)
  %43 = fcmp ugt double %sqrt.us.2, %17
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  %45 = sub nsw i32 %31, %16
  %46 = sitofp i32 %45 to double
  %47 = tail call double @llvm.fmuladd.f64(double %46, double %46, double %29)
  %sqrt.us.3 = tail call double @llvm.sqrt.f64(double %47)
  %48 = fcmp ugt double %sqrt.us.3, %17
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  br label %50

50:                                               ; preds = %49, %44, %39, %36, %30
  %51 = phi float [ 1.000000e+00, %30 ], [ 1.000000e+00, %36 ], [ 1.000000e+00, %39 ], [ 1.000000e+00, %44 ], [ 0.000000e+00, %49 ]
  %52 = add nuw nsw i64 %indvars.iv, %19
  %53 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %52) #3
  store float %51, ptr %53, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %18
  br i1 %exitcond.not, label %._crit_edge.us, label %30, !llvm.loop !12

._crit_edge.us:                                   ; preds = %50
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next53, %18
  br i1 %exitcond56.not, label %._crit_edge49, label %.preheader.us, !llvm.loop !14

._crit_edge49:                                    ; preds = %._crit_edge.us, %3
  ret void
}

; Function Attrs: mustprogress 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.sqrt.f64(double) #2

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_ZTS15CrossQuadrupole", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass