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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cpotri_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = load i64, ptr %16, align 8, !tbaa !9
  store i64 %17, ptr %12, align 8, !tbaa !9
  %18 = load i64, ptr %12, align 8, !tbaa !9
  %19 = add nsw i64 1, %18
  store i64 %19, ptr %13, align 8, !tbaa !9
  %20 = load i64, ptr %13, align 8, !tbaa !9
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = sub i64 0, %20
  %23 = getelementptr inbounds %struct.complex, ptr %21, i64 %22
  store ptr %23, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %24, align 8, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i64 @lsame_(ptr noundef %25, ptr noundef @.str)
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %34, label %28

28:                                               ; preds = %5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call i64 @lsame_(ptr noundef %29, ptr noundef @.str.1)
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %34, label %32

32:                                               ; preds = %28
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -1, ptr %33, align 8, !tbaa !9
  br label %57

34:                                               ; preds = %28, %5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = icmp slt i64 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -2, ptr %39, align 8, !tbaa !9
  br label %56

40:                                               ; preds = %34
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = icmp sge i64 1, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %40
  br label %50

47:                                               ; preds = %40
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %48, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %47, %46
  %51 = phi i64 [ 1, %46 ], [ %49, %47 ]
  %52 = icmp slt i64 %42, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %50
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -4, ptr %54, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %53, %50
  br label %56

56:                                               ; preds = %55, %38
  br label %57

57:                                               ; preds = %56, %32
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = icmp ne i64 %59, 0
  br i1 %60, label %61, label %66

61:                                               ; preds = %57
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = sub nsw i64 0, %63
  store i64 %64, ptr %14, align 8, !tbaa !9
  %65 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %14)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %93

66:                                               ; preds = %57
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = icmp eq i64 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %66
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %93

71:                                               ; preds = %66
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load i64, ptr %13, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.complex, ptr %74, i64 %75
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = call i32 @ctrtri_(ptr noundef %72, ptr noundef @.str.3, ptr noundef %73, ptr noundef %76, ptr noundef %77, ptr noundef %78)
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = load i64, ptr %80, align 8, !tbaa !9
  %82 = icmp sgt i64 %81, 0
  br i1 %82, label %83, label %84

83:                                               ; preds = %71
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %93

84:                                               ; preds = %71
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = load i64, ptr %13, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.complex, ptr %87, i64 %88
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = call i32 @clauum_(ptr noundef %85, ptr noundef %86, ptr noundef %89, ptr noundef %90, ptr noundef %91)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %93

93:                                               ; preds = %84, %83, %70, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %94 = load i32, ptr %6, align 4
  ret i32 %94
}

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

declare i32 @clauum_(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
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cpotri_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  %7 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  %.not31 = icmp eq i64 %9, 0
  br i1 %.not31, label %.thread.sink.split, label %10

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

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

16:                                               ; preds = %13
  %.pr = load i64, ptr %4, align 8, !tbaa !5
  %.not32 = icmp eq i64 %.pr, 0
  br i1 %.not32, label %20, label %.thread

.thread.sink.split:                               ; preds = %13, %10, %8
  %.sink = phi i64 [ -1, %8 ], [ -2, %10 ], [ -4, %13 ]
  store i64 %.sink, ptr %4, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %16
  %17 = phi i64 [ %.pr, %16 ], [ %.sink, %.thread.sink.split ]
  %18 = sub nsw i64 0, %17
  store i64 %18, ptr %6, align 8, !tbaa !5
  %19 = call i32 @xerbla_(ptr noundef nonnull @.str.2, ptr noundef nonnull %6) #4
  br label %28

20:                                               ; preds = %16
  %21 = icmp eq i64 %11, 0
  br i1 %21, label %28, label %22

22:                                               ; preds = %20
  %23 = tail call i32 @ctrtri_(ptr noundef %0, ptr noundef nonnull @.str.3, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, ptr noundef nonnull %4) #4
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %28, label %26

26:                                               ; preds = %22
  %27 = tail call i32 @clauum_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, ptr noundef nonnull %4) #4
  br label %28

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

declare i32 @clauum_(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,SROAPass,SimplifyCFGPass,TailCallElimPass