; LLVM IR from kkumatani/distant_speech_recognition :: btk20_src/matrix/blas1_c.ll (Z6scnrm2iPSt7complexIfEi)

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

%"class.std::complex" = 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: mustprogress nounwind uwtable
declare dso_local noundef float @_Z6r4_absf(float noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8)) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #3

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

15:                                               ; preds = %3
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %15, %3
  store float 0.000000e+00, ptr %12, align 4, !tbaa !11
  br label %112

19:                                               ; preds = %15
  store float 0.000000e+00, ptr %9, align 4, !tbaa !11
  store float 1.000000e+00, ptr %10, align 4, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %104, %19
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %107

24:                                               ; preds = %20
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %"class.std::complex", ptr %25, i64 %27
  %29 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %28)
  %30 = fpext float %29 to double
  %31 = fcmp une double %30, 0.000000e+00
  br i1 %31, label %32, label %62

32:                                               ; preds = %24
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %"class.std::complex", ptr %33, i64 %35
  %37 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %36)
  %38 = call noundef float @_Z6r4_absf(float noundef %37)
  store float %38, ptr %11, align 4, !tbaa !11
  %39 = load float, ptr %9, align 4, !tbaa !11
  %40 = load float, ptr %11, align 4, !tbaa !11
  %41 = fcmp olt float %39, %40
  br i1 %41, label %42, label %52

42:                                               ; preds = %32
  %43 = load float, ptr %10, align 4, !tbaa !11
  %44 = fpext float %43 to double
  %45 = load float, ptr %9, align 4, !tbaa !11
  %46 = load float, ptr %11, align 4, !tbaa !11
  %47 = fdiv float %45, %46
  %48 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %47, i32 noundef 2)
  %49 = call double @llvm.fmuladd.f64(double %44, double %48, double 1.000000e+00)
  %50 = fptrunc double %49 to float
  store float %50, ptr %10, align 4, !tbaa !11
  %51 = load float, ptr %11, align 4, !tbaa !11
  store float %51, ptr %9, align 4, !tbaa !11
  br label %61

52:                                               ; preds = %32
  %53 = load float, ptr %10, align 4, !tbaa !11
  %54 = fpext float %53 to double
  %55 = load float, ptr %11, align 4, !tbaa !11
  %56 = load float, ptr %9, align 4, !tbaa !11
  %57 = fdiv float %55, %56
  %58 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %57, i32 noundef 2)
  %59 = fadd double %54, %58
  %60 = fptrunc double %59 to float
  store float %60, ptr %10, align 4, !tbaa !11
  br label %61

61:                                               ; preds = %52, %42
  br label %62

62:                                               ; preds = %61, %24
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %"class.std::complex", ptr %63, i64 %65
  %67 = call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %66)
  %68 = fpext float %67 to double
  %69 = fcmp une double %68, 0.000000e+00
  br i1 %69, label %70, label %100

70:                                               ; preds = %62
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %"class.std::complex", ptr %71, i64 %73
  %75 = call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %74)
  %76 = call noundef float @_Z6r4_absf(float noundef %75)
  store float %76, ptr %11, align 4, !tbaa !11
  %77 = load float, ptr %9, align 4, !tbaa !11
  %78 = load float, ptr %11, align 4, !tbaa !11
  %79 = fcmp olt float %77, %78
  br i1 %79, label %80, label %90

80:                                               ; preds = %70
  %81 = load float, ptr %10, align 4, !tbaa !11
  %82 = fpext float %81 to double
  %83 = load float, ptr %9, align 4, !tbaa !11
  %84 = load float, ptr %11, align 4, !tbaa !11
  %85 = fdiv float %83, %84
  %86 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %85, i32 noundef 2)
  %87 = call double @llvm.fmuladd.f64(double %82, double %86, double 1.000000e+00)
  %88 = fptrunc double %87 to float
  store float %88, ptr %10, align 4, !tbaa !11
  %89 = load float, ptr %11, align 4, !tbaa !11
  store float %89, ptr %9, align 4, !tbaa !11
  br label %99

90:                                               ; preds = %70
  %91 = load float, ptr %10, align 4, !tbaa !11
  %92 = fpext float %91 to double
  %93 = load float, ptr %11, align 4, !tbaa !11
  %94 = load float, ptr %9, align 4, !tbaa !11
  %95 = fdiv float %93, %94
  %96 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %95, i32 noundef 2)
  %97 = fadd double %92, %96
  %98 = fptrunc double %97 to float
  store float %98, ptr %10, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %90, %80
  br label %100

100:                                              ; preds = %99, %62
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = add nsw i32 %101, %102
  store i32 %103, ptr %8, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %100
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %7, align 4, !tbaa !5
  br label %20, !llvm.loop !13

107:                                              ; preds = %20
  %108 = load float, ptr %9, align 4, !tbaa !11
  %109 = load float, ptr %10, align 4, !tbaa !11
  %110 = call noundef float @_ZSt4sqrtf(float noundef %109)
  %111 = fmul float %108, %110
  store float %111, ptr %12, align 4, !tbaa !11
  br label %112

112:                                              ; preds = %107, %18
  %113 = load float, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret float %113
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { inlinehint 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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"

%"class.std::complex" = type { { float, float } }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z6r4_absf(float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_Z6scnrm2iPSt7complexIfEi(i32 noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp slt i32 %0, 1
  %5 = icmp slt i32 %2, 1
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %48, label %.preheader.preheader

.preheader.preheader:                             ; preds = %3
  %6 = zext nneg i32 %2 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %43
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %43 ]
  %.03651 = phi float [ 1.000000e+00, %.preheader.preheader ], [ %.2, %43 ]
  %.03750 = phi float [ 0.000000e+00, %.preheader.preheader ], [ %.239, %43 ]
  %.04148 = phi i32 [ 0, %.preheader.preheader ], [ %44, %43 ]
  %7 = getelementptr inbounds %"class.std::complex", ptr %1, i64 %indvars.iv
  %8 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %7)
  %9 = fcmp une float %8, 0.000000e+00
  br i1 %9, label %10, label %25

10:                                               ; preds = %.preheader
  %11 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %7)
  %12 = tail call noundef float @_Z6r4_absf(float noundef %11)
  %13 = fcmp olt float %.03750, %12
  %14 = fpext float %.03651 to double
  br i1 %13, label %15, label %20

15:                                               ; preds = %10
  %16 = fdiv float %.03750, %12
  %17 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %16, i32 noundef 2)
  %18 = tail call double @llvm.fmuladd.f64(double %14, double %17, double 1.000000e+00)
  %19 = fptrunc double %18 to float
  br label %25

20:                                               ; preds = %10
  %21 = fdiv float %12, %.03750
  %22 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %21, i32 noundef 2)
  %23 = fadd double %22, %14
  %24 = fptrunc double %23 to float
  br label %25

25:                                               ; preds = %15, %20, %.preheader
  %.138 = phi float [ %12, %15 ], [ %.03750, %20 ], [ %.03750, %.preheader ]
  %.1 = phi float [ %19, %15 ], [ %24, %20 ], [ %.03651, %.preheader ]
  %26 = tail call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %7)
  %27 = fcmp une float %26, 0.000000e+00
  br i1 %27, label %28, label %43

28:                                               ; preds = %25
  %29 = tail call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %7)
  %30 = tail call noundef float @_Z6r4_absf(float noundef %29)
  %31 = fcmp olt float %.138, %30
  %32 = fpext float %.1 to double
  br i1 %31, label %33, label %38

33:                                               ; preds = %28
  %34 = fdiv float %.138, %30
  %35 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %34, i32 noundef 2)
  %36 = tail call double @llvm.fmuladd.f64(double %32, double %35, double 1.000000e+00)
  %37 = fptrunc double %36 to float
  br label %43

38:                                               ; preds = %28
  %39 = fdiv float %30, %.138
  %40 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %39, i32 noundef 2)
  %41 = fadd double %40, %32
  %42 = fptrunc double %41 to float
  br label %43

43:                                               ; preds = %33, %38, %25
  %.239 = phi float [ %30, %33 ], [ %.138, %38 ], [ %.138, %25 ]
  %.2 = phi float [ %37, %33 ], [ %42, %38 ], [ %.1, %25 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, %6
  %44 = add nuw nsw i32 %.04148, 1
  %exitcond.not = icmp eq i32 %44, %0
  br i1 %exitcond.not, label %45, label %.preheader, !llvm.loop !5

45:                                               ; preds = %43
  %46 = tail call noundef float @_ZSt4sqrtf(float noundef %.2)
  %47 = fmul float %.239, %46
  br label %48

48:                                               ; preds = %3, %45
  %.0 = phi float [ %47, %45 ], [ 0.000000e+00, %3 ]
  ret float %.0
}

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

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 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 = { inlinehint 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 = { mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass