; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/LAPACKE/src (lapacke_zlaset_work)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @LAPACKE_zlaset_work(i32 noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, ptr noundef %8, i32 noundef %9) #0 {
  %11 = alloca i32, align 4
  %12 = alloca { double, double }, align 8
  %13 = alloca { double, double }, align 8
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %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 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  store double %4, ptr %24, align 8
  %25 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  store double %5, ptr %25, align 8
  %26 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  store double %6, ptr %26, align 8
  %27 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  store double %7, ptr %27, align 8
  store i32 %0, ptr %14, align 4, !tbaa !5
  store i8 %1, ptr %15, align 1, !tbaa !9
  store i32 %2, ptr %16, align 4, !tbaa !5
  store i32 %3, ptr %17, align 4, !tbaa !5
  store ptr %8, ptr %18, align 8, !tbaa !10
  store i32 %9, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %20, align 4, !tbaa !5
  %28 = load i32, ptr %14, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 102
  br i1 %29, label %30, label %32

30:                                               ; preds = %10
  %31 = load ptr, ptr %18, align 8, !tbaa !10
  call void @zlaset_(ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %12, ptr noundef %13, ptr noundef %31, ptr noundef %19, i64 noundef 1)
  br label %94

32:                                               ; preds = %10
  %33 = load i32, ptr %14, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 101
  br i1 %34, label %35, label %91

35:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  %36 = load i32, ptr %16, align 4, !tbaa !5
  %37 = icmp sgt i32 1, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %41

39:                                               ; preds = %35
  %40 = load i32, ptr %16, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %39, %38
  %42 = phi i32 [ 1, %38 ], [ %40, %39 ]
  store i32 %42, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  store ptr null, ptr %22, align 8, !tbaa !10
  %43 = load i32, ptr %19, align 4, !tbaa !5
  %44 = load i32, ptr %17, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %41
  store i32 -8, ptr %20, align 4, !tbaa !5
  %47 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %47)
  %48 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %48, ptr %11, align 4
  store i32 1, ptr %23, align 4
  br label %88

49:                                               ; preds = %41
  %50 = load i32, ptr %21, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = mul i64 16, %51
  %53 = load i32, ptr %17, align 4, !tbaa !5
  %54 = icmp sgt i32 1, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %49
  br label %58

56:                                               ; preds = %49
  %57 = load i32, ptr %17, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %56, %55
  %59 = phi i32 [ 1, %55 ], [ %57, %56 ]
  %60 = sext i32 %59 to i64
  %61 = mul i64 %52, %60
  %62 = call noalias ptr @malloc(i64 noundef %61) #6
  store ptr %62, ptr %22, align 8, !tbaa !10
  %63 = load ptr, ptr %22, align 8, !tbaa !10
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %66

65:                                               ; preds = %58
  store i32 -1011, ptr %20, align 4, !tbaa !5
  br label %82

66:                                               ; preds = %58
  %67 = load i32, ptr %14, align 4, !tbaa !5
  %68 = load i32, ptr %16, align 4, !tbaa !5
  %69 = load i32, ptr %17, align 4, !tbaa !5
  %70 = load ptr, ptr %18, align 8, !tbaa !10
  %71 = load i32, ptr %19, align 4, !tbaa !5
  %72 = load ptr, ptr %22, align 8, !tbaa !10
  %73 = load i32, ptr %21, align 4, !tbaa !5
  call void @LAPACKE_zge_trans(i32 noundef %67, i32 noundef %68, i32 noundef %69, ptr noundef %70, i32 noundef %71, ptr noundef %72, i32 noundef %73)
  %74 = load ptr, ptr %22, align 8, !tbaa !10
  call void @zlaset_(ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %12, ptr noundef %13, ptr noundef %74, ptr noundef %21, i64 noundef 1)
  store i32 0, ptr %20, align 4, !tbaa !5
  %75 = load i32, ptr %16, align 4, !tbaa !5
  %76 = load i32, ptr %17, align 4, !tbaa !5
  %77 = load ptr, ptr %22, align 8, !tbaa !10
  %78 = load i32, ptr %21, align 4, !tbaa !5
  %79 = load ptr, ptr %18, align 8, !tbaa !10
  %80 = load i32, ptr %19, align 4, !tbaa !5
  call void @LAPACKE_zge_trans(i32 noundef 102, i32 noundef %75, i32 noundef %76, ptr noundef %77, i32 noundef %78, ptr noundef %79, i32 noundef %80)
  %81 = load ptr, ptr %22, align 8, !tbaa !10
  call void @free(ptr noundef %81) #5
  br label %82

82:                                               ; preds = %66, %65
  %83 = load i32, ptr %20, align 4, !tbaa !5
  %84 = icmp eq i32 %83, -1011
  br i1 %84, label %85, label %87

85:                                               ; preds = %82
  %86 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %86)
  br label %87

87:                                               ; preds = %85, %82
  store i32 0, ptr %23, align 4
  br label %88

88:                                               ; preds = %87, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  %89 = load i32, ptr %23, align 4
  switch i32 %89, label %96 [
    i32 0, label %90
  ]

90:                                               ; preds = %88
  br label %93

91:                                               ; preds = %32
  store i32 -1, ptr %20, align 4, !tbaa !5
  %92 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %92)
  br label %93

93:                                               ; preds = %91, %90
  br label %94

94:                                               ; preds = %93, %30
  %95 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %95, ptr %11, align 4
  store i32 1, ptr %23, align 4
  br label %96

96:                                               ; preds = %94, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  %97 = load i32, ptr %11, align 4
  ret i32 %97
}

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

declare void @zlaset_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #2

declare void @LAPACKE_xerbla(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare void @LAPACKE_zge_trans(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; 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 allocsize(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 #4 = { nounwind "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !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 [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @LAPACKE_zlaset_work(i32 noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, ptr noundef %8, i32 noundef %9) local_unnamed_addr #0 {
  %11 = alloca { double, double }, align 8
  %12 = alloca { double, double }, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store double %4, ptr %11, align 8
  %18 = getelementptr inbounds i8, ptr %11, i64 8
  store double %5, ptr %18, align 8
  store double %6, ptr %12, align 8
  %19 = getelementptr inbounds i8, ptr %12, i64 8
  store double %7, ptr %19, align 8
  store i8 %1, ptr %13, align 1, !tbaa !5
  store i32 %2, ptr %14, align 4, !tbaa !8
  store i32 %3, ptr %15, align 4, !tbaa !8
  store i32 %9, ptr %16, align 4, !tbaa !8
  switch i32 %0, label %38 [
    i32 102, label %20
    i32 101, label %21
  ]

20:                                               ; preds = %10
  call void @zlaset_(ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef %8, ptr noundef nonnull %16, i64 noundef 1) #6
  br label %39

21:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %17) #6
  %22 = tail call i32 @llvm.smax.i32(i32 %2, i32 1)
  store i32 %22, ptr %17, align 4, !tbaa !8
  %.not = icmp slt i32 %9, %3
  br i1 %.not, label %23, label %24

23:                                               ; preds = %21
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -8) #6
  br label %37

24:                                               ; preds = %21
  %25 = zext nneg i32 %22 to i64
  %26 = shl nuw nsw i64 %25, 4
  %27 = tail call i32 @llvm.smax.i32(i32 %3, i32 1)
  %28 = zext nneg i32 %27 to i64
  %29 = mul i64 %26, %28
  %30 = tail call noalias ptr @malloc(i64 noundef %29) #7
  %31 = icmp eq ptr %30, null
  br i1 %31, label %36, label %32

32:                                               ; preds = %24
  tail call void @LAPACKE_zge_trans(i32 noundef 101, i32 noundef %2, i32 noundef %3, ptr noundef %8, i32 noundef %9, ptr noundef nonnull %30, i32 noundef %22) #6
  call void @zlaset_(ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef nonnull %30, ptr noundef nonnull %17, i64 noundef 1) #6
  %33 = load i32, ptr %14, align 4, !tbaa !8
  %34 = load i32, ptr %15, align 4, !tbaa !8
  %35 = load i32, ptr %17, align 4, !tbaa !8
  call void @LAPACKE_zge_trans(i32 noundef 102, i32 noundef %33, i32 noundef %34, ptr noundef nonnull %30, i32 noundef %35, ptr noundef %8, i32 noundef %9) #6
  call void @free(ptr noundef nonnull %30) #6
  br label %37

36:                                               ; preds = %24
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1011) #6
  br label %37

37:                                               ; preds = %32, %36, %23
  %spec.select = phi i32 [ -8, %23 ], [ -1011, %36 ], [ 0, %32 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %17) #6
  br label %39

38:                                               ; preds = %10
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1) #6
  br label %39

39:                                               ; preds = %37, %20, %38
  %.120 = phi i32 [ 0, %20 ], [ -1, %38 ], [ %spec.select, %37 ]
  ret i32 %.120
}

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

declare void @zlaset_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @LAPACKE_xerbla(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

declare void @LAPACKE_zge_trans(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; 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.smax.i32(i32, i32) #5

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


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