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

; 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: mustprogress uwtable
define dso_local noundef float @_Z6scasumiPSt7complexIfEi(i32 noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca float, align 4
  %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 float, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store float 0.000000e+00, ptr %10, align 4, !tbaa !11
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = icmp sle i32 %12, 0
  br i1 %13, label %17, label %14

14:                                               ; preds = %3
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = icmp sle i32 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %14, %3
  %18 = load float, ptr %10, align 4, !tbaa !11
  store float %18, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %77

19:                                               ; preds = %14
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 1
  br i1 %21, label %22, label %47

22:                                               ; preds = %19
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %43, %22
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %46

27:                                               ; preds = %23
  %28 = load float, ptr %10, align 4, !tbaa !11
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %"class.std::complex", ptr %29, i64 %31
  %33 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %32)
  %34 = call noundef float @_Z6r4_absf(float noundef %33)
  %35 = fadd float %28, %34
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %"class.std::complex", ptr %36, i64 %38
  %40 = call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %39)
  %41 = call noundef float @_Z6r4_absf(float noundef %40)
  %42 = fadd float %35, %41
  store float %42, ptr %10, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %27
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %8, align 4, !tbaa !5
  br label %23, !llvm.loop !13

46:                                               ; preds = %23
  br label %75

47:                                               ; preds = %19
  store i32 0, ptr %9, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %71, %47
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %74

52:                                               ; preds = %48
  %53 = load float, ptr %10, align 4, !tbaa !11
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %"class.std::complex", ptr %54, i64 %56
  %58 = call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %57)
  %59 = call noundef float @_Z6r4_absf(float noundef %58)
  %60 = fadd float %53, %59
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %"class.std::complex", ptr %61, i64 %63
  %65 = call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %64)
  %66 = call noundef float @_Z6r4_absf(float noundef %65)
  %67 = fadd float %60, %66
  store float %67, ptr %10, align 4, !tbaa !11
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = add nsw i32 %68, %69
  store i32 %70, ptr %9, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %52
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !5
  br label %48, !llvm.loop !15

74:                                               ; preds = %48
  br label %75

75:                                               ; preds = %74, %46
  %76 = load float, ptr %10, align 4, !tbaa !11
  store float %76, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %77

77:                                               ; preds = %75, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %78 = load float, ptr %4, align 4
  ret float %78
}

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 = { 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"}
!15 = distinct !{!15, !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 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: mustprogress uwtable
define dso_local noundef float @_Z6scasumiPSt7complexIfEi(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 %.loopexit, label %6

6:                                                ; preds = %3
  %7 = icmp eq i32 %2, 1
  br i1 %7, label %.lr.ph37.preheader, label %.lr.ph.preheader

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

.lr.ph37.preheader:                               ; preds = %6
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph37

.lr.ph37:                                         ; preds = %.lr.ph37.preheader, %.lr.ph37
  %indvars.iv42 = phi i64 [ 0, %.lr.ph37.preheader ], [ %indvars.iv.next43, %.lr.ph37 ]
  %.036 = phi float [ 0.000000e+00, %.lr.ph37.preheader ], [ %15, %.lr.ph37 ]
  %9 = getelementptr inbounds %"class.std::complex", ptr %1, i64 %indvars.iv42
  %10 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %9)
  %11 = tail call noundef float @_Z6r4_absf(float noundef %10)
  %12 = fadd float %.036, %11
  %13 = tail call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %9)
  %14 = tail call noundef float @_Z6r4_absf(float noundef %13)
  %15 = fadd float %12, %14
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond45.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count
  br i1 %exitcond45.not, label %.loopexit, label %.lr.ph37, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.134 = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %22, %.lr.ph ]
  %.12632 = phi i32 [ 0, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %16 = getelementptr inbounds %"class.std::complex", ptr %1, i64 %indvars.iv
  %17 = tail call noundef float @_ZSt4realIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %16)
  %18 = tail call noundef float @_Z6r4_absf(float noundef %17)
  %19 = fadd float %.134, %18
  %20 = tail call noundef float @_ZSt4imagIfET_RKSt7complexIS0_E(ptr noundef nonnull align 4 dereferenceable(8) %16)
  %21 = tail call noundef float @_Z6r4_absf(float noundef %20)
  %22 = fadd float %19, %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, %8
  %23 = add nuw nsw i32 %.12632, 1
  %exitcond.not = icmp eq i32 %23, %0
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !7

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph37, %3
  %.027 = phi float [ 0.000000e+00, %3 ], [ %15, %.lr.ph37 ], [ %22, %.lr.ph ]
  ret float %.027
}

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

!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"}
!7 = distinct !{!7, !6}


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