; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (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 i32 @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 i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca double, align 8
  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 8, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #3
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  store i64 %27, ptr %17, align 8, !tbaa !9
  %28 = load i64, ptr %17, align 8, !tbaa !9
  %29 = add nsw i64 1, %28
  store i64 %29, ptr %18, align 8, !tbaa !9
  %30 = load i64, ptr %18, align 8, !tbaa !9
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = sub i64 0, %30
  %33 = getelementptr inbounds %struct.doublecomplex, ptr %31, i64 %32
  store ptr %33, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !9
  store i64 %35, ptr %15, align 8, !tbaa !9
  %36 = load i64, ptr %15, align 8, !tbaa !9
  %37 = add nsw i64 1, %36
  store i64 %37, ptr %16, align 8, !tbaa !9
  %38 = load i64, ptr %16, align 8, !tbaa !9
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = sub i64 0, %38
  %41 = getelementptr inbounds %struct.complex, ptr %39, i64 %40
  store ptr %41, ptr %12, align 8, !tbaa !5
  %42 = call double @slamch_(ptr noundef @.str)
  store double %42, ptr %25, align 8, !tbaa !11
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load i64, ptr %43, align 8, !tbaa !9
  store i64 %44, ptr %19, align 8, !tbaa !9
  store i64 1, ptr %24, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %143, %7
  %46 = load i64, ptr %24, align 8, !tbaa !9
  %47 = load i64, ptr %19, align 8, !tbaa !9
  %48 = icmp sle i64 %46, %47
  br i1 %48, label %49, label %146

49:                                               ; preds = %45
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %50, align 8, !tbaa !9
  store i64 %51, ptr %20, align 8, !tbaa !9
  store i64 1, ptr %23, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %139, %49
  %53 = load i64, ptr %23, align 8, !tbaa !9
  %54 = load i64, ptr %20, align 8, !tbaa !9
  %55 = icmp sle i64 %53, %54
  br i1 %55, label %56, label %142

56:                                               ; preds = %52
  %57 = load i64, ptr %23, align 8, !tbaa !9
  %58 = load i64, ptr %24, align 8, !tbaa !9
  %59 = load i64, ptr %17, align 8, !tbaa !9
  %60 = mul nsw i64 %58, %59
  %61 = add nsw i64 %57, %60
  store i64 %61, ptr %21, align 8, !tbaa !9
  %62 = load i64, ptr %23, align 8, !tbaa !9
  %63 = load i64, ptr %24, align 8, !tbaa !9
  %64 = load i64, ptr %17, align 8, !tbaa !9
  %65 = mul nsw i64 %63, %64
  %66 = add nsw i64 %62, %65
  store i64 %66, ptr %22, align 8, !tbaa !9
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load i64, ptr %21, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.doublecomplex, ptr %67, i64 %68
  %70 = getelementptr inbounds %struct.doublecomplex, ptr %69, i32 0, i32 0
  %71 = load double, ptr %70, align 8, !tbaa !13
  %72 = load double, ptr %25, align 8, !tbaa !11
  %73 = fneg double %72
  %74 = fcmp olt double %71, %73
  br i1 %74, label %106, label %75

75:                                               ; preds = %56
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = load i64, ptr %22, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.doublecomplex, ptr %76, i64 %77
  %79 = getelementptr inbounds %struct.doublecomplex, ptr %78, i32 0, i32 0
  %80 = load double, ptr %79, align 8, !tbaa !13
  %81 = load double, ptr %25, align 8, !tbaa !11
  %82 = fcmp ogt double %80, %81
  br i1 %82, label %106, label %83

83:                                               ; preds = %75
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = load i64, ptr %23, align 8, !tbaa !9
  %86 = load i64, ptr %24, align 8, !tbaa !9
  %87 = load i64, ptr %17, align 8, !tbaa !9
  %88 = mul nsw i64 %86, %87
  %89 = add nsw i64 %85, %88
  %90 = getelementptr inbounds %struct.doublecomplex, ptr %84, i64 %89
  %91 = call double @d_imag(ptr noundef %90)
  %92 = load double, ptr %25, align 8, !tbaa !11
  %93 = fneg double %92
  %94 = fcmp olt double %91, %93
  br i1 %94, label %106, label %95

95:                                               ; preds = %83
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = load i64, ptr %23, align 8, !tbaa !9
  %98 = load i64, ptr %24, align 8, !tbaa !9
  %99 = load i64, ptr %17, align 8, !tbaa !9
  %100 = mul nsw i64 %98, %99
  %101 = add nsw i64 %97, %100
  %102 = getelementptr inbounds %struct.doublecomplex, ptr %96, i64 %101
  %103 = call double @d_imag(ptr noundef %102)
  %104 = load double, ptr %25, align 8, !tbaa !11
  %105 = fcmp ogt double %103, %104
  br i1 %105, label %106, label %108

106:                                              ; preds = %95, %83, %75, %56
  %107 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 1, ptr %107, align 8, !tbaa !9
  br label %148

108:                                              ; preds = %95
  %109 = load i64, ptr %23, align 8, !tbaa !9
  %110 = load i64, ptr %24, align 8, !tbaa !9
  %111 = load i64, ptr %15, align 8, !tbaa !9
  %112 = mul nsw i64 %110, %111
  %113 = add nsw i64 %109, %112
  store i64 %113, ptr %21, align 8, !tbaa !9
  %114 = load i64, ptr %23, align 8, !tbaa !9
  %115 = load i64, ptr %24, align 8, !tbaa !9
  %116 = load i64, ptr %17, align 8, !tbaa !9
  %117 = mul nsw i64 %115, %116
  %118 = add nsw i64 %114, %117
  store i64 %118, ptr %22, align 8, !tbaa !9
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = load i64, ptr %22, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.doublecomplex, ptr %119, i64 %120
  %122 = getelementptr inbounds %struct.doublecomplex, ptr %121, i32 0, i32 0
  %123 = load double, ptr %122, align 8, !tbaa !13
  %124 = fptrunc double %123 to float
  %125 = load ptr, ptr %12, align 8, !tbaa !5
  %126 = load i64, ptr %21, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct.complex, ptr %125, i64 %126
  %128 = getelementptr inbounds %struct.complex, ptr %127, i32 0, i32 0
  store float %124, ptr %128, align 4, !tbaa !15
  %129 = load ptr, ptr %10, align 8, !tbaa !5
  %130 = load i64, ptr %22, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.doublecomplex, ptr %129, i64 %130
  %132 = getelementptr inbounds %struct.doublecomplex, ptr %131, i32 0, i32 1
  %133 = load double, ptr %132, align 8, !tbaa !18
  %134 = fptrunc double %133 to float
  %135 = load ptr, ptr %12, align 8, !tbaa !5
  %136 = load i64, ptr %21, align 8, !tbaa !9
  %137 = getelementptr inbounds %struct.complex, ptr %135, i64 %136
  %138 = getelementptr inbounds %struct.complex, ptr %137, i32 0, i32 1
  store float %134, ptr %138, align 4, !tbaa !19
  br label %139

139:                                              ; preds = %108
  %140 = load i64, ptr %23, align 8, !tbaa !9
  %141 = add nsw i64 %140, 1
  store i64 %141, ptr %23, align 8, !tbaa !9
  br label %52, !llvm.loop !20

142:                                              ; preds = %52
  br label %143

143:                                              ; preds = %142
  %144 = load i64, ptr %24, align 8, !tbaa !9
  %145 = add nsw i64 %144, 1
  store i64 %145, ptr %24, align 8, !tbaa !9
  br label %45, !llvm.loop !22

146:                                              ; preds = %45
  %147 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 0, ptr %147, align 8, !tbaa !9
  br label %148

148:                                              ; preds = %146, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  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 8, ptr %15) #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 double @slamch_(ptr noundef) #2

declare double @d_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 = !{!"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 noundef i32 @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 i64, ptr %3, align 8, !tbaa !5
  %9 = xor i64 %8, -1
  %10 = getelementptr inbounds %struct.doublecomplex, ptr %2, i64 %9
  %11 = load i64, ptr %5, align 8, !tbaa !5
  %12 = xor i64 %11, -1
  %13 = getelementptr inbounds %struct.complex, ptr %4, i64 %12
  %14 = tail call double @slamch_(ptr noundef nonnull @.str) #2
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %.not63 = icmp slt i64 %15, 1
  br i1 %.not63, label %.loopexit, label %.lr.ph66

.lr.ph66:                                         ; preds = %7
  %16 = fneg double %14
  %17 = load i64, ptr %0, align 8, !tbaa !5
  %18 = icmp slt i64 %17, 1
  br i1 %18, label %.loopexit, label %.lr.ph66.split

.lr.ph66.splitthread-pre-split:                   ; preds = %._crit_edge
  %19 = add nuw i64 %.064, 1
  %.pr = load i64, ptr %0, align 8, !tbaa !5
  br label %.lr.ph66.split

.lr.ph66.split:                                   ; preds = %.lr.ph66, %.lr.ph66.splitthread-pre-split
  %20 = phi i64 [ %.pr, %.lr.ph66.splitthread-pre-split ], [ %17, %.lr.ph66 ]
  %.064 = phi i64 [ %19, %.lr.ph66.splitthread-pre-split ], [ 1, %.lr.ph66 ]
  %.not5759 = icmp slt i64 %20, 1
  br i1 %.not5759, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph66.split
  %21 = mul nsw i64 %.064, %8
  %invariant.gep = getelementptr %struct.doublecomplex, ptr %10, i64 %21
  %22 = mul nsw i64 %.064, %11
  %invariant.gep61 = getelementptr %struct.complex, ptr %13, i64 %22
  br label %23

23:                                               ; preds = %.lr.ph, %33
  %.05360 = phi i64 [ 1, %.lr.ph ], [ %36, %33 ]
  %gep = getelementptr %struct.doublecomplex, ptr %invariant.gep, i64 %.05360
  %24 = load double, ptr %gep, align 8, !tbaa !9
  %25 = fcmp olt double %24, %16
  %26 = fcmp ogt double %24, %14
  %or.cond = or i1 %25, %26
  br i1 %or.cond, label %.loopexit, label %27

27:                                               ; preds = %23
  %28 = tail call double @d_imag(ptr noundef nonnull %gep) #2
  %29 = fcmp olt double %28, %16
  br i1 %29, label %.loopexit, label %30

30:                                               ; preds = %27
  %31 = tail call double @d_imag(ptr noundef nonnull %gep) #2
  %32 = fcmp ogt double %31, %14
  br i1 %32, label %.loopexit, label %33

33:                                               ; preds = %30
  %gep62 = getelementptr %struct.complex, ptr %invariant.gep61, i64 %.05360
  %34 = load <2 x double>, ptr %gep, align 8, !tbaa !12
  %35 = fptrunc <2 x double> %34 to <2 x float>
  store <2 x float> %35, ptr %gep62, align 4, !tbaa !13
  %36 = add nuw i64 %.05360, 1
  %exitcond.not = icmp eq i64 %.05360, %20
  br i1 %exitcond.not, label %._crit_edge, label %23, !llvm.loop !15

._crit_edge:                                      ; preds = %33, %.lr.ph66.split
  %exitcond69.not = icmp eq i64 %.064, %15
  br i1 %exitcond69.not, label %.loopexit, label %.lr.ph66.splitthread-pre-split, !llvm.loop !17

.loopexit:                                        ; preds = %._crit_edge, %23, %27, %30, %.lr.ph66, %7
  %storemerge = phi i64 [ 0, %7 ], [ 0, %.lr.ph66 ], [ 1, %30 ], [ 1, %27 ], [ 1, %23 ], [ 0, %._crit_edge ]
  store i64 %storemerge, ptr %6, align 8, !tbaa !5
  ret i32 0
}

declare double @slamch_(ptr noundef) local_unnamed_addr #1

declare double @d_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, !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