; LLVM IR from VT-ICAM/cfem :: cfem (cf_local_load)

; 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.cf_ref_arrays_s = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double }
%struct.cf_local_element_s = type { [3 x double], [3 x double], [4 x double], [2 x double], double, double, ptr }

@__c_N = external dso_local global i8, align 1
@__c_T = external dso_local global i8, align 1
@__d_zero = external dso_local global double, align 8
@__d_one = external dso_local global double, align 8

; 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
declare dso_local void @cf_affine_transformation(ptr noundef, ptr noundef, ptr noundef nonnull align 8, ptr noundef nonnull align 8) #1

; Function Attrs: nounwind uwtable
declare dso_local void @cf_supg_test_function_value(ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

declare void @dgemm_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @cf_local_load(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, double noundef %4, ptr noundef nonnull align 8 %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  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 double %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.cf_ref_arrays_s, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = zext i32 %26 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.cf_ref_arrays_s, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !11
  store i32 %30, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.cf_ref_arrays_s, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !15
  store i32 %33, ptr %16, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %34 = load i32, ptr %15, align 4, !tbaa !14
  %35 = load i32, ptr %16, align 4, !tbaa !14
  %36 = mul nsw i32 %34, %35
  store i32 %36, ptr %17, align 4, !tbaa !14
  %37 = load i32, ptr %15, align 4, !tbaa !14
  %38 = zext i32 %37 to i64
  %39 = call ptr @llvm.stacksave.p0()
  store ptr %39, ptr %18, align 8
  %40 = alloca double, i64 %38, align 16
  store i64 %38, ptr %19, align 8
  %41 = load i32, ptr %15, align 4, !tbaa !14
  %42 = load i32, ptr %16, align 4, !tbaa !14
  %43 = mul nsw i32 %41, %42
  %44 = zext i32 %43 to i64
  %45 = alloca double, i64 %44, align 16
  store i64 %44, ptr %20, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 0, ptr %21, align 4, !tbaa !14
  %46 = load i32, ptr %15, align 4, !tbaa !14
  %47 = zext i32 %46 to i64
  %48 = alloca double, i64 %47, align 16
  store i64 %47, ptr %22, align 8
  %49 = load i32, ptr %15, align 4, !tbaa !14
  %50 = zext i32 %49 to i64
  %51 = alloca double, i64 %50, align 16
  store i64 %50, ptr %23, align 8
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  call void @cf_affine_transformation(ptr noundef %52, ptr noundef %53, ptr noundef %48, ptr noundef %51)
  store i32 0, ptr %13, align 4, !tbaa !14
  br label %54

54:                                               ; preds = %85, %6
  %55 = load i32, ptr %13, align 4, !tbaa !14
  %56 = load i32, ptr %15, align 4, !tbaa !14
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %58, label %88

58:                                               ; preds = %54
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.cf_local_element_s, ptr %59, i32 0, i32 4
  %61 = load double, ptr %60, align 8, !tbaa !16
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.cf_ref_arrays_s, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !18
  %65 = load i32, ptr %13, align 4, !tbaa !14
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds double, ptr %64, i64 %66
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = fmul double %61, %68
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load double, ptr %11, align 8, !tbaa !9
  %72 = load i32, ptr %13, align 4, !tbaa !14
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %48, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = load i32, ptr %13, align 4, !tbaa !14
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds double, ptr %51, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = call double %70(double noundef %71, double noundef %75, double noundef %79)
  %81 = fmul double %69, %80
  %82 = load i32, ptr %13, align 4, !tbaa !14
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds double, ptr %40, i64 %83
  store double %81, ptr %84, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %58
  %86 = load i32, ptr %13, align 4, !tbaa !14
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %13, align 4, !tbaa !14
  br label %54, !llvm.loop !19

88:                                               ; preds = %54
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = icmp eq ptr %89, null
  br i1 %90, label %96, label %91

91:                                               ; preds = %88
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.cf_local_element_s, ptr %92, i32 0, i32 5
  %94 = load double, ptr %93, align 8, !tbaa !21
  %95 = fcmp oeq double %94, 0.000000e+00
  br i1 %95, label %96, label %103

96:                                               ; preds = %91, %88
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.cf_ref_arrays_s, ptr %97, i32 0, i32 5
  %99 = load ptr, ptr %98, align 8, !tbaa !22
  %100 = load i32, ptr %17, align 4, !tbaa !14
  %101 = sext i32 %100 to i64
  %102 = mul i64 8, %101
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %45, ptr align 8 %99, i64 %102, i1 false)
  br label %107

103:                                              ; preds = %91
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cf_supg_test_function_value(ptr noundef %104, ptr noundef %105, ptr noundef %106, ptr noundef %45)
  br label %107

107:                                              ; preds = %103, %96
  %108 = load ptr, ptr %12, align 8, !tbaa !5
  call void @dgemm_(ptr noundef @__c_T, ptr noundef @__c_N, ptr noundef %14, ptr noundef %16, ptr noundef %15, ptr noundef @__d_one, ptr noundef %40, ptr noundef %15, ptr noundef %45, ptr noundef %15, ptr noundef @__d_zero, ptr noundef %108, ptr noundef %14)
  %109 = load i32, ptr %21, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  %110 = load ptr, ptr %18, align 8
  call void @llvm.stackrestore.p0(ptr %110)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  ret i32 %109
}

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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 }

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !10, i64 80}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 4}
!16 = !{!17, !10, i64 96}
!17 = !{!"", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 80, !10, i64 96, !10, i64 104, !6, i64 112}
!18 = !{!12, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !10, i64 104}
!22 = !{!12, !6, i64 32}


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

@__c_N = external dso_local global i8, align 1
@__c_T = external dso_local global i8, align 1
@__d_zero = external dso_local global double, align 8
@__d_one = external dso_local global double, align 8

; 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
declare dso_local void @cf_affine_transformation(ptr noundef, ptr noundef, ptr noundef nonnull align 8, ptr noundef nonnull align 8) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @cf_supg_test_function_value(ptr noundef, ptr noundef, ptr noundef, ptr noundef nonnull align 8) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

declare void @dgemm_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cf_local_load(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3, double noundef %4, ptr noundef nonnull align 8 %5) local_unnamed_addr #1 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %10 = load i32, ptr %0, align 8, !tbaa !9
  store i32 %10, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #5
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !13
  store i32 %12, ptr %9, align 4, !tbaa !5
  %13 = mul nsw i32 %12, %10
  %14 = zext i32 %10 to i64
  %15 = tail call ptr @llvm.stacksave.p0()
  %16 = alloca double, i64 %14, align 16
  %17 = zext i32 %13 to i64
  %18 = alloca double, i64 %17, align 16
  %19 = alloca double, i64 %14, align 16
  %20 = alloca double, i64 %14, align 16
  call void @cf_affine_transformation(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %19, ptr noundef %20)
  %21 = icmp sgt i32 %10, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %22 = getelementptr inbounds i8, ptr %1, i64 96
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = zext nneg i32 %10 to i64
  br label %25

25:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %26 = load double, ptr %22, align 8, !tbaa !14
  %27 = load ptr, ptr %23, align 8, !tbaa !16
  %28 = getelementptr inbounds double, ptr %27, i64 %indvars.iv
  %29 = load double, ptr %28, align 8, !tbaa !17
  %30 = fmul double %26, %29
  %31 = getelementptr inbounds double, ptr %19, i64 %indvars.iv
  %32 = load double, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds double, ptr %20, i64 %indvars.iv
  %34 = load double, ptr %33, align 8, !tbaa !17
  %35 = call double %3(double noundef %4, double noundef %32, double noundef %34) #5
  %36 = fmul double %30, %35
  %37 = getelementptr inbounds double, ptr %16, i64 %indvars.iv
  store double %36, ptr %37, align 8, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = icmp ult i64 %indvars.iv.next, %24
  br i1 %38, label %25, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %25, %6
  %39 = icmp eq ptr %2, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %._crit_edge
  %41 = getelementptr inbounds i8, ptr %1, i64 104
  %42 = load double, ptr %41, align 8, !tbaa !20
  %43 = fcmp oeq double %42, 0.000000e+00
  br i1 %43, label %44, label %49

44:                                               ; preds = %40, %._crit_edge
  %45 = getelementptr inbounds i8, ptr %0, i64 32
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  %47 = sext i32 %13 to i64
  %48 = shl nsw i64 %47, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %18, ptr align 8 %46, i64 %48, i1 false)
  br label %50

49:                                               ; preds = %40
  call void @cf_supg_test_function_value(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %18)
  br label %50

50:                                               ; preds = %49, %44
  call void @dgemm_(ptr noundef nonnull @__c_T, ptr noundef nonnull @__c_N, ptr noundef nonnull %7, ptr noundef nonnull %9, ptr noundef nonnull %8, ptr noundef nonnull @__d_one, ptr noundef nonnull %16, ptr noundef nonnull %8, ptr noundef nonnull %18, ptr noundef nonnull %8, ptr noundef nonnull @__d_zero, ptr noundef nonnull %5, ptr noundef nonnull %7) #5
  call void @llvm.stackrestore.p0(ptr %15)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  ret i32 0
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !12, i64 80}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !6, i64 4}
!14 = !{!15, !12, i64 96}
!15 = !{!"", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 80, !12, i64 96, !12, i64 104, !11, i64 112}
!16 = !{!10, !11, i64 24}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!15, !12, i64 104}
!21 = !{!10, !11, i64 32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass