; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (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 i32 @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 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 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
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.complex, ptr %22, i32 -1
  store ptr %23, ptr %13, align 8, !tbaa !5
  %24 = load ptr, ptr %14, align 8, !tbaa !5
  %25 = getelementptr inbounds i64, ptr %24, i32 -1
  store ptr %25, ptr %14, align 8, !tbaa !5
  %26 = load ptr, ptr %16, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  store i64 %27, ptr %18, align 8, !tbaa !9
  %28 = load i64, ptr %18, align 8, !tbaa !9
  %29 = add nsw i64 1, %28
  store i64 %29, ptr %19, align 8, !tbaa !9
  %30 = load i64, ptr %19, align 8, !tbaa !9
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  %32 = sub i64 0, %30
  %33 = getelementptr inbounds %struct.complex, ptr %31, i64 %32
  store ptr %33, ptr %15, align 8, !tbaa !5
  %34 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 0, ptr %34, align 8, !tbaa !9
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = call i64 @lsame_(ptr noundef %35, ptr noundef @.str)
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %44, label %38

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

42:                                               ; preds = %38
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -1, ptr %43, align 8, !tbaa !9
  br label %74

44:                                               ; preds = %38, %8
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = icmp slt i64 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -2, ptr %49, align 8, !tbaa !9
  br label %73

50:                                               ; preds = %44
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %50
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -3, ptr %55, align 8, !tbaa !9
  br label %72

56:                                               ; preds = %50
  %57 = load ptr, ptr %16, align 8, !tbaa !5
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp sge i64 1, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %56
  br label %66

63:                                               ; preds = %56
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load i64, ptr %64, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %63, %62
  %67 = phi i64 [ 1, %62 ], [ %65, %63 ]
  %68 = icmp slt i64 %58, %67
  br i1 %68, label %69, label %71

69:                                               ; preds = %66
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 -7, ptr %70, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %69, %66
  br label %72

72:                                               ; preds = %71, %54
  br label %73

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

74:                                               ; preds = %73, %42
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  %76 = load i64, ptr %75, align 8, !tbaa !9
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %83

78:                                               ; preds = %74
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %81 = sub nsw i64 0, %80
  store i64 %81, ptr %20, align 8, !tbaa !9
  %82 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %20)
  store i32 0, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %110

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

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

109:                                              ; preds = %95, %83
  store i32 0, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %110

110:                                              ; preds = %109, %78
  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
  %111 = load i32, ptr %9, align 4
  ret i32 %111
}

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

declare i64 @lsame_(ptr noundef, ptr noundef) #2

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

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

declare i32 @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 = !{!"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 [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 noundef i32 @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 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 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %11, label %13

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

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

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

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

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

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

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

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

30:                                               ; preds = %26
  %31 = tail call i32 @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 %32

32:                                               ; preds = %26, %30, %.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 i64 @lsame_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

declare i32 @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 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass