; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/BLAS/TESTING (cblat1)

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ctest_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca [20 x float], align 16
  %15 = alloca [20 x float], align 16
  %16 = alloca [20 x float], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  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 80, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr %16) #3
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.complex, ptr %17, i32 -1
  store ptr %18, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.complex, ptr %19, i32 -1
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.complex, ptr %21, i32 -1
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %11, align 8, !tbaa !9
  store i64 1, ptr %13, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %87, %5
  %26 = load i64, ptr %13, align 8, !tbaa !9
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = icmp sle i64 %26, %27
  br i1 %28, label %29, label %90

29:                                               ; preds = %25
  %30 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %30, ptr %12, align 8, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i64, ptr %12, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.complex, ptr %31, i64 %32
  %34 = getelementptr inbounds %struct.complex, ptr %33, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = load i64, ptr %13, align 8, !tbaa !9
  %37 = shl i64 %36, 1
  %38 = sub nsw i64 %37, 2
  %39 = getelementptr inbounds [20 x float], ptr %14, i64 0, i64 %38
  store float %35, ptr %39, align 4, !tbaa !14
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load i64, ptr %13, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.complex, ptr %40, i64 %41
  %43 = call double @r_imag(ptr noundef %42)
  %44 = fptrunc double %43 to float
  %45 = load i64, ptr %13, align 8, !tbaa !9
  %46 = shl i64 %45, 1
  %47 = sub nsw i64 %46, 1
  %48 = getelementptr inbounds [20 x float], ptr %14, i64 0, i64 %47
  store float %44, ptr %48, align 4, !tbaa !14
  %49 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %49, ptr %12, align 8, !tbaa !9
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %12, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.complex, ptr %50, i64 %51
  %53 = getelementptr inbounds %struct.complex, ptr %52, i32 0, i32 0
  %54 = load float, ptr %53, align 4, !tbaa !11
  %55 = load i64, ptr %13, align 8, !tbaa !9
  %56 = shl i64 %55, 1
  %57 = sub nsw i64 %56, 2
  %58 = getelementptr inbounds [20 x float], ptr %16, i64 0, i64 %57
  store float %54, ptr %58, align 4, !tbaa !14
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load i64, ptr %13, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.complex, ptr %59, i64 %60
  %62 = call double @r_imag(ptr noundef %61)
  %63 = fptrunc double %62 to float
  %64 = load i64, ptr %13, align 8, !tbaa !9
  %65 = shl i64 %64, 1
  %66 = sub nsw i64 %65, 1
  %67 = getelementptr inbounds [20 x float], ptr %16, i64 0, i64 %66
  store float %63, ptr %67, align 4, !tbaa !14
  %68 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %68, ptr %12, align 8, !tbaa !9
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load i64, ptr %12, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.complex, ptr %69, i64 %70
  %72 = getelementptr inbounds %struct.complex, ptr %71, i32 0, i32 0
  %73 = load float, ptr %72, align 4, !tbaa !11
  %74 = load i64, ptr %13, align 8, !tbaa !9
  %75 = shl i64 %74, 1
  %76 = sub nsw i64 %75, 2
  %77 = getelementptr inbounds [20 x float], ptr %15, i64 0, i64 %76
  store float %73, ptr %77, align 4, !tbaa !14
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = load i64, ptr %13, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.complex, ptr %78, i64 %79
  %81 = call double @r_imag(ptr noundef %80)
  %82 = fptrunc double %81 to float
  %83 = load i64, ptr %13, align 8, !tbaa !9
  %84 = shl i64 %83, 1
  %85 = sub nsw i64 %84, 1
  %86 = getelementptr inbounds [20 x float], ptr %15, i64 0, i64 %85
  store float %82, ptr %86, align 4, !tbaa !14
  br label %87

87:                                               ; preds = %29
  %88 = load i64, ptr %13, align 8, !tbaa !9
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr %13, align 8, !tbaa !9
  br label %25, !llvm.loop !15

90:                                               ; preds = %25
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load i64, ptr %91, align 8, !tbaa !9
  %93 = shl i64 %92, 1
  store i64 %93, ptr %11, align 8, !tbaa !9
  %94 = getelementptr inbounds [20 x float], ptr %14, i64 0, i64 0
  %95 = getelementptr inbounds [20 x float], ptr %16, i64 0, i64 0
  %96 = getelementptr inbounds [20 x float], ptr %15, i64 0, i64 0
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = call i32 @stest_(ptr noundef %11, ptr noundef %94, ptr noundef %95, ptr noundef %96, ptr noundef %97)
  call void @llvm.lifetime.end.p0(i64 80, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 80, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @stest_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare double @r_imag(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

%struct.complex = type { float, float }

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ctest_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca i64, align 8
  %7 = alloca [20 x float], align 16
  %8 = alloca [20 x float], align 16
  %9 = alloca [20 x float], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %9) #3
  %10 = getelementptr inbounds i8, ptr %3, i64 -8
  %11 = getelementptr inbounds i8, ptr %2, i64 -8
  %12 = getelementptr inbounds i8, ptr %1, i64 -8
  %13 = load i64, ptr %0, align 8, !tbaa !5
  %.not28 = icmp slt i64 %13, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.029 = phi i64 [ %35, %.lr.ph ], [ 1, %5 ]
  %14 = getelementptr inbounds %struct.complex, ptr %12, i64 %.029
  %15 = load float, ptr %14, align 4, !tbaa !9
  %16 = shl nuw i64 %.029, 1
  %17 = add nsw i64 %16, -2
  %18 = getelementptr inbounds [20 x float], ptr %7, i64 0, i64 %17
  store float %15, ptr %18, align 8, !tbaa !12
  %19 = tail call double @r_imag(ptr noundef nonnull %14) #3
  %20 = fptrunc double %19 to float
  %21 = add nsw i64 %16, -1
  %22 = getelementptr inbounds [20 x float], ptr %7, i64 0, i64 %21
  store float %20, ptr %22, align 4, !tbaa !12
  %23 = getelementptr inbounds %struct.complex, ptr %11, i64 %.029
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = getelementptr inbounds [20 x float], ptr %9, i64 0, i64 %17
  store float %24, ptr %25, align 8, !tbaa !12
  %26 = tail call double @r_imag(ptr noundef nonnull %23) #3
  %27 = fptrunc double %26 to float
  %28 = getelementptr inbounds [20 x float], ptr %9, i64 0, i64 %21
  store float %27, ptr %28, align 4, !tbaa !12
  %29 = getelementptr inbounds %struct.complex, ptr %10, i64 %.029
  %30 = load float, ptr %29, align 4, !tbaa !9
  %31 = getelementptr inbounds [20 x float], ptr %8, i64 0, i64 %17
  store float %30, ptr %31, align 8, !tbaa !12
  %32 = tail call double @r_imag(ptr noundef nonnull %29) #3
  %33 = fptrunc double %32 to float
  %34 = getelementptr inbounds [20 x float], ptr %8, i64 0, i64 %21
  store float %33, ptr %34, align 4, !tbaa !12
  %35 = add nuw i64 %.029, 1
  %exitcond.not = icmp eq i64 %.029, %13
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %0, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %5
  %36 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %13, %5 ]
  %37 = shl i64 %36, 1
  store i64 %37, ptr %6, align 8, !tbaa !5
  %38 = call i32 @stest_(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %9, ptr noundef nonnull %8, ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @stest_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare double @r_imag(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass