; LLVM IR from OpenMathLib/OpenBLAS :: relapack/src (chetrf_rook)

; 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"

@.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 [12 x i8], align 1

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

40:                                               ; preds = %8
  %41 = load i32, ptr %20, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %45, label %43

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

45:                                               ; preds = %40, %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 %92

51:                                               ; preds = %45
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = icmp sgt i32 1, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  br label %61

58:                                               ; preds = %51
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load i32, ptr %59, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %58, %57
  %62 = phi i32 [ 1, %57 ], [ %60, %58 ]
  %63 = icmp slt i32 %53, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %61
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -4, ptr %65, align 4, !tbaa !9
  br label %91

66:                                               ; preds = %61
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = icmp slt i32 %68, 1
  br i1 %69, label %75, label %70

70:                                               ; preds = %66
  %71 = load ptr, ptr %15, align 8, !tbaa !5
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = load i32, ptr %18, align 4, !tbaa !9
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %75, label %81

75:                                               ; preds = %70, %66
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp ne i32 %77, -1
  br i1 %78, label %79, label %81

79:                                               ; preds = %75
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -7, ptr %80, align 4, !tbaa !9
  br label %90

81:                                               ; preds = %75, %70
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp eq i32 %83, -1
  br i1 %84, label %85, label %89

85:                                               ; preds = %81
  %86 = load i32, ptr %17, align 4, !tbaa !9
  %87 = sitofp i32 %86 to float
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  store float %87, ptr %88, align 4, !tbaa !11
  store i32 1, ptr %21, align 4
  br label %118

89:                                               ; preds = %81
  br label %90

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

91:                                               ; preds = %90, %64
  br label %92

92:                                               ; preds = %91, %49
  br label %93

93:                                               ; preds = %92, %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %94, ptr %22, align 8, !tbaa !5
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %103

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = sub nsw i32 0, %100
  store i32 %101, ptr %23, align 4, !tbaa !9
  %102 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %23, i32 noundef 11)
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  br label %117

103:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #3
  %104 = load i32, ptr %19, align 4, !tbaa !9
  %105 = icmp ne i32 %104, 0
  %106 = zext i1 %105 to i64
  %107 = select i1 %105, i32 76, i32 85
  %108 = trunc i32 %107 to i8
  store i8 %108, ptr %24, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = load ptr, ptr %12, align 8, !tbaa !5
  %113 = load ptr, ptr %13, align 8, !tbaa !5
  %114 = load ptr, ptr %22, align 8, !tbaa !5
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = load ptr, ptr %16, align 8, !tbaa !5
  call void @RELAPACK_chetrf_rook_rec(ptr noundef %24, ptr noundef %109, ptr noundef %110, ptr noundef %25, ptr noundef %111, ptr noundef %112, ptr noundef %113, ptr noundef %114, ptr noundef %115, ptr noundef %116)
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #3
  store i32 0, ptr %21, align 4
  br label %117

117:                                              ; preds = %103, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  br label %118

118:                                              ; preds = %117, %85
  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
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  %119 = load i32, ptr %21, align 4
  switch i32 %119, label %121 [
    i32 0, label %120
    i32 1, label %120
  ]

120:                                              ; preds = %118, %118
  ret void

121:                                              ; preds = %118
  unreachable
}

; 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

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

; Function Attrs: nounwind uwtable
declare hidden void @RELAPACK_chetrf_rook_rec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!7, !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 [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @RELAPACK_chetrf_rook(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr nocapture noundef readonly %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = sdiv i32 %12, 2
  %14 = mul nsw i32 %13, %12
  %15 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %16 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  %17 = icmp ne i32 %15, 0
  %18 = icmp ne i32 %16, 0
  %or.cond = select i1 %17, i1 true, i1 %18
  br i1 %or.cond, label %19, label %.thread38

19:                                               ; preds = %8
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %.thread38, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.umax.i32(i32 %20, i32 1)
  %24 = icmp slt i32 %23, %spec.select
  br i1 %24, label %.thread38, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 1
  %28 = icmp slt i32 %26, %14
  %or.cond37 = select i1 %27, i1 true, i1 %28
  br i1 %or.cond37, label %29, label %33

29:                                               ; preds = %25
  %.not = icmp eq i32 %26, -1
  br i1 %.not, label %30, label %.thread38

30:                                               ; preds = %29
  %31 = sitofp i32 %14 to float
  store float %31, ptr %5, align 4, !tbaa !9
  br label %35

.thread38:                                        ; preds = %29, %22, %19, %8
  %.sink = phi i32 [ -1, %8 ], [ -2, %19 ], [ -4, %22 ], [ -7, %29 ]
  %.neg = phi i32 [ 1, %8 ], [ 2, %19 ], [ 4, %22 ], [ 7, %29 ]
  store i32 %.sink, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  store i32 %.neg, ptr %9, align 4, !tbaa !5
  %32 = call i32 @xerbla_(ptr noundef nonnull @.str.2, ptr noundef nonnull %9, i32 noundef 11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  br label %35

33:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #4
  %34 = select i1 %17, i8 76, i8 85
  store i8 %34, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  call void @RELAPACK_chetrf_rook_rec(ptr noundef nonnull %10, ptr noundef nonnull %1, ptr noundef nonnull %1, ptr noundef nonnull %11, ptr noundef %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef %5, ptr noundef nonnull %1, ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #4
  br label %35

35:                                               ; preds = %.thread38, %33, %30
  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

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

; Function Attrs: nounwind uwtable
declare hidden void @RELAPACK_chetrf_rook_rec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass