; LLVM IR from CMU-SAFARI/prim-benchmarks :: GEMV/baselines/cpu (gemv_openmp)

; 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.Timer = type { [4 x %struct.timeval], [4 x %struct.timeval], [4 x double] }
%struct.timeval = type { i64, i64 }

@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @start(ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @stop(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @print(ptr noundef, i32 noundef, i32 noundef) #0

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @allocate_dense(i64 noundef, i64 noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, 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 %struct.Timer, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 20480, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 8192, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %14 = call noalias ptr @malloc(i64 noundef 163840) #5
  store ptr %14, ptr %9, align 8, !tbaa !9
  %15 = call noalias ptr @malloc(i64 noundef 65536) #5
  store ptr %15, ptr %10, align 8, !tbaa !9
  call void @allocate_dense(i64 noundef 20480, i64 noundef 8192, ptr noundef %8)
  call void @make_hilbert_mat(i64 noundef 20480, i64 noundef 8192, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %27, %2
  %17 = load i64, ptr %11, align 8, !tbaa !11
  %18 = icmp ult i64 %17, 8192
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %30

20:                                               ; preds = %16
  %21 = load i64, ptr %11, align 8, !tbaa !11
  %22 = uitofp i64 %21 to double
  %23 = fadd double %22, 1.000000e+00
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = load i64, ptr %11, align 8, !tbaa !11
  %26 = getelementptr inbounds double, ptr %24, i64 %25
  store double %23, ptr %26, align 8, !tbaa !13
  br label %27

27:                                               ; preds = %20
  %28 = load i64, ptr %11, align 8, !tbaa !11
  %29 = add i64 %28, 1
  store i64 %29, ptr %11, align 8, !tbaa !11
  br label %16, !llvm.loop !15

30:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %39, %30
  %32 = load i64, ptr %12, align 8, !tbaa !11
  %33 = icmp ult i64 %32, 20480
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %42

35:                                               ; preds = %31
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  %37 = load i64, ptr %12, align 8, !tbaa !11
  %38 = getelementptr inbounds double, ptr %36, i64 %37
  store double 0.000000e+00, ptr %38, align 8, !tbaa !13
  br label %39

39:                                               ; preds = %35
  %40 = load i64, ptr %12, align 8, !tbaa !11
  %41 = add i64 %40, 1
  store i64 %41, ptr %12, align 8, !tbaa !11
  br label %31, !llvm.loop !17

42:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 160, ptr %13) #4
  call void @start(ptr noundef %13, i32 noundef 0, i32 noundef 0)
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = load ptr, ptr %10, align 8, !tbaa !9
  call void @gemv(ptr noundef %43, ptr noundef %44, i64 noundef 20480, i64 noundef 8192, ptr noundef %9)
  call void @stop(ptr noundef %13, i32 noundef 0)
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @print(ptr noundef %13, i32 noundef 0, i32 noundef 1)
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  %48 = call double @sum_vec(ptr noundef %47, i64 noundef 8192)
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = call double @sum_vec(ptr noundef %49, i64 noundef 20480)
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef %48, double noundef %50)
  call void @llvm.lifetime.end.p0(i64 160, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local void @make_hilbert_mat(i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @gemv(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @sum_vec(ptr noundef, i64 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 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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.Timer = type { [4 x %struct.timeval], [4 x %struct.timeval], [4 x double] }
%struct.timeval = type { i64, i64 }

@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @start(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @stop(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @print(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @allocate_dense(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
vector.ph:
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.Timer, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %5 = tail call noalias dereferenceable_or_null(163840) ptr @malloc(i64 noundef 163840) #6
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = tail call noalias dereferenceable_or_null(65536) ptr @malloc(i64 noundef 65536) #6
  call void @allocate_dense(i64 noundef 20480, i64 noundef 8192, ptr noundef nonnull %2)
  call void @make_hilbert_mat(i64 noundef 20480, i64 noundef 8192, ptr noundef nonnull %2)
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.3, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ %vec.ind.next.3, %vector.body ]
  %7 = uitofp <2 x i64> %vec.ind to <2 x double>
  %8 = fadd <2 x double> %7, <double 1.000000e+00, double 1.000000e+00>
  %9 = getelementptr inbounds double, ptr %6, i64 %index
  store <2 x double> %8, ptr %9, align 8, !tbaa !9
  %index.next = or disjoint i64 %index, 2
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %10 = uitofp <2 x i64> %vec.ind.next to <2 x double>
  %11 = fadd <2 x double> %10, <double 1.000000e+00, double 1.000000e+00>
  %12 = getelementptr inbounds double, ptr %6, i64 %index.next
  store <2 x double> %11, ptr %12, align 8, !tbaa !9
  %index.next.1 = or disjoint i64 %index, 4
  %vec.ind.next.1 = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %13 = uitofp <2 x i64> %vec.ind.next.1 to <2 x double>
  %14 = fadd <2 x double> %13, <double 1.000000e+00, double 1.000000e+00>
  %15 = getelementptr inbounds double, ptr %6, i64 %index.next.1
  store <2 x double> %14, ptr %15, align 8, !tbaa !9
  %index.next.2 = or disjoint i64 %index, 6
  %vec.ind.next.2 = add <2 x i64> %vec.ind, <i64 6, i64 6>
  %16 = uitofp <2 x i64> %vec.ind.next.2 to <2 x double>
  %17 = fadd <2 x double> %16, <double 1.000000e+00, double 1.000000e+00>
  %18 = getelementptr inbounds double, ptr %6, i64 %index.next.2
  store <2 x double> %17, ptr %18, align 8, !tbaa !9
  %index.next.3 = add nuw nsw i64 %index, 8
  %vec.ind.next.3 = add <2 x i64> %vec.ind, <i64 8, i64 8>
  %19 = icmp eq i64 %index.next.3, 8192
  br i1 %19, label %.preheader, label %vector.body, !llvm.loop !11

.preheader:                                       ; preds = %vector.body
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(163840) %5, i8 0, i64 163840, i1 false), !tbaa !9
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %4) #5
  call void @start(ptr noundef nonnull %4, i32 noundef 0, i32 noundef 0)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  call void @gemv(ptr noundef %20, ptr noundef nonnull %6, i64 noundef 20480, i64 noundef 8192, ptr noundef nonnull %3)
  call void @stop(ptr noundef nonnull %4, i32 noundef 0)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  call void @print(ptr noundef nonnull %4, i32 noundef 0, i32 noundef 1)
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %23 = call double @sum_vec(ptr noundef nonnull %6, i64 noundef 8192)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call double @sum_vec(ptr noundef %24, i64 noundef 20480)
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %23, double noundef %25)
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local void @make_hilbert_mat(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @gemv(ptr noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @sum_vec(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { nofree 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 #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass