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

; 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 [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @chpsv_(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 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 ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.complex, ptr %21, i32 -1
  store ptr %22, ptr %12, align 8, !tbaa !5
  %23 = load ptr, ptr %13, align 8, !tbaa !5
  %24 = getelementptr inbounds i32, ptr %23, i32 -1
  store ptr %24, ptr %13, align 8, !tbaa !5
  %25 = load ptr, ptr %15, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %26, ptr %17, align 4, !tbaa !9
  %27 = load i32, ptr %17, align 4, !tbaa !9
  %28 = mul nsw i32 %27, 1
  %29 = add nsw i32 1, %28
  store i32 %29, ptr %18, align 4, !tbaa !9
  %30 = load i32, ptr %18, align 4, !tbaa !9
  %31 = load ptr, ptr %14, align 8, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = sub i64 0, %32
  %34 = getelementptr inbounds %struct.complex, ptr %31, i64 %33
  store ptr %34, ptr %14, align 8, !tbaa !5
  %35 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 0, ptr %35, align 4, !tbaa !9
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = call i32 @lsame_(ptr noundef %36, ptr noundef @.str)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %45, label %39

39:                                               ; preds = %8
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = call i32 @lsame_(ptr noundef %40, ptr noundef @.str.1)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %45, label %43

43:                                               ; preds = %39
  %44 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -1, ptr %44, align 4, !tbaa !9
  br label %75

45:                                               ; preds = %39, %8
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -2, ptr %50, align 4, !tbaa !9
  br label %74

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

55:                                               ; preds = %51
  %56 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -3, ptr %56, align 4, !tbaa !9
  br label %73

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

63:                                               ; preds = %57
  br label %67

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

67:                                               ; preds = %64, %63
  %68 = phi i32 [ 1, %63 ], [ %66, %64 ]
  %69 = icmp slt i32 %59, %68
  br i1 %69, label %70, label %72

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

72:                                               ; preds = %70, %67
  br label %73

73:                                               ; preds = %72, %55
  br label %74

74:                                               ; preds = %73, %49
  br label %75

75:                                               ; preds = %74, %43
  %76 = load ptr, ptr %16, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %84

79:                                               ; preds = %75
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = sub nsw i32 0, %81
  store i32 %82, ptr %19, align 4, !tbaa !9
  %83 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %19, i32 noundef 6)
  store i32 1, ptr %20, align 4
  br label %110

84:                                               ; preds = %75
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.complex, ptr %87, i64 1
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = getelementptr inbounds i32, ptr %89, i64 1
  %91 = load ptr, ptr %16, align 8, !tbaa !5
  call void @chptrf_(ptr noundef %85, ptr noundef %86, ptr noundef %88, ptr noundef %90, ptr noundef %91)
  %92 = load ptr, ptr %16, align 8, !tbaa !5
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = icmp eq i32 %93, 0
  br i1 %94, label %95, label %109

95:                                               ; preds = %84
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.complex, ptr %99, i64 1
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds i32, ptr %101, i64 1
  %103 = load ptr, ptr %14, align 8, !tbaa !5
  %104 = load i32, ptr %18, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.complex, ptr %103, i64 %105
  %107 = load ptr, ptr %15, align 8, !tbaa !5
  %108 = load ptr, ptr %16, align 8, !tbaa !5
  call void @chptrs_(ptr noundef %96, ptr noundef %97, ptr noundef %98, ptr noundef %100, ptr noundef %102, ptr noundef %106, ptr noundef %107, ptr noundef %108)
  br label %109

109:                                              ; preds = %95, %84
  store i32 1, ptr %20, align 4
  br label %110

110:                                              ; preds = %109, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #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 @lsame_(ptr noundef, ptr noundef) #2

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

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

declare void @chptrs_(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 [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @chpsv_(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 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %13

11:                                               ; preds = %8
  %12 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  %.not35 = icmp eq i32 %12, 0
  br i1 %.not35, label %.thread.sink.split, label %13

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

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

19:                                               ; preds = %16
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.umax.i32(i32 %14, i32 1)
  %21 = icmp slt i32 %20, %spec.select
  br i1 %21, label %.thread.sink.split, label %22

22:                                               ; preds = %19
  %.pr = load i32, ptr %7, align 4, !tbaa !5
  %.not36 = icmp eq i32 %.pr, 0
  br i1 %.not36, label %26, label %.thread

.thread.sink.split:                               ; preds = %19, %16, %13, %11
  %.sink = phi i32 [ -1, %11 ], [ -2, %13 ], [ -3, %16 ], [ -7, %19 ]
  store i32 %.sink, ptr %7, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %22
  %23 = phi i32 [ %.pr, %22 ], [ %.sink, %.thread.sink.split ]
  %24 = sub nsw i32 0, %23
  store i32 %24, ptr %9, align 4, !tbaa !5
  %25 = call i32 @xerbla_(ptr noundef nonnull @.str.2, ptr noundef nonnull %9, i32 noundef 6) #4
  br label %30

26:                                               ; preds = %22
  tail call void @chptrf_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %7) #4
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  tail call void @chptrs_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %7) #4
  br label %30

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

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

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

declare void @chptrs_(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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass