; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/SRC (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 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 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 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %24 = load ptr, ptr %13, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %25, ptr %18, align 4, !tbaa !9
  %26 = load i32, ptr %18, align 4, !tbaa !9
  %27 = mul nsw i32 %26, 1
  %28 = add nsw i32 1, %27
  store i32 %28, ptr %19, align 4, !tbaa !9
  %29 = load i32, ptr %19, align 4, !tbaa !9
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = sext i32 %29 to i64
  %32 = sub i64 0, %31
  %33 = getelementptr inbounds %struct.complex, ptr %30, i64 %32
  store ptr %33, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %14, align 8, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i32 -1
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  %37 = load i32, ptr %36, align 4, !tbaa !9
  store i32 %37, ptr %20, align 4, !tbaa !9
  %38 = load i32, ptr %20, align 4, !tbaa !9
  %39 = mul nsw i32 %38, 1
  %40 = add nsw i32 1, %39
  store i32 %40, ptr %21, align 4, !tbaa !9
  %41 = load i32, ptr %21, align 4, !tbaa !9
  %42 = load ptr, ptr %15, 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 %15, align 8, !tbaa !5
  %46 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 0, ptr %46, align 4, !tbaa !9
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %8
  %51 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 -1, ptr %51, align 4, !tbaa !9
  br label %91

52:                                               ; preds = %8
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 -2, ptr %57, align 4, !tbaa !9
  br label %90

58:                                               ; preds = %52
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = icmp sge i32 1, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  br label %68

65:                                               ; preds = %58
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %65, %64
  %69 = phi i32 [ 1, %64 ], [ %67, %65 ]
  %70 = icmp slt i32 %60, %69
  br i1 %70, label %71, label %73

71:                                               ; preds = %68
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 -4, ptr %72, align 4, !tbaa !9
  br label %89

73:                                               ; preds = %68
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp sge i32 1, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %73
  br label %83

80:                                               ; preds = %73
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i32, ptr %81, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %80, %79
  %84 = phi i32 [ 1, %79 ], [ %82, %80 ]
  %85 = icmp slt i32 %75, %84
  br i1 %85, label %86, label %88

86:                                               ; preds = %83
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 -7, ptr %87, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %86, %83
  br label %89

89:                                               ; preds = %88, %71
  br label %90

90:                                               ; preds = %89, %56
  br label %91

91:                                               ; preds = %90, %50
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %100

95:                                               ; preds = %91
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = load i32, ptr %96, align 4, !tbaa !9
  %98 = sub nsw i32 0, %97
  store i32 %98, ptr %22, align 4, !tbaa !9
  %99 = call i32 @xerbla_(ptr noundef @.str, ptr noundef %22, i32 noundef 6)
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %131

100:                                              ; preds = %91
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = load i32, ptr %19, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.complex, ptr %103, i64 %105
  %107 = load ptr, ptr %13, align 8, !tbaa !5
  %108 = load ptr, ptr %14, align 8, !tbaa !5
  %109 = getelementptr inbounds i32, ptr %108, i64 1
  %110 = load ptr, ptr %17, align 8, !tbaa !5
  call void @cgetrf_(ptr noundef %101, ptr noundef %102, ptr noundef %106, ptr noundef %107, ptr noundef %109, ptr noundef %110)
  %111 = load ptr, ptr %17, align 8, !tbaa !5
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = icmp eq i32 %112, 0
  br i1 %113, label %114, label %130

114:                                              ; preds = %100
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = load i32, ptr %19, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.complex, ptr %117, i64 %119
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = load ptr, ptr %14, align 8, !tbaa !5
  %123 = getelementptr inbounds i32, ptr %122, i64 1
  %124 = load ptr, ptr %15, align 8, !tbaa !5
  %125 = load i32, ptr %21, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds %struct.complex, ptr %124, i64 %126
  %128 = load ptr, ptr %16, align 8, !tbaa !5
  %129 = load ptr, ptr %17, align 8, !tbaa !5
  call void @cgetrs_(ptr noundef @.str.1, ptr noundef %115, ptr noundef %116, ptr noundef %120, ptr noundef %121, ptr noundef %123, ptr noundef %127, ptr noundef %128, ptr noundef %129)
  br label %130

130:                                              ; preds = %114, %100
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %131

131:                                              ; preds = %130, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %132 = load i32, ptr %9, align 4
  ret i32 %132
}

; 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, i32 noundef) #2

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

declare void @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 = !{!"int", !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 i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  %10 = load i32, ptr %0, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %.thread, label %12

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

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

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

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

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

25:                                               ; preds = %22
  tail call void @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 %26

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

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

declare void @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 i32 @llvm.umax.i32(i32, i32) #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 = !{!"int", !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