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

; 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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @RELAPACK_chetrf(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 %89

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 %88

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 %87

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

71:                                               ; preds = %66
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = icmp ne i32 %73, -1
  br i1 %74, label %75, label %77

75:                                               ; preds = %71
  %76 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 -7, ptr %76, align 4, !tbaa !9
  br label %86

77:                                               ; preds = %71, %66
  %78 = load ptr, ptr %15, align 8, !tbaa !5
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = icmp eq i32 %79, -1
  br i1 %80, label %81, label %85

81:                                               ; preds = %77
  %82 = load i32, ptr %17, align 4, !tbaa !9
  %83 = sitofp i32 %82 to float
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  store float %83, ptr %84, align 4, !tbaa !11
  store i32 1, ptr %21, align 4
  br label %114

85:                                               ; preds = %77
  br label %86

86:                                               ; preds = %85, %75
  br label %87

87:                                               ; preds = %86, %64
  br label %88

88:                                               ; preds = %87, %49
  br label %89

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

94:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = sub nsw i32 0, %96
  store i32 %97, ptr %23, align 4, !tbaa !9
  %98 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %23, i32 noundef 6)
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  br label %113

99:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #3
  %100 = load i32, ptr %19, align 4, !tbaa !9
  %101 = icmp ne i32 %100, 0
  %102 = zext i1 %101 to i64
  %103 = select i1 %101, i32 76, i32 85
  %104 = trunc i32 %103 to i8
  store i8 %104, ptr %24, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  %108 = load ptr, ptr %12, align 8, !tbaa !5
  %109 = load ptr, ptr %13, align 8, !tbaa !5
  %110 = load ptr, ptr %22, align 8, !tbaa !5
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %16, align 8, !tbaa !5
  call void @RELAPACK_chetrf_rec(ptr noundef %24, ptr noundef %105, ptr noundef %106, ptr noundef %25, ptr noundef %107, ptr noundef %108, ptr noundef %109, ptr noundef %110, ptr noundef %111, ptr noundef %112)
  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 %113

113:                                              ; preds = %99, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  br label %114

114:                                              ; preds = %113, %81
  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
  %115 = load i32, ptr %21, align 4
  switch i32 %115, label %117 [
    i32 0, label %116
    i32 1, label %116
  ]

116:                                              ; preds = %114, %114
  ret void

117:                                              ; preds = %114
  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_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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @RELAPACK_chetrf(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 %.thread

19:                                               ; preds = %8
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %.thread, 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 %.thread, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp sge i32 %26, %14
  %.not = icmp eq i32 %26, -1
  %or.cond36 = or i1 %27, %.not
  br i1 %or.cond36, label %28, label %.thread

28:                                               ; preds = %25
  br i1 %.not, label %29, label %32

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

.thread:                                          ; preds = %25, %22, %19, %8
  %.sink = phi i32 [ -1, %8 ], [ -2, %19 ], [ -4, %22 ], [ -7, %25 ]
  %.neg = phi i32 [ 1, %8 ], [ 2, %19 ], [ 4, %22 ], [ 7, %25 ]
  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
  %31 = call i32 @xerbla_(ptr noundef nonnull @.str.2, ptr noundef nonnull %9, i32 noundef 6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  br label %34

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #4
  %33 = select i1 %17, i8 76, i8 85
  store i8 %33, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  call void @RELAPACK_chetrf_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 %34

34:                                               ; preds = %.thread, %32, %29
  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_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