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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cgesv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #0 {
  %9 = alloca i32, align 4
  %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 ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, 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 i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  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
  %24 = load ptr, ptr %13, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !9
  store i64 %25, ptr %18, align 8, !tbaa !9
  %26 = load i64, ptr %18, align 8, !tbaa !9
  %27 = add nsw i64 1, %26
  store i64 %27, ptr %19, align 8, !tbaa !9
  %28 = load i64, ptr %19, align 8, !tbaa !9
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = sub i64 0, %28
  %31 = getelementptr inbounds %struct.complex, ptr %29, i64 %30
  store ptr %31, ptr %12, align 8, !tbaa !5
  %32 = load ptr, ptr %14, align 8, !tbaa !5
  %33 = getelementptr inbounds i64, ptr %32, i32 -1
  store ptr %33, ptr %14, align 8, !tbaa !5
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !9
  store i64 %35, ptr %20, align 8, !tbaa !9
  %36 = load i64, ptr %20, align 8, !tbaa !9
  %37 = add nsw i64 1, %36
  store i64 %37, ptr %21, align 8, !tbaa !9
  %38 = load i64, ptr %21, align 8, !tbaa !9
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = sub i64 0, %38
  %41 = getelementptr inbounds %struct.complex, ptr %39, i64 %40
  store ptr %41, ptr %15, align 8, !tbaa !5
  %42 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 0, ptr %42, align 8, !tbaa !9
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = icmp slt i64 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %8
  %47 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -1, ptr %47, align 8, !tbaa !9
  br label %87

48:                                               ; preds = %8
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = icmp slt i64 %50, 0
  br i1 %51, label %52, label %54

52:                                               ; preds = %48
  %53 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -2, ptr %53, align 8, !tbaa !9
  br label %86

54:                                               ; preds = %48
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = icmp sge i64 1, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  br label %64

61:                                               ; preds = %54
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load i64, ptr %62, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %61, %60
  %65 = phi i64 [ 1, %60 ], [ %63, %61 ]
  %66 = icmp slt i64 %56, %65
  br i1 %66, label %67, label %69

67:                                               ; preds = %64
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -4, ptr %68, align 8, !tbaa !9
  br label %85

69:                                               ; preds = %64
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = icmp sge i64 1, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %69
  br label %79

76:                                               ; preds = %69
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load i64, ptr %77, align 8, !tbaa !9
  br label %79

79:                                               ; preds = %76, %75
  %80 = phi i64 [ 1, %75 ], [ %78, %76 ]
  %81 = icmp slt i64 %71, %80
  br i1 %81, label %82, label %84

82:                                               ; preds = %79
  %83 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -7, ptr %83, align 8, !tbaa !9
  br label %84

84:                                               ; preds = %82, %79
  br label %85

85:                                               ; preds = %84, %67
  br label %86

86:                                               ; preds = %85, %52
  br label %87

87:                                               ; preds = %86, %46
  %88 = load ptr, ptr %17, align 8, !tbaa !5
  %89 = load i64, ptr %88, align 8, !tbaa !9
  %90 = icmp ne i64 %89, 0
  br i1 %90, label %91, label %96

91:                                               ; preds = %87
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = sub nsw i64 0, %93
  store i64 %94, ptr %22, align 8, !tbaa !9
  %95 = call i32 @xerbla_(ptr noundef @.str, ptr noundef %22)
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %126

96:                                               ; preds = %87
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = load i64, ptr %19, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.complex, ptr %99, i64 %100
  %102 = load ptr, ptr %13, align 8, !tbaa !5
  %103 = load ptr, ptr %14, align 8, !tbaa !5
  %104 = getelementptr inbounds i64, ptr %103, i64 1
  %105 = load ptr, ptr %17, align 8, !tbaa !5
  %106 = call i32 @cgetrf_(ptr noundef %97, ptr noundef %98, ptr noundef %101, ptr noundef %102, ptr noundef %104, ptr noundef %105)
  %107 = load ptr, ptr %17, align 8, !tbaa !5
  %108 = load i64, ptr %107, align 8, !tbaa !9
  %109 = icmp eq i64 %108, 0
  br i1 %109, label %110, label %125

110:                                              ; preds = %96
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = load i64, ptr %19, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.complex, ptr %113, i64 %114
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  %117 = load ptr, ptr %14, align 8, !tbaa !5
  %118 = getelementptr inbounds i64, ptr %117, i64 1
  %119 = load ptr, ptr %15, align 8, !tbaa !5
  %120 = load i64, ptr %21, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.complex, ptr %119, i64 %120
  %122 = load ptr, ptr %16, align 8, !tbaa !5
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  %124 = call i32 @cgetrs_(ptr noundef @.str.1, ptr noundef %111, ptr noundef %112, ptr noundef %115, ptr noundef %116, ptr noundef %118, ptr noundef %121, ptr noundef %122, ptr noundef %123)
  br label %125

125:                                              ; preds = %110, %96
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %126

126:                                              ; preds = %125, %91
  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
  %127 = load i32, ptr %9, align 4
  ret i32 %127
}

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

declare i32 @xerbla_(ptr noundef, ptr noundef) #2

declare i32 @cgetrf_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @cgetrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, 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}


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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cgesv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  %10 = load i64, ptr %0, align 8, !tbaa !5
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %8
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = icmp slt i64 %13, 0
  br i1 %14, label %.thread, label %15

15:                                               ; preds = %12
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umax.i64(i64 %10, i64 1)
  %17 = icmp slt i64 %16, %spec.select
  br i1 %17, label %.thread, label %18

18:                                               ; preds = %15
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %20 = icmp slt i64 %19, %spec.select
  br i1 %20, label %.thread, label %22

.thread:                                          ; preds = %18, %15, %12, %8
  %.sink = phi i64 [ -1, %8 ], [ -2, %12 ], [ -4, %15 ], [ -7, %18 ]
  %.neg = phi i64 [ 1, %8 ], [ 2, %12 ], [ 4, %15 ], [ 7, %18 ]
  store i64 %.sink, ptr %7, align 8, !tbaa !5
  store i64 %.neg, ptr %9, align 8, !tbaa !5
  %21 = call i32 @xerbla_(ptr noundef nonnull @.str, ptr noundef nonnull %9) #4
  br label %28

22:                                               ; preds = %18
  %23 = tail call i32 @cgetrf_(ptr noundef nonnull %0, ptr noundef nonnull %0, ptr noundef %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef nonnull %7) #4
  %24 = load i64, ptr %7, align 8, !tbaa !5
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  %27 = tail call i32 @cgetrs_(ptr noundef nonnull @.str.1, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %7) #4
  br label %28

28:                                               ; preds = %22, %26, %.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  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 i32 @xerbla_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @cgetrf_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @cgetrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass