; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (clacgv)

; 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 @clacgv_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %struct.complex, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.complex, ptr %12, i32 -1
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 1
  br i1 %16, label %17, label %45

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i64, ptr %18, align 8, !tbaa !9
  store i64 %19, ptr %7, align 8, !tbaa !9
  store i64 1, ptr %10, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %41, %17
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = icmp sle i64 %21, %22
  br i1 %23, label %24, label %44

24:                                               ; preds = %20
  %25 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %25, ptr %8, align 8, !tbaa !9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i64, ptr %10, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.complex, ptr %26, i64 %27
  call void @r_cnjg(ptr noundef %9, ptr noundef %28)
  %29 = getelementptr inbounds %struct.complex, ptr %9, i32 0, i32 0
  %30 = load float, ptr %29, align 4, !tbaa !11
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i64, ptr %8, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.complex, ptr %31, i64 %32
  %34 = getelementptr inbounds %struct.complex, ptr %33, i32 0, i32 0
  store float %30, ptr %34, align 4, !tbaa !11
  %35 = getelementptr inbounds %struct.complex, ptr %9, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.complex, ptr %37, i64 %38
  %40 = getelementptr inbounds %struct.complex, ptr %39, i32 0, i32 1
  store float %36, ptr %40, align 4, !tbaa !14
  br label %41

41:                                               ; preds = %24
  %42 = load i64, ptr %10, align 8, !tbaa !9
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %10, align 8, !tbaa !9
  br label %20, !llvm.loop !15

44:                                               ; preds = %20
  br label %89

45:                                               ; preds = %3
  store i64 1, ptr %11, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %49, label %57

49:                                               ; preds = %45
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = sub nsw i64 %51, 1
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = mul nsw i64 %52, %54
  %56 = sub nsw i64 1, %55
  store i64 %56, ptr %11, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %49, %45
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load i64, ptr %58, align 8, !tbaa !9
  store i64 %59, ptr %7, align 8, !tbaa !9
  store i64 1, ptr %10, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %85, %57
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = load i64, ptr %7, align 8, !tbaa !9
  %63 = icmp sle i64 %61, %62
  br i1 %63, label %64, label %88

64:                                               ; preds = %60
  %65 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %65, ptr %8, align 8, !tbaa !9
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load i64, ptr %11, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.complex, ptr %66, i64 %67
  call void @r_cnjg(ptr noundef %9, ptr noundef %68)
  %69 = getelementptr inbounds %struct.complex, ptr %9, i32 0, i32 0
  %70 = load float, ptr %69, align 4, !tbaa !11
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i64, ptr %8, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.complex, ptr %71, i64 %72
  %74 = getelementptr inbounds %struct.complex, ptr %73, i32 0, i32 0
  store float %70, ptr %74, align 4, !tbaa !11
  %75 = getelementptr inbounds %struct.complex, ptr %9, i32 0, i32 1
  %76 = load float, ptr %75, align 4, !tbaa !14
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.complex, ptr %77, i64 %78
  %80 = getelementptr inbounds %struct.complex, ptr %79, i32 0, i32 1
  store float %76, ptr %80, align 4, !tbaa !14
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = load i64, ptr %81, align 8, !tbaa !9
  %83 = load i64, ptr %11, align 8, !tbaa !9
  %84 = add nsw i64 %83, %82
  store i64 %84, ptr %11, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %64
  %86 = load i64, ptr %10, align 8, !tbaa !9
  %87 = add nsw i64 %86, 1
  store i64 %87, ptr %10, align 8, !tbaa !9
  br label %60, !llvm.loop !17

88:                                               ; preds = %60
  br label %89

89:                                               ; preds = %88, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

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

declare void @r_cnjg(ptr noundef, 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, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 @clacgv_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = alloca %struct.complex, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %1, i64 -8
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 1
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %.not3136 = icmp slt i64 %8, 1
  br i1 %7, label %9, label %13

9:                                                ; preds = %3
  br i1 %.not3136, label %.loopexit, label %.lr.ph38

.lr.ph38:                                         ; preds = %9, %.lr.ph38
  %.02837 = phi i64 [ %12, %.lr.ph38 ], [ 1, %9 ]
  %10 = getelementptr inbounds %struct.complex, ptr %5, i64 %.02837
  call void @r_cnjg(ptr noundef nonnull %4, ptr noundef nonnull %10) #3
  %11 = load <2 x float>, ptr %4, align 8, !tbaa !9
  store <2 x float> %11, ptr %10, align 4, !tbaa !9
  %12 = add nuw i64 %.02837, 1
  %exitcond40.not = icmp eq i64 %.02837, %8
  br i1 %exitcond40.not, label %.loopexit, label %.lr.ph38, !llvm.loop !11

13:                                               ; preds = %3
  br i1 %.not3136, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %14 = icmp slt i64 %6, 0
  %15 = add nsw i64 %8, -1
  %16 = mul nsw i64 %15, %6
  %17 = sub nsw i64 1, %16
  %.0 = select i1 %14, i64 %17, i64 1
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %.135 = phi i64 [ %.0, %.lr.ph ], [ %22, %18 ]
  %.12934 = phi i64 [ 1, %.lr.ph ], [ %23, %18 ]
  %19 = getelementptr inbounds %struct.complex, ptr %5, i64 %.135
  call void @r_cnjg(ptr noundef nonnull %4, ptr noundef nonnull %19) #3
  %20 = load <2 x float>, ptr %4, align 8, !tbaa !9
  store <2 x float> %20, ptr %19, align 4, !tbaa !9
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = add nsw i64 %21, %.135
  %23 = add nuw i64 %.12934, 1
  %exitcond.not = icmp eq i64 %.12934, %8
  br i1 %exitcond.not, label %.loopexit, label %18, !llvm.loop !13

.loopexit:                                        ; preds = %18, %.lr.ph38, %13, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

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

declare void @r_cnjg(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass