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

; 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 void @cgbsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) #0 {
  %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 ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  store ptr %9, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %27 = load ptr, ptr %16, align 8, !tbaa !5
  %28 = load i32, ptr %27, align 4, !tbaa !9
  store i32 %28, ptr %21, align 4, !tbaa !9
  %29 = load i32, ptr %21, align 4, !tbaa !9
  %30 = mul nsw i32 %29, 1
  %31 = add nsw i32 1, %30
  store i32 %31, ptr %22, align 4, !tbaa !9
  %32 = load i32, ptr %22, align 4, !tbaa !9
  %33 = load ptr, ptr %15, align 8, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = sub i64 0, %34
  %36 = getelementptr inbounds %struct.complex, ptr %33, i64 %35
  store ptr %36, ptr %15, align 8, !tbaa !5
  %37 = load ptr, ptr %17, align 8, !tbaa !5
  %38 = getelementptr inbounds i32, ptr %37, i32 -1
  store ptr %38, ptr %17, align 8, !tbaa !5
  %39 = load ptr, ptr %19, align 8, !tbaa !5
  %40 = load i32, ptr %39, align 4, !tbaa !9
  store i32 %40, ptr %23, align 4, !tbaa !9
  %41 = load i32, ptr %23, align 4, !tbaa !9
  %42 = mul nsw i32 %41, 1
  %43 = add nsw i32 1, %42
  store i32 %43, ptr %24, align 4, !tbaa !9
  %44 = load i32, ptr %24, align 4, !tbaa !9
  %45 = load ptr, ptr %18, align 8, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = sub i64 0, %46
  %48 = getelementptr inbounds %struct.complex, ptr %45, i64 %47
  store ptr %48, ptr %18, align 8, !tbaa !5
  %49 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 0, ptr %49, align 4, !tbaa !9
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %10
  %54 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -1, ptr %54, align 4, !tbaa !9
  br label %106

55:                                               ; preds = %10
  %56 = load ptr, ptr %12, 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 %61

59:                                               ; preds = %55
  %60 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -2, ptr %60, align 4, !tbaa !9
  br label %105

61:                                               ; preds = %55
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = icmp slt i32 %63, 0
  br i1 %64, label %65, label %67

65:                                               ; preds = %61
  %66 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -3, ptr %66, align 4, !tbaa !9
  br label %104

67:                                               ; preds = %61
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = icmp slt i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %67
  %72 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -4, ptr %72, align 4, !tbaa !9
  br label %103

73:                                               ; preds = %67
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = shl i32 %77, 1
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = add nsw i32 %78, %80
  %82 = add nsw i32 %81, 1
  %83 = icmp slt i32 %75, %82
  br i1 %83, label %84, label %86

84:                                               ; preds = %73
  %85 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -6, ptr %85, align 4, !tbaa !9
  br label %102

86:                                               ; preds = %73
  %87 = load ptr, ptr %19, align 8, !tbaa !5
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = icmp sge i32 %90, 1
  br i1 %91, label %92, label %95

92:                                               ; preds = %86
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = load i32, ptr %93, align 4, !tbaa !9
  br label %96

95:                                               ; preds = %86
  br label %96

96:                                               ; preds = %95, %92
  %97 = phi i32 [ %94, %92 ], [ 1, %95 ]
  %98 = icmp slt i32 %88, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %96
  %100 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 -9, ptr %100, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %99, %96
  br label %102

102:                                              ; preds = %101, %84
  br label %103

103:                                              ; preds = %102, %71
  br label %104

104:                                              ; preds = %103, %65
  br label %105

105:                                              ; preds = %104, %59
  br label %106

106:                                              ; preds = %105, %53
  %107 = load ptr, ptr %20, align 8, !tbaa !5
  %108 = load i32, ptr %107, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %115

110:                                              ; preds = %106
  %111 = load ptr, ptr %20, align 8, !tbaa !5
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = sub nsw i32 0, %112
  store i32 %113, ptr %25, align 4, !tbaa !9
  %114 = call i32 @xerbla_(ptr noundef @.str, ptr noundef %25, i32 noundef 6)
  store i32 1, ptr %26, align 4
  br label %150

115:                                              ; preds = %106
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = load i32, ptr %22, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds %struct.complex, ptr %120, i64 %122
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = load ptr, ptr %17, align 8, !tbaa !5
  %126 = getelementptr inbounds i32, ptr %125, i64 1
  %127 = load ptr, ptr %20, align 8, !tbaa !5
  call void @cgbtrf_(ptr noundef %116, ptr noundef %117, ptr noundef %118, ptr noundef %119, ptr noundef %123, ptr noundef %124, ptr noundef %126, ptr noundef %127)
  %128 = load ptr, ptr %20, align 8, !tbaa !5
  %129 = load i32, ptr %128, align 4, !tbaa !9
  %130 = icmp eq i32 %129, 0
  br i1 %130, label %131, label %149

131:                                              ; preds = %115
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  %133 = load ptr, ptr %12, align 8, !tbaa !5
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  %135 = load ptr, ptr %14, align 8, !tbaa !5
  %136 = load ptr, ptr %15, align 8, !tbaa !5
  %137 = load i32, ptr %22, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds %struct.complex, ptr %136, i64 %138
  %140 = load ptr, ptr %16, align 8, !tbaa !5
  %141 = load ptr, ptr %17, align 8, !tbaa !5
  %142 = getelementptr inbounds i32, ptr %141, i64 1
  %143 = load ptr, ptr %18, align 8, !tbaa !5
  %144 = load i32, ptr %24, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds %struct.complex, ptr %143, i64 %145
  %147 = load ptr, ptr %19, align 8, !tbaa !5
  %148 = load ptr, ptr %20, align 8, !tbaa !5
  call void @cgbtrs_(ptr noundef @.str.1, ptr noundef %132, ptr noundef %133, ptr noundef %134, ptr noundef %135, ptr noundef %139, ptr noundef %140, ptr noundef %142, ptr noundef %146, ptr noundef %147, ptr noundef %148)
  br label %149

149:                                              ; preds = %131, %115
  store i32 1, ptr %26, align 4
  br label %150

150:                                              ; preds = %149, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  ret void
}

; 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 @cgbtrf_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @cgbtrs_(ptr noundef, ptr noundef, 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 void @cgbsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) local_unnamed_addr #0 {
  %11 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  %12 = load i32, ptr %0, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %.thread, label %14

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

17:                                               ; preds = %14
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %.thread, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %.thread, label %23

23:                                               ; preds = %20
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = shl nuw i32 %15, 1
  %26 = add nsw i32 %18, %25
  %.not = icmp sgt i32 %24, %26
  br i1 %.not, label %27, label %.thread

27:                                               ; preds = %23
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.umax.i32(i32 %12, i32 1)
  %29 = icmp slt i32 %28, %spec.select
  br i1 %29, label %.thread, label %31

.thread:                                          ; preds = %27, %23, %20, %17, %14, %10
  %.sink = phi i32 [ -1, %10 ], [ -2, %14 ], [ -3, %17 ], [ -4, %20 ], [ -6, %23 ], [ -9, %27 ]
  %.neg = phi i32 [ 1, %10 ], [ 2, %14 ], [ 3, %17 ], [ 4, %20 ], [ 6, %23 ], [ 9, %27 ]
  store i32 %.sink, ptr %9, align 4, !tbaa !5
  store i32 %.neg, ptr %11, align 4, !tbaa !5
  %30 = call i32 @xerbla_(ptr noundef nonnull @.str, ptr noundef nonnull %11, i32 noundef 6) #4
  br label %35

31:                                               ; preds = %27
  tail call void @cgbtrf_(ptr noundef nonnull %0, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %4, ptr noundef nonnull %5, ptr noundef %6, ptr noundef nonnull %9) #4
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  tail call void @cgbtrs_(ptr noundef nonnull @.str.1, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef nonnull %5, ptr noundef %6, ptr noundef %7, ptr noundef nonnull %8, ptr noundef nonnull %9) #4
  br label %35

35:                                               ; preds = %31, %34, %.thread
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  ret void
}

; 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 @cgbtrf_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @cgbtrs_(ptr noundef, ptr noundef, 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,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass