; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/BLAS/SRC (csscal)

; 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 i32 @f2c_csscal(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca %struct.complex, align 4
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.complex, ptr %20, i32 -1
  store ptr %21, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp sle i64 %23, 0
  br i1 %24, label %29, label %25

25:                                               ; preds = %4
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = icmp sle i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25, %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %148

30:                                               ; preds = %25
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = icmp eq i64 %32, 1
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  br label %101

35:                                               ; preds = %30
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = mul nsw i64 %37, %39
  store i64 %40, ptr %18, align 8, !tbaa !9
  %41 = load i64, ptr %18, align 8, !tbaa !9
  store i64 %41, ptr %10, align 8, !tbaa !9
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i64, ptr %42, align 8, !tbaa !9
  store i64 %43, ptr %11, align 8, !tbaa !9
  store i64 1, ptr %17, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %96, %35
  %45 = load i64, ptr %11, align 8, !tbaa !9
  %46 = icmp slt i64 %45, 0
  br i1 %46, label %47, label %52

47:                                               ; preds = %44
  %48 = load i64, ptr %17, align 8, !tbaa !9
  %49 = load i64, ptr %10, align 8, !tbaa !9
  %50 = icmp sge i64 %48, %49
  %51 = zext i1 %50 to i32
  br label %57

52:                                               ; preds = %44
  %53 = load i64, ptr %17, align 8, !tbaa !9
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = icmp sle i64 %53, %54
  %56 = zext i1 %55 to i32
  br label %57

57:                                               ; preds = %52, %47
  %58 = phi i32 [ %51, %47 ], [ %56, %52 ]
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %100

60:                                               ; preds = %57
  %61 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %61, ptr %12, align 8, !tbaa !9
  %62 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %62, ptr %13, align 8, !tbaa !9
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load float, ptr %63, align 4, !tbaa !11
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load i64, ptr %13, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.complex, ptr %65, i64 %66
  %68 = getelementptr inbounds %struct.complex, ptr %67, i32 0, i32 0
  %69 = load float, ptr %68, align 4, !tbaa !13
  %70 = fmul float %64, %69
  store float %70, ptr %14, align 4, !tbaa !11
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load float, ptr %71, align 4, !tbaa !11
  %73 = fpext float %72 to double
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = load i64, ptr %17, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.complex, ptr %74, i64 %75
  %77 = call double @r_imag(ptr noundef %76)
  %78 = fmul double %73, %77
  %79 = fptrunc double %78 to float
  store float %79, ptr %15, align 4, !tbaa !11
  %80 = load float, ptr %14, align 4, !tbaa !11
  %81 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 0
  store float %80, ptr %81, align 4, !tbaa !13
  %82 = load float, ptr %15, align 4, !tbaa !11
  %83 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 1
  store float %82, ptr %83, align 4, !tbaa !15
  %84 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 0
  %85 = load float, ptr %84, align 4, !tbaa !13
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load i64, ptr %12, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.complex, ptr %86, i64 %87
  %89 = getelementptr inbounds %struct.complex, ptr %88, i32 0, i32 0
  store float %85, ptr %89, align 4, !tbaa !13
  %90 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 1
  %91 = load float, ptr %90, align 4, !tbaa !15
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i64, ptr %12, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.complex, ptr %92, i64 %93
  %95 = getelementptr inbounds %struct.complex, ptr %94, i32 0, i32 1
  store float %91, ptr %95, align 4, !tbaa !15
  br label %96

96:                                               ; preds = %60
  %97 = load i64, ptr %11, align 8, !tbaa !9
  %98 = load i64, ptr %17, align 8, !tbaa !9
  %99 = add nsw i64 %98, %97
  store i64 %99, ptr %17, align 8, !tbaa !9
  br label %44, !llvm.loop !16

100:                                              ; preds = %57
  store i32 0, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %148

101:                                              ; preds = %34
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = load i64, ptr %102, align 8, !tbaa !9
  store i64 %103, ptr %11, align 8, !tbaa !9
  store i64 1, ptr %17, align 8, !tbaa !9
  br label %104

104:                                              ; preds = %144, %101
  %105 = load i64, ptr %17, align 8, !tbaa !9
  %106 = load i64, ptr %11, align 8, !tbaa !9
  %107 = icmp sle i64 %105, %106
  br i1 %107, label %108, label %147

108:                                              ; preds = %104
  %109 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %109, ptr %10, align 8, !tbaa !9
  %110 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %110, ptr %12, align 8, !tbaa !9
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = load float, ptr %111, align 4, !tbaa !11
  %113 = load ptr, ptr %8, align 8, !tbaa !5
  %114 = load i64, ptr %12, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.complex, ptr %113, i64 %114
  %116 = getelementptr inbounds %struct.complex, ptr %115, i32 0, i32 0
  %117 = load float, ptr %116, align 4, !tbaa !13
  %118 = fmul float %112, %117
  store float %118, ptr %14, align 4, !tbaa !11
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = load float, ptr %119, align 4, !tbaa !11
  %121 = fpext float %120 to double
  %122 = load ptr, ptr %8, align 8, !tbaa !5
  %123 = load i64, ptr %17, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.complex, ptr %122, i64 %123
  %125 = call double @r_imag(ptr noundef %124)
  %126 = fmul double %121, %125
  %127 = fptrunc double %126 to float
  store float %127, ptr %15, align 4, !tbaa !11
  %128 = load float, ptr %14, align 4, !tbaa !11
  %129 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 0
  store float %128, ptr %129, align 4, !tbaa !13
  %130 = load float, ptr %15, align 4, !tbaa !11
  %131 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 1
  store float %130, ptr %131, align 4, !tbaa !15
  %132 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 0
  %133 = load float, ptr %132, align 4, !tbaa !13
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = load i64, ptr %10, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.complex, ptr %134, i64 %135
  %137 = getelementptr inbounds %struct.complex, ptr %136, i32 0, i32 0
  store float %133, ptr %137, align 4, !tbaa !13
  %138 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 1
  %139 = load float, ptr %138, align 4, !tbaa !15
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  %141 = load i64, ptr %10, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.complex, ptr %140, i64 %141
  %143 = getelementptr inbounds %struct.complex, ptr %142, i32 0, i32 1
  store float %139, ptr %143, align 4, !tbaa !15
  br label %144

144:                                              ; preds = %108
  %145 = load i64, ptr %17, align 8, !tbaa !9
  %146 = add nsw i64 %145, 1
  store i64 %146, ptr %17, align 8, !tbaa !9
  br label %104, !llvm.loop !18

147:                                              ; preds = %104
  store i32 0, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %148

148:                                              ; preds = %147, %100, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %149 = load i32, ptr %5, align 4
  ret i32 %149
}

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

declare double @r_imag(ptr noundef) #2

; 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"="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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 4}
!15 = !{!14, !12, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 noundef i32 @f2c_csscal(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %2, i64 -8
  %6 = load i64, ptr %0, align 8, !tbaa !5
  %7 = icmp slt i64 %6, 1
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %4
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = icmp slt i64 %9, 1
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %8
  %12 = icmp eq i64 %9, 1
  br i1 %12, label %.lr.ph57, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %11
  %13 = mul nuw nsw i64 %9, %6
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.04954 = phi i64 [ %23, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %14 = load float, ptr %1, align 4, !tbaa !9
  %15 = getelementptr inbounds %struct.complex, ptr %5, i64 %.04954
  %16 = load float, ptr %15, align 4, !tbaa !11
  %17 = fmul float %14, %16
  %18 = fpext float %14 to double
  %19 = tail call double @r_imag(ptr noundef nonnull %15) #2
  %20 = fmul double %19, %18
  %21 = fptrunc double %20 to float
  store float %17, ptr %15, align 4, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %15, i64 4
  store float %21, ptr %22, align 4, !tbaa !13
  %23 = add nuw nsw i64 %.04954, %9
  %.not = icmp sgt i64 %23, %13
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !14

.lr.ph57:                                         ; preds = %11, %.lr.ph57
  %.156 = phi i64 [ %33, %.lr.ph57 ], [ 1, %11 ]
  %24 = load float, ptr %1, align 4, !tbaa !9
  %25 = getelementptr inbounds %struct.complex, ptr %5, i64 %.156
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = fmul float %24, %26
  %28 = fpext float %24 to double
  %29 = tail call double @r_imag(ptr noundef nonnull %25) #2
  %30 = fmul double %29, %28
  %31 = fptrunc double %30 to float
  store float %27, ptr %25, align 4, !tbaa !11
  %32 = getelementptr inbounds i8, ptr %25, i64 4
  store float %31, ptr %32, align 4, !tbaa !13
  %33 = add nuw i64 %.156, 1
  %exitcond.not = icmp eq i64 %.156, %6
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph57, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph57, %4, %8
  ret i32 0
}

declare double @r_imag(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 = !{!"long", !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, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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