; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/SRC (scsum1)

; 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.complex = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local float @scsum1_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  %14 = alloca i32, align 4
  %15 = alloca { float, float }, align 4
  %16 = alloca { float, float }, align 4
  %17 = alloca { float, float }, align 4
  %18 = alloca { float, float }, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.complex, ptr %19, i32 -1
  store ptr %20, ptr %6, align 8, !tbaa !5
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = icmp sle i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %3
  %25 = load float, ptr %10, align 4, !tbaa !9
  store float %25, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %108

26:                                               ; preds = %3
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  br label %79

31:                                               ; preds = %26
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = mul nsw i32 %33, %35
  store i32 %36, ptr %12, align 4, !tbaa !11
  %37 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %37, ptr %8, align 4, !tbaa !11
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %38, align 4, !tbaa !11
  store i32 %39, ptr %9, align 4, !tbaa !11
  store i32 1, ptr %11, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %72, %31
  %41 = load i32, ptr %9, align 4, !tbaa !11
  %42 = icmp slt i32 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %40
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = load i32, ptr %8, align 4, !tbaa !11
  %46 = icmp sge i32 %44, %45
  %47 = zext i1 %46 to i32
  br label %53

48:                                               ; preds = %40
  %49 = load i32, ptr %11, align 4, !tbaa !11
  %50 = load i32, ptr %8, align 4, !tbaa !11
  %51 = icmp sle i32 %49, %50
  %52 = zext i1 %51 to i32
  br label %53

53:                                               ; preds = %48, %43
  %54 = phi i32 [ %47, %43 ], [ %52, %48 ]
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %76

56:                                               ; preds = %53
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %11, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %struct.complex, ptr %57, i64 %59
  %61 = call <2 x float> @Cf(ptr noundef %60)
  store <2 x float> %61, ptr %15, align 4
  %62 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %63 = load float, ptr %62, align 4
  %64 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  %65 = load float, ptr %64, align 4
  %66 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %67 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  store float %63, ptr %66, align 4
  store float %65, ptr %67, align 4
  %68 = load <2 x float>, ptr %16, align 4
  %69 = call float @cabsf(<2 x float> noundef %68) #4
  %70 = load float, ptr %13, align 4, !tbaa !9
  %71 = fadd float %70, %69
  store float %71, ptr %13, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %56
  %73 = load i32, ptr %9, align 4, !tbaa !11
  %74 = load i32, ptr %11, align 4, !tbaa !11
  %75 = add nsw i32 %74, %73
  store i32 %75, ptr %11, align 4, !tbaa !11
  br label %40, !llvm.loop !13

76:                                               ; preds = %53
  %77 = load float, ptr %13, align 4, !tbaa !9
  store float %77, ptr %10, align 4, !tbaa !9
  %78 = load float, ptr %10, align 4, !tbaa !9
  store float %78, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %108

79:                                               ; preds = %30
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !11
  store i32 %81, ptr %9, align 4, !tbaa !11
  store i32 1, ptr %11, align 4, !tbaa !11
  br label %82

82:                                               ; preds = %102, %79
  %83 = load i32, ptr %11, align 4, !tbaa !11
  %84 = load i32, ptr %9, align 4, !tbaa !11
  %85 = icmp sle i32 %83, %84
  br i1 %85, label %86, label %105

86:                                               ; preds = %82
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = load i32, ptr %11, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.complex, ptr %87, i64 %89
  %91 = call <2 x float> @Cf(ptr noundef %90)
  store <2 x float> %91, ptr %17, align 4
  %92 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 0
  %93 = load float, ptr %92, align 4
  %94 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 1
  %95 = load float, ptr %94, align 4
  %96 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  store float %93, ptr %96, align 4
  store float %95, ptr %97, align 4
  %98 = load <2 x float>, ptr %18, align 4
  %99 = call float @cabsf(<2 x float> noundef %98) #4
  %100 = load float, ptr %13, align 4, !tbaa !9
  %101 = fadd float %100, %99
  store float %101, ptr %13, align 4, !tbaa !9
  br label %102

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

105:                                              ; preds = %82
  %106 = load float, ptr %13, align 4, !tbaa !9
  store float %106, ptr %10, align 4, !tbaa !9
  %107 = load float, ptr %10, align 4, !tbaa !9
  store float %107, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %108

108:                                              ; preds = %105, %76, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  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
  %109 = load float, ptr %4, align 4
  ret float %109
}

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

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @Cf(ptr noundef) #3

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

%struct.complex = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local float @scsum1_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 -8
  %5 = load i32, ptr %0, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 1
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %3
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %.lr.ph46.preheader, label %11

.lr.ph46.preheader:                               ; preds = %7
  %10 = add nuw i32 %5, 1
  %wide.trip.count = zext i32 %10 to i64
  br label %.lr.ph46

11:                                               ; preds = %7
  %12 = mul nsw i32 %8, %5
  %13 = icmp slt i32 %8, 0
  %14 = icmp slt i32 %12, 2
  %15 = icmp sgt i32 %12, 0
  %.in40 = select i1 %13, i1 %14, i1 %15
  br i1 %.in40, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %11
  %16 = sext i32 %8 to i64
  %17 = sext i32 %12 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.03442 = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %18 = getelementptr inbounds %struct.complex, ptr %4, i64 %indvars.iv
  %19 = tail call <2 x float> @Cf(ptr noundef nonnull %18)
  %20 = tail call float @cabsf(<2 x float> noundef %19) #3
  %21 = fadd float %.03442, %20
  %indvars.iv.next = add nsw i64 %indvars.iv, %16
  %22 = icmp sge i64 %indvars.iv.next, %17
  %23 = icmp sle i64 %indvars.iv.next, %17
  %.in = select i1 %13, i1 %22, i1 %23
  br i1 %.in, label %.lr.ph, label %.loopexit, !llvm.loop !9

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %.lr.ph46
  %indvars.iv51 = phi i64 [ 1, %.lr.ph46.preheader ], [ %indvars.iv.next52, %.lr.ph46 ]
  %.145 = phi float [ 0.000000e+00, %.lr.ph46.preheader ], [ %27, %.lr.ph46 ]
  %24 = getelementptr inbounds %struct.complex, ptr %4, i64 %indvars.iv51
  %25 = tail call <2 x float> @Cf(ptr noundef nonnull %24)
  %26 = tail call float @cabsf(<2 x float> noundef %25) #3
  %27 = fadd float %.145, %26
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next52, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph46, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph46, %11, %3
  %.0 = phi float [ 0.000000e+00, %3 ], [ 0.000000e+00, %11 ], [ %27, %.lr.ph46 ], [ %21, %.lr.ph ]
  ret float %.0
}

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @Cf(ptr noundef) local_unnamed_addr #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { 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 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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