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

; 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 nounwind uwtable
declare dso_local void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_Z5cmachi(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca %"class.std::complex", align 4
  %7 = alloca %"class.std::complex", align 4
  %8 = alloca %"class.std::complex", align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %7, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 1.000000e+00, ptr %3, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %24, %1
  %12 = load float, ptr %3, align 4, !tbaa !9
  %13 = fpext float %12 to double
  %14 = fdiv double %13, 2.000000e+00
  %15 = fptrunc double %14 to float
  store float %15, ptr %3, align 4, !tbaa !9
  %16 = load float, ptr %3, align 4, !tbaa !9
  %17 = fpext float %16 to double
  %18 = fadd double 1.000000e+00, %17
  %19 = fptrunc double %18 to float
  store float %19, ptr %5, align 4, !tbaa !9
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = fpext float %20 to double
  %22 = fcmp ole double %21, 1.000000e+00
  br i1 %22, label %23, label %24

23:                                               ; preds = %11
  br label %25

24:                                               ; preds = %11
  br label %11, !llvm.loop !11

25:                                               ; preds = %23
  %26 = load float, ptr %3, align 4, !tbaa !9
  %27 = fpext float %26 to double
  %28 = fmul double 2.000000e+00, %27
  %29 = fptrunc double %28 to float
  store float %29, ptr %3, align 4, !tbaa !9
  store float 1.000000e+00, ptr %5, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %41, %25
  %31 = load float, ptr %5, align 4, !tbaa !9
  store float %31, ptr %9, align 4, !tbaa !9
  %32 = load float, ptr %5, align 4, !tbaa !9
  %33 = fpext float %32 to double
  %34 = fdiv double %33, 1.600000e+01
  %35 = fptrunc double %34 to float
  store float %35, ptr %5, align 4, !tbaa !9
  %36 = load float, ptr %5, align 4, !tbaa !9
  %37 = fpext float %36 to double
  %38 = fmul double %37, 1.000000e+00
  %39 = fcmp oeq double %38, 0.000000e+00
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  br label %42

41:                                               ; preds = %30
  br label %30, !llvm.loop !13

42:                                               ; preds = %40
  %43 = load float, ptr %9, align 4, !tbaa !9
  %44 = load float, ptr %3, align 4, !tbaa !9
  %45 = fdiv float %43, %44
  %46 = fpext float %45 to double
  %47 = fmul double %46, 1.000000e+02
  %48 = fptrunc double %47 to float
  store float %48, ptr %9, align 4, !tbaa !9
  %49 = load float, ptr %9, align 4, !tbaa !9
  %50 = call noundef float @_ZSt4sqrtf(float noundef %49)
  store float %50, ptr %9, align 4, !tbaa !9
  %51 = load float, ptr %9, align 4, !tbaa !9
  %52 = fpext float %51 to double
  %53 = fdiv double 1.000000e+00, %52
  %54 = fptrunc double %53 to float
  store float %54, ptr %4, align 4, !tbaa !9
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = icmp eq i32 %55, 1
  br i1 %56, label %57, label %59

57:                                               ; preds = %42
  %58 = load float, ptr %3, align 4, !tbaa !9
  store float %58, ptr %10, align 4, !tbaa !9
  br label %72

59:                                               ; preds = %42
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = load float, ptr %9, align 4, !tbaa !9
  store float %63, ptr %10, align 4, !tbaa !9
  br label %71

64:                                               ; preds = %59
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = icmp eq i32 %65, 3
  br i1 %66, label %67, label %69

67:                                               ; preds = %64
  %68 = load float, ptr %4, align 4, !tbaa !9
  store float %68, ptr %10, align 4, !tbaa !9
  br label %70

69:                                               ; preds = %64
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %69, %67
  br label %71

71:                                               ; preds = %70, %62
  br label %72

72:                                               ; preds = %71, %57
  %73 = load float, ptr %10, align 4, !tbaa !9
  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 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret float %73
}

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

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 = { 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 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z5cmachi(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca %"class.std::complex", align 4
  %3 = alloca %"class.std::complex", align 4
  %4 = alloca %"class.std::complex", align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @_ZNSt7complexIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %5 = call noundef float @_ZSt4sqrtf(float noundef 0x3889000000000000)
  switch i32 %0, label %9 [
    i32 1, label %10
    i32 2, label %6
    i32 3, label %7
  ]

6:                                                ; preds = %1
  br label %10

7:                                                ; preds = %1
  %8 = fdiv float 1.000000e+00, %5
  br label %10

9:                                                ; preds = %1
  br label %10

10:                                               ; preds = %1, %6, %9, %7
  %.0 = phi float [ %5, %6 ], [ %8, %7 ], [ 0.000000e+00, %9 ], [ 0x3E80000000000000, %1 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret float %.0
}

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass