; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/BLAS/TESTING (cblat2)

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

@cbeg_.i__ = external hidden global i64, align 8
@cbeg_.j = external hidden global i64, align 8
@cbeg_.ic = external hidden global i64, align 8
@cbeg_.mi = external hidden global i64, align 8
@cbeg_.mj = external hidden global i64, align 8

; 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: nounwind uwtable
define dso_local void @cbeg_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca %struct.complex, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = icmp ne i64 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  store i64 891, ptr @cbeg_.mi, align 8, !tbaa !9
  store i64 457, ptr @cbeg_.mj, align 8, !tbaa !9
  store i64 7, ptr @cbeg_.i__, align 8, !tbaa !9
  store i64 7, ptr @cbeg_.j, align 8, !tbaa !9
  store i64 0, ptr @cbeg_.ic, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %11, %2
  %14 = load i64, ptr @cbeg_.ic, align 8, !tbaa !9
  %15 = add nsw i64 %14, 1
  store i64 %15, ptr @cbeg_.ic, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %35, %13
  %17 = load i64, ptr @cbeg_.mi, align 8, !tbaa !9
  %18 = load i64, ptr @cbeg_.i__, align 8, !tbaa !9
  %19 = mul nsw i64 %18, %17
  store i64 %19, ptr @cbeg_.i__, align 8, !tbaa !9
  %20 = load i64, ptr @cbeg_.mj, align 8, !tbaa !9
  %21 = load i64, ptr @cbeg_.j, align 8, !tbaa !9
  %22 = mul nsw i64 %21, %20
  store i64 %22, ptr @cbeg_.j, align 8, !tbaa !9
  %23 = load i64, ptr @cbeg_.i__, align 8, !tbaa !9
  %24 = sdiv i64 %23, 1000
  %25 = mul nsw i64 %24, 1000
  %26 = load i64, ptr @cbeg_.i__, align 8, !tbaa !9
  %27 = sub nsw i64 %26, %25
  store i64 %27, ptr @cbeg_.i__, align 8, !tbaa !9
  %28 = load i64, ptr @cbeg_.j, align 8, !tbaa !9
  %29 = sdiv i64 %28, 1000
  %30 = mul nsw i64 %29, 1000
  %31 = load i64, ptr @cbeg_.j, align 8, !tbaa !9
  %32 = sub nsw i64 %31, %30
  store i64 %32, ptr @cbeg_.j, align 8, !tbaa !9
  %33 = load i64, ptr @cbeg_.ic, align 8, !tbaa !9
  %34 = icmp sge i64 %33, 5
  br i1 %34, label %35, label %36

35:                                               ; preds = %16
  store i64 0, ptr @cbeg_.ic, align 8, !tbaa !9
  br label %16

36:                                               ; preds = %16
  %37 = load i64, ptr @cbeg_.i__, align 8, !tbaa !9
  %38 = sub nsw i64 %37, 500
  %39 = sitofp i64 %38 to float
  %40 = fdiv float %39, 1.001000e+03
  store float %40, ptr %5, align 4, !tbaa !11
  %41 = load i64, ptr @cbeg_.j, align 8, !tbaa !9
  %42 = sub nsw i64 %41, 500
  %43 = sitofp i64 %42 to float
  %44 = fdiv float %43, 1.001000e+03
  store float %44, ptr %6, align 4, !tbaa !11
  %45 = load float, ptr %5, align 4, !tbaa !11
  %46 = getelementptr inbounds %struct.complex, ptr %7, i32 0, i32 0
  store float %45, ptr %46, align 4, !tbaa !13
  %47 = load float, ptr %6, align 4, !tbaa !11
  %48 = getelementptr inbounds %struct.complex, ptr %7, i32 0, i32 1
  store float %47, ptr %48, align 4, !tbaa !15
  %49 = getelementptr inbounds %struct.complex, ptr %7, i32 0, i32 0
  %50 = load float, ptr %49, align 4, !tbaa !13
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.complex, ptr %51, i32 0, i32 0
  store float %50, ptr %52, align 4, !tbaa !13
  %53 = getelementptr inbounds %struct.complex, ptr %7, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !15
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.complex, ptr %55, i32 0, i32 1
  store float %54, ptr %56, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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


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

@cbeg_.i__ = external hidden local_unnamed_addr global i64, align 8
@cbeg_.j = external hidden local_unnamed_addr global i64, align 8
@cbeg_.ic = external hidden local_unnamed_addr global i64, align 8
@cbeg_.mi = external hidden local_unnamed_addr global i64, align 8
@cbeg_.mj = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @cbeg_(ptr nocapture noundef writeonly %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %.peel.begin, label %4

4:                                                ; preds = %2
  store i64 891, ptr @cbeg_.mi, align 8, !tbaa !5
  store i64 457, ptr @cbeg_.mj, align 8, !tbaa !5
  store i64 7, ptr @cbeg_.i__, align 8, !tbaa !5
  store i64 7, ptr @cbeg_.j, align 8, !tbaa !5
  store i64 0, ptr @cbeg_.ic, align 8, !tbaa !5
  store i64 0, ptr %1, align 8, !tbaa !5
  br label %.peel.begin

.peel.begin:                                      ; preds = %4, %2
  %5 = load i64, ptr @cbeg_.ic, align 8, !tbaa !5
  %6 = add nsw i64 %5, 1
  %7 = load i64, ptr @cbeg_.mi, align 8, !tbaa !5
  %.fr12 = freeze i64 %7
  %8 = load i64, ptr @cbeg_.mj, align 8, !tbaa !5
  %.fr = freeze i64 %8
  %cbeg_.i__.promoted = load i64, ptr @cbeg_.i__, align 8, !tbaa !5
  %cbeg_.j.promoted = load i64, ptr @cbeg_.j, align 8, !tbaa !5
  %cbeg_.i__.promoted.fr = freeze i64 %cbeg_.i__.promoted
  %9 = mul i64 %cbeg_.i__.promoted.fr, %.fr12
  %cbeg_.j.promoted.fr = freeze i64 %cbeg_.j.promoted
  %10 = mul i64 %cbeg_.j.promoted.fr, %.fr
  %11 = srem i64 %9, 1000
  %12 = srem i64 %10, 1000
  %13 = icmp sgt i64 %5, 3
  br i1 %13, label %.loopexit, label %18

.loopexit:                                        ; preds = %.peel.begin
  %14 = mul i64 %12, %.fr
  %15 = srem i64 %14, 1000
  %16 = mul i64 %11, %.fr12
  %17 = srem i64 %16, 1000
  br label %18

18:                                               ; preds = %.loopexit, %.peel.begin
  %storemerge.lcssa = phi i64 [ %6, %.peel.begin ], [ 0, %.loopexit ]
  %.lcssa10 = phi i64 [ %11, %.peel.begin ], [ %17, %.loopexit ]
  %.lcssa = phi i64 [ %12, %.peel.begin ], [ %15, %.loopexit ]
  store i64 %storemerge.lcssa, ptr @cbeg_.ic, align 8, !tbaa !5
  store i64 %.lcssa10, ptr @cbeg_.i__, align 8, !tbaa !5
  store i64 %.lcssa, ptr @cbeg_.j, align 8, !tbaa !5
  %19 = add nsw i64 %.lcssa10, -500
  %20 = sitofp i64 %19 to float
  %21 = fdiv float %20, 1.001000e+03
  %22 = add nsw i64 %.lcssa, -500
  %23 = sitofp i64 %22 to float
  %24 = fdiv float %23, 1.001000e+03
  store float %21, ptr %0, align 4, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  store float %24, ptr %25, align 4, !tbaa !12
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass