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

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

@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @zlag2c_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca double, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !9
  store i32 %27, ptr %17, align 4, !tbaa !9
  %28 = load i32, ptr %17, align 4, !tbaa !9
  %29 = mul nsw i32 %28, 1
  %30 = add nsw i32 1, %29
  store i32 %30, ptr %18, align 4, !tbaa !9
  %31 = load i32, ptr %18, align 4, !tbaa !9
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = sext i32 %31 to i64
  %34 = sub i64 0, %33
  %35 = getelementptr inbounds %struct.doublecomplex, ptr %32, i64 %34
  store ptr %35, ptr %10, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = load i32, ptr %36, align 4, !tbaa !9
  store i32 %37, ptr %15, align 4, !tbaa !9
  %38 = load i32, ptr %15, align 4, !tbaa !9
  %39 = mul nsw i32 %38, 1
  %40 = add nsw i32 1, %39
  store i32 %40, ptr %16, align 4, !tbaa !9
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = sext i32 %41 to i64
  %44 = sub i64 0, %43
  %45 = getelementptr inbounds %struct.complex, ptr %42, i64 %44
  store ptr %45, ptr %12, align 8, !tbaa !5
  %46 = call float @slamch_(ptr noundef @.str)
  %47 = fpext float %46 to double
  store double %47, ptr %23, align 8, !tbaa !11
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 4, !tbaa !9
  store i32 %49, ptr %19, align 4, !tbaa !9
  store i32 1, ptr %25, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %160, %7
  %51 = load i32, ptr %25, align 4, !tbaa !9
  %52 = load i32, ptr %19, align 4, !tbaa !9
  %53 = icmp sle i32 %51, %52
  br i1 %53, label %54, label %163

54:                                               ; preds = %50
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i32, ptr %55, align 4, !tbaa !9
  store i32 %56, ptr %20, align 4, !tbaa !9
  store i32 1, ptr %24, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %156, %54
  %58 = load i32, ptr %24, align 4, !tbaa !9
  %59 = load i32, ptr %20, align 4, !tbaa !9
  %60 = icmp sle i32 %58, %59
  br i1 %60, label %61, label %159

61:                                               ; preds = %57
  %62 = load i32, ptr %24, align 4, !tbaa !9
  %63 = load i32, ptr %25, align 4, !tbaa !9
  %64 = load i32, ptr %17, align 4, !tbaa !9
  %65 = mul nsw i32 %63, %64
  %66 = add nsw i32 %62, %65
  store i32 %66, ptr %21, align 4, !tbaa !9
  %67 = load i32, ptr %24, align 4, !tbaa !9
  %68 = load i32, ptr %25, align 4, !tbaa !9
  %69 = load i32, ptr %17, align 4, !tbaa !9
  %70 = mul nsw i32 %68, %69
  %71 = add nsw i32 %67, %70
  store i32 %71, ptr %22, align 4, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load i32, ptr %21, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.doublecomplex, ptr %72, i64 %74
  %76 = getelementptr inbounds %struct.doublecomplex, ptr %75, i32 0, i32 0
  %77 = load double, ptr %76, align 8, !tbaa !13
  %78 = load double, ptr %23, align 8, !tbaa !11
  %79 = fneg double %78
  %80 = fcmp olt double %77, %79
  br i1 %80, label %119, label %81

81:                                               ; preds = %61
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = load i32, ptr %22, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.doublecomplex, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.doublecomplex, ptr %85, i32 0, i32 0
  %87 = load double, ptr %86, align 8, !tbaa !13
  %88 = load double, ptr %23, align 8, !tbaa !11
  %89 = fcmp ogt double %87, %88
  br i1 %89, label %119, label %90

90:                                               ; preds = %81
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = load i32, ptr %24, align 4, !tbaa !9
  %93 = load i32, ptr %25, align 4, !tbaa !9
  %94 = load i32, ptr %17, align 4, !tbaa !9
  %95 = mul nsw i32 %93, %94
  %96 = add nsw i32 %92, %95
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds %struct.doublecomplex, ptr %91, i64 %97
  %99 = call { double, double } @Cd(ptr noundef %98)
  %100 = extractvalue { double, double } %99, 0
  %101 = extractvalue { double, double } %99, 1
  %102 = load double, ptr %23, align 8, !tbaa !11
  %103 = fneg double %102
  %104 = fcmp olt double %101, %103
  br i1 %104, label %119, label %105

105:                                              ; preds = %90
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = load i32, ptr %24, align 4, !tbaa !9
  %108 = load i32, ptr %25, align 4, !tbaa !9
  %109 = load i32, ptr %17, align 4, !tbaa !9
  %110 = mul nsw i32 %108, %109
  %111 = add nsw i32 %107, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %struct.doublecomplex, ptr %106, i64 %112
  %114 = call { double, double } @Cd(ptr noundef %113)
  %115 = extractvalue { double, double } %114, 0
  %116 = extractvalue { double, double } %114, 1
  %117 = load double, ptr %23, align 8, !tbaa !11
  %118 = fcmp ogt double %116, %117
  br i1 %118, label %119, label %121

119:                                              ; preds = %105, %90, %81, %61
  %120 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 1, ptr %120, align 4, !tbaa !9
  br label %165

121:                                              ; preds = %105
  %122 = load i32, ptr %24, align 4, !tbaa !9
  %123 = load i32, ptr %25, align 4, !tbaa !9
  %124 = load i32, ptr %15, align 4, !tbaa !9
  %125 = mul nsw i32 %123, %124
  %126 = add nsw i32 %122, %125
  store i32 %126, ptr %21, align 4, !tbaa !9
  %127 = load i32, ptr %24, align 4, !tbaa !9
  %128 = load i32, ptr %25, align 4, !tbaa !9
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = mul nsw i32 %128, %129
  %131 = add nsw i32 %127, %130
  store i32 %131, ptr %22, align 4, !tbaa !9
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  %133 = load i32, ptr %22, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds %struct.doublecomplex, ptr %132, i64 %134
  %136 = getelementptr inbounds %struct.doublecomplex, ptr %135, i32 0, i32 0
  %137 = load double, ptr %136, align 8, !tbaa !13
  %138 = fptrunc double %137 to float
  %139 = load ptr, ptr %12, align 8, !tbaa !5
  %140 = load i32, ptr %21, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds %struct.complex, ptr %139, i64 %141
  %143 = getelementptr inbounds %struct.complex, ptr %142, i32 0, i32 0
  store float %138, ptr %143, align 4, !tbaa !15
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = load i32, ptr %22, align 4, !tbaa !9
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds %struct.doublecomplex, ptr %144, i64 %146
  %148 = getelementptr inbounds %struct.doublecomplex, ptr %147, i32 0, i32 1
  %149 = load double, ptr %148, align 8, !tbaa !18
  %150 = fptrunc double %149 to float
  %151 = load ptr, ptr %12, align 8, !tbaa !5
  %152 = load i32, ptr %21, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds %struct.complex, ptr %151, i64 %153
  %155 = getelementptr inbounds %struct.complex, ptr %154, i32 0, i32 1
  store float %150, ptr %155, align 4, !tbaa !19
  br label %156

156:                                              ; preds = %121
  %157 = load i32, ptr %24, align 4, !tbaa !9
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %24, align 4, !tbaa !9
  br label %57, !llvm.loop !20

159:                                              ; preds = %57
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %25, align 4, !tbaa !9
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %25, align 4, !tbaa !9
  br label %50, !llvm.loop !22

163:                                              ; preds = %50
  %164 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %164, align 4, !tbaa !9
  br label %165

165:                                              ; preds = %163, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  ret void
}

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

declare float @slamch_(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden { double, double } @Cd(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"="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 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 8}
!15 = !{!16, !17, i64 0}
!16 = !{!"", !17, i64 0, !17, i64 4}
!17 = !{!"float", !7, i64 0}
!18 = !{!14, !12, i64 8}
!19 = !{!16, !17, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @zlag2c_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %narrow = xor i32 %8, -1
  %9 = sext i32 %narrow to i64
  %10 = getelementptr inbounds %struct.doublecomplex, ptr %2, i64 %9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %narrow57 = xor i32 %11, -1
  %12 = sext i32 %narrow57 to i64
  %13 = getelementptr inbounds %struct.complex, ptr %4, i64 %12
  %14 = tail call float @slamch_(ptr noundef nonnull @.str) #3
  %15 = fpext float %14 to double
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %.not62 = icmp slt i32 %16, 1
  br i1 %.not62, label %.loopexit, label %.lr.ph65

.lr.ph65:                                         ; preds = %7
  %17 = fneg double %15
  %18 = load i32, ptr %0, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 1
  br i1 %19, label %.loopexit, label %.lr.ph65.split.preheader

.lr.ph65.split.preheader:                         ; preds = %.lr.ph65
  %20 = sext i32 %8 to i64
  %21 = sext i32 %11 to i64
  %22 = add nuw i32 %16, 1
  %wide.trip.count72 = zext i32 %22 to i64
  br label %.lr.ph65.split

.lr.ph65.split:                                   ; preds = %.lr.ph65.split.preheader, %._crit_edge
  %indvars.iv69 = phi i64 [ 1, %.lr.ph65.split.preheader ], [ %indvars.iv.next70, %._crit_edge ]
  %23 = load i32, ptr %0, align 4, !tbaa !5
  %.not5860 = icmp slt i32 %23, 1
  br i1 %.not5860, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph65.split
  %24 = mul nsw i64 %indvars.iv69, %20
  %25 = mul nsw i64 %indvars.iv69, %21
  %26 = add nuw i32 %23, 1
  %wide.trip.count = zext i32 %26 to i64
  %invariant.gep = getelementptr %struct.doublecomplex, ptr %10, i64 %24
  %invariant.gep75 = getelementptr %struct.complex, ptr %13, i64 %25
  br label %27

27:                                               ; preds = %.lr.ph, %39
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %39 ]
  %gep = getelementptr %struct.doublecomplex, ptr %invariant.gep, i64 %indvars.iv
  %28 = load double, ptr %gep, align 8, !tbaa !9
  %29 = fcmp olt double %28, %17
  %30 = fcmp ogt double %28, %15
  %or.cond = or i1 %29, %30
  br i1 %or.cond, label %.loopexit, label %31

31:                                               ; preds = %27
  %32 = tail call { double, double } @Cd(ptr noundef nonnull %gep)
  %33 = extractvalue { double, double } %32, 1
  %34 = fcmp olt double %33, %17
  br i1 %34, label %.loopexit, label %35

35:                                               ; preds = %31
  %36 = tail call { double, double } @Cd(ptr noundef nonnull %gep)
  %37 = extractvalue { double, double } %36, 1
  %38 = fcmp ogt double %37, %15
  br i1 %38, label %.loopexit, label %39

39:                                               ; preds = %35
  %gep76 = getelementptr %struct.complex, ptr %invariant.gep75, i64 %indvars.iv
  %40 = load <2 x double>, ptr %gep, align 8, !tbaa !12
  %41 = fptrunc <2 x double> %40 to <2 x float>
  store <2 x float> %41, ptr %gep76, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %27, !llvm.loop !15

._crit_edge:                                      ; preds = %39, %.lr.ph65.split
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next70, %wide.trip.count72
  br i1 %exitcond73.not, label %.loopexit, label %.lr.ph65.split, !llvm.loop !17

.loopexit:                                        ; preds = %._crit_edge, %27, %31, %35, %.lr.ph65, %7
  %storemerge = phi i32 [ 0, %7 ], [ 0, %.lr.ph65 ], [ 1, %35 ], [ 1, %31 ], [ 1, %27 ], [ 0, %._crit_edge ]
  store i32 %storemerge, ptr %6, align 4, !tbaa !5
  ret void
}

declare float @slamch_(ptr noundef) local_unnamed_addr #1

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

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 = { 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass