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

; 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.doublecomplex = type { double, double }

; Function Attrs: nounwind uwtable
define dso_local void @zlacgv_(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 i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.doublecomplex, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.doublecomplex, ptr %12, i32 -1
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %55

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

20:                                               ; preds = %51, %17
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %24, label %54

24:                                               ; preds = %20
  %25 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %25, ptr %8, align 4, !tbaa !9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.doublecomplex, ptr %26, i64 %28
  %30 = call { double, double } @Cd(ptr noundef %29)
  %31 = extractvalue { double, double } %30, 0
  %32 = extractvalue { double, double } %30, 1
  %33 = fneg double %32
  %34 = call ptr @_pCd(ptr noundef %9)
  %35 = getelementptr inbounds { double, double }, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds { double, double }, ptr %34, i32 0, i32 1
  store double %31, ptr %35, align 8
  store double %33, ptr %36, align 8
  %37 = getelementptr inbounds %struct.doublecomplex, ptr %9, i32 0, i32 0
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.doublecomplex, ptr %39, i64 %41
  %43 = getelementptr inbounds %struct.doublecomplex, ptr %42, i32 0, i32 0
  store double %38, ptr %43, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.doublecomplex, ptr %9, i32 0, i32 1
  %45 = load double, ptr %44, align 8, !tbaa !14
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.doublecomplex, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.doublecomplex, ptr %49, i32 0, i32 1
  store double %45, ptr %50, align 8, !tbaa !14
  br label %51

51:                                               ; preds = %24
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %11, align 4, !tbaa !9
  br label %20, !llvm.loop !15

54:                                               ; preds = %20
  br label %109

55:                                               ; preds = %3
  store i32 1, ptr %10, align 4, !tbaa !9
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = icmp slt i32 %57, 0
  br i1 %58, label %59, label %67

59:                                               ; preds = %55
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = sub nsw i32 %61, 1
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = mul nsw i32 %62, %64
  %66 = sub nsw i32 1, %65
  store i32 %66, ptr %10, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %59, %55
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load i32, ptr %68, align 4, !tbaa !9
  store i32 %69, ptr %7, align 4, !tbaa !9
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %105, %67
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = icmp sle i32 %71, %72
  br i1 %73, label %74, label %108

74:                                               ; preds = %70
  %75 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %75, ptr %8, align 4, !tbaa !9
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.doublecomplex, ptr %76, i64 %78
  %80 = call { double, double } @Cd(ptr noundef %79)
  %81 = extractvalue { double, double } %80, 0
  %82 = extractvalue { double, double } %80, 1
  %83 = fneg double %82
  %84 = call ptr @_pCd(ptr noundef %9)
  %85 = getelementptr inbounds { double, double }, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds { double, double }, ptr %84, i32 0, i32 1
  store double %81, ptr %85, align 8
  store double %83, ptr %86, align 8
  %87 = getelementptr inbounds %struct.doublecomplex, ptr %9, i32 0, i32 0
  %88 = load double, ptr %87, align 8, !tbaa !11
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.doublecomplex, ptr %89, i64 %91
  %93 = getelementptr inbounds %struct.doublecomplex, ptr %92, i32 0, i32 0
  store double %88, ptr %93, align 8, !tbaa !11
  %94 = getelementptr inbounds %struct.doublecomplex, ptr %9, i32 0, i32 1
  %95 = load double, ptr %94, align 8, !tbaa !14
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.doublecomplex, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.doublecomplex, ptr %99, i32 0, i32 1
  store double %95, ptr %100, align 8, !tbaa !14
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = load i32, ptr %10, align 4, !tbaa !9
  %104 = add nsw i32 %103, %102
  store i32 %104, ptr %10, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %74
  %106 = load i32, ptr %11, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %11, align 4, !tbaa !9
  br label %70, !llvm.loop !17

108:                                              ; preds = %70
  br label %109

109:                                              ; preds = %108, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { double, double } @Cd(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @_pCd(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 = { inlinehint 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)"}
!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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 8}
!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.doublecomplex = type { double, double }

; Function Attrs: nounwind uwtable
define dso_local void @zlacgv_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = alloca %struct.doublecomplex, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %1, i64 -16
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  %8 = load i32, ptr %0, align 4, !tbaa !5
  %.not3136 = icmp slt i32 %8, 1
  br i1 %7, label %9, label %20

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

.lr.ph38:                                         ; preds = %9
  %10 = add nuw i32 %8, 1
  %wide.trip.count = zext i32 %10 to i64
  br label %11

11:                                               ; preds = %.lr.ph38, %11
  %indvars.iv = phi i64 [ 1, %.lr.ph38 ], [ %indvars.iv.next, %11 ]
  %12 = getelementptr inbounds %struct.doublecomplex, ptr %5, i64 %indvars.iv
  %13 = call { double, double } @Cd(ptr noundef nonnull %12)
  %14 = extractvalue { double, double } %13, 0
  %15 = extractvalue { double, double } %13, 1
  %16 = fneg double %15
  %17 = call ptr @_pCd(ptr noundef nonnull %4)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  store double %14, ptr %17, align 8
  store double %16, ptr %18, align 8
  %19 = load <2 x double>, ptr %4, align 16, !tbaa !9
  store <2 x double> %19, ptr %12, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond41.not, label %.loopexit, label %11, !llvm.loop !11

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

.lr.ph:                                           ; preds = %20
  %21 = icmp slt i32 %6, 0
  %22 = add nsw i32 %8, -1
  %23 = mul nsw i32 %22, %6
  %24 = sub nsw i32 1, %23
  %.028 = select i1 %21, i32 %24, i32 1
  br label %25

25:                                               ; preds = %.lr.ph, %25
  %.135 = phi i32 [ 1, %.lr.ph ], [ %37, %25 ]
  %.12934 = phi i32 [ %.028, %.lr.ph ], [ %36, %25 ]
  %26 = sext i32 %.12934 to i64
  %27 = getelementptr inbounds %struct.doublecomplex, ptr %5, i64 %26
  %28 = call { double, double } @Cd(ptr noundef nonnull %27)
  %29 = extractvalue { double, double } %28, 0
  %30 = extractvalue { double, double } %28, 1
  %31 = fneg double %30
  %32 = call ptr @_pCd(ptr noundef nonnull %4)
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  store double %29, ptr %32, align 8
  store double %31, ptr %33, align 8
  %34 = load <2 x double>, ptr %4, align 16, !tbaa !9
  store <2 x double> %34, ptr %27, align 8, !tbaa !9
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, %.12934
  %37 = add nuw i32 %.135, 1
  %exitcond.not = icmp eq i32 %.135, %8
  br i1 %exitcond.not, label %.loopexit, label %25, !llvm.loop !13

.loopexit:                                        ; preds = %25, %11, %20, %9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { double, double } @Cd(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @_pCd(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 = { inlinehint 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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