; LLVM IR from kkumatani/distant_speech_recognition :: btk20_src/matrix/linpack_c.ll (Z5cpbdiPSt7complexIfEiiiPf)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5cpbdiPSt7complexIfEiiiPf(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %12 = load ptr, ptr %10, align 8, !tbaa !5
  %13 = getelementptr inbounds float, ptr %12, i64 0
  store float 1.000000e+00, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = getelementptr inbounds float, ptr %14, i64 1
  store float 0.000000e+00, ptr %15, align 4, !tbaa !11
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %103, %5
  %17 = load i32, ptr %11, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %20, label %106

20:                                               ; preds = %16
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds float, ptr %21, i64 0
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 1
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = mul nsw i32 %27, %28
  %30 = add nsw i32 %25, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %"class.std::complex", ptr %24, i64 %31
  %33 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %32)
  %34 = fmul float %23, %33
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = sub nsw i32 %37, 1
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = mul nsw i32 %38, %39
  %41 = add nsw i32 %36, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %"class.std::complex", ptr %35, i64 %42
  %44 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %43)
  %45 = fmul float %34, %44
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds float, ptr %46, i64 0
  store float %45, ptr %47, align 4, !tbaa !11
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds float, ptr %48, i64 0
  %50 = load float, ptr %49, align 4, !tbaa !11
  %51 = fpext float %50 to double
  %52 = fcmp oeq double %51, 0.000000e+00
  br i1 %52, label %53, label %54

53:                                               ; preds = %20
  br label %106

54:                                               ; preds = %20
  br label %55

55:                                               ; preds = %61, %54
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds float, ptr %56, i64 0
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = fpext float %58 to double
  %60 = fcmp olt double %59, 1.000000e+00
  br i1 %60, label %61, label %78

61:                                               ; preds = %55
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds float, ptr %62, i64 0
  %64 = load float, ptr %63, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = fmul double %65, 1.000000e+01
  %67 = fptrunc double %66 to float
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds float, ptr %68, i64 0
  store float %67, ptr %69, align 4, !tbaa !11
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds float, ptr %70, i64 1
  %72 = load float, ptr %71, align 4, !tbaa !11
  %73 = fpext float %72 to double
  %74 = fsub double %73, 1.000000e+00
  %75 = fptrunc double %74 to float
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds float, ptr %76, i64 1
  store float %75, ptr %77, align 4, !tbaa !11
  br label %55, !llvm.loop !13

78:                                               ; preds = %55
  br label %79

79:                                               ; preds = %85, %78
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = getelementptr inbounds float, ptr %80, i64 0
  %82 = load float, ptr %81, align 4, !tbaa !11
  %83 = fpext float %82 to double
  %84 = fcmp ole double 1.000000e+01, %83
  br i1 %84, label %85, label %102

85:                                               ; preds = %79
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds float, ptr %86, i64 0
  %88 = load float, ptr %87, align 4, !tbaa !11
  %89 = fpext float %88 to double
  %90 = fdiv double %89, 1.000000e+01
  %91 = fptrunc double %90 to float
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = getelementptr inbounds float, ptr %92, i64 0
  store float %91, ptr %93, align 4, !tbaa !11
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = getelementptr inbounds float, ptr %94, i64 1
  %96 = load float, ptr %95, align 4, !tbaa !11
  %97 = fpext float %96 to double
  %98 = fadd double %97, 1.000000e+00
  %99 = fptrunc double %98 to float
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = getelementptr inbounds float, ptr %100, i64 1
  store float %99, ptr %101, align 4, !tbaa !11
  br label %79, !llvm.loop !15

102:                                              ; preds = %79
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %11, align 4, !tbaa !9
  br label %16, !llvm.loop !16

106:                                              ; preds = %53, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"float", !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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5cpbdiPSt7complexIfEiiiPf(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %4, i64 4
  store <2 x float> <float 1.000000e+00, float 0.000000e+00>, ptr %4, align 4, !tbaa !5
  %.not32 = icmp slt i32 %2, 1
  br i1 %.not32, label %._crit_edge36, label %.lr.ph35.preheader

.lr.ph35.preheader:                               ; preds = %5
  %7 = sext i32 %1 to i64
  %8 = sext i32 %3 to i64
  %9 = add nuw i32 %2, 1
  %wide.trip.count = zext i32 %9 to i64
  %invariant.gep = getelementptr %"class.std::complex", ptr %0, i64 %8
  br label %.lr.ph35

.lr.ph35:                                         ; preds = %.lr.ph35.preheader, %32
  %10 = phi float [ 1.000000e+00, %.lr.ph35.preheader ], [ %33, %32 ]
  %indvars.iv = phi i64 [ 1, %.lr.ph35.preheader ], [ %indvars.iv.next, %32 ]
  %11 = add nsw i64 %indvars.iv, -1
  %12 = mul nsw i64 %11, %7
  %gep = getelementptr %"class.std::complex", ptr %invariant.gep, i64 %12
  %13 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %gep)
  %14 = fmul float %10, %13
  %15 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %gep)
  %16 = fmul float %14, %15
  store float %16, ptr %4, align 4, !tbaa !5
  %17 = fcmp oeq float %16, 0.000000e+00
  br i1 %17, label %._crit_edge36, label %.preheader

.preheader:                                       ; preds = %.lr.ph35
  %18 = fcmp olt float %16, 1.000000e+00
  br i1 %18, label %.lr.ph, label %thread-pre-split

.lr.ph:                                           ; preds = %.preheader
  %.promoted = load float, ptr %6, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %20 = phi float [ %.promoted, %.lr.ph ], [ %23, %19 ]
  %21 = phi float [ %16, %.lr.ph ], [ %22, %19 ]
  %22 = fmul float %21, 1.000000e+01
  %23 = fadd float %20, -1.000000e+00
  %24 = fcmp olt float %22, 1.000000e+00
  br i1 %24, label %19, label %.thread-pre-split_crit_edge, !llvm.loop !9

.thread-pre-split_crit_edge:                      ; preds = %19
  store float %22, ptr %4, align 4, !tbaa !5
  store float %23, ptr %6, align 4, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %.thread-pre-split_crit_edge, %.preheader
  %.pr = phi float [ %22, %.thread-pre-split_crit_edge ], [ %16, %.preheader ]
  %25 = fcmp ult float %.pr, 1.000000e+01
  br i1 %25, label %32, label %.lr.ph28

.lr.ph28:                                         ; preds = %thread-pre-split
  %.promoted30 = load float, ptr %6, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %.lr.ph28, %26
  %27 = phi float [ %.promoted30, %.lr.ph28 ], [ %30, %26 ]
  %28 = phi float [ %.pr, %.lr.ph28 ], [ %29, %26 ]
  %29 = fdiv float %28, 1.000000e+01
  %30 = fadd float %27, 1.000000e+00
  %31 = fcmp ult float %29, 1.000000e+01
  br i1 %31, label %._crit_edge, label %26, !llvm.loop !11

._crit_edge:                                      ; preds = %26
  store float %29, ptr %4, align 4, !tbaa !5
  store float %30, ptr %6, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %._crit_edge, %thread-pre-split
  %33 = phi float [ %29, %._crit_edge ], [ %.pr, %thread-pre-split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge36, label %.lr.ph35, !llvm.loop !12

._crit_edge36:                                    ; preds = %32, %.lr.ph35, %5
  ret void
}

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

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass