; LLVM IR from ox-vgg/vise :: src/search_engine/relja_retrival/external/KMCode_relja/matrix (vector)

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

%class.Matrix = type { ptr, ptr, i32, i32 }
%class.Vector = type { %class.Matrix, ptr }

@.str = external hidden unnamed_addr constant [62 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1

; 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

declare void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Vector6createEiid(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #4 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %4
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef @.str)
  br label %14

14:                                               ; preds = %13, %4
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp sle i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef @.str.1)
  br label %18

18:                                               ; preds = %17, %14
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = getelementptr inbounds %class.Matrix, ptr %10, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = icmp ne i32 %19, %21
  br i1 %22, label %23, label %44

23:                                               ; preds = %18
  %24 = load ptr, ptr %10, align 8, !tbaa !15
  %25 = getelementptr inbounds ptr, ptr %24, i64 4
  %26 = load ptr, ptr %25, align 8
  call void %26(ptr noundef nonnull align 8 dereferenceable(32) %10)
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = getelementptr inbounds %class.Matrix, ptr %10, i32 0, i32 2
  store i32 %27, ptr %28, align 8, !tbaa !13
  %29 = getelementptr inbounds %class.Matrix, ptr %10, i32 0, i32 3
  store i32 1, ptr %29, align 4, !tbaa !17
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %31, i64 8)
  %33 = extractvalue { i64, i1 } %32, 1
  %34 = extractvalue { i64, i1 } %32, 0
  %35 = select i1 %33, i64 -1, i64 %34
  %36 = call noalias noundef nonnull ptr @_Znam(i64 noundef %35) #6
  %37 = getelementptr inbounds double, ptr %36, i64 -1
  %38 = getelementptr inbounds %class.Vector, ptr %10, i32 0, i32 1
  store ptr %37, ptr %38, align 8, !tbaa !18
  %39 = getelementptr inbounds %class.Vector, ptr %10, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %23
  call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef @.str.2)
  br label %43

43:                                               ; preds = %42, %23
  br label %44

44:                                               ; preds = %43, %18
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %56, %44
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = icmp sle i32 %46, %47
  br i1 %48, label %49, label %59

49:                                               ; preds = %45
  %50 = load double, ptr %8, align 8, !tbaa !11
  %51 = getelementptr inbounds %class.Vector, ptr %10, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %52, i64 %54
  store double %50, ptr %55, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %49
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !9
  br label %45, !llvm.loop !20

59:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin 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 = { mustprogress 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 #5 = { nounwind }
attributes #6 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTS6Matrix", !6, i64 8, !10, i64 16, !10, i64 20}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!14, !10, i64 20}
!18 = !{!19, !6, i64 24}
!19 = !{!"_ZTS6Vector", !14, i64 0, !6, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@.str = external hidden unnamed_addr constant [62 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1

declare void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Vector6createEiid(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #2 align 2 {
  %.not = icmp eq i32 %2, 1
  br i1 %.not, label %6, label %5

5:                                                ; preds = %4
  tail call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull @.str)
  br label %6

6:                                                ; preds = %5, %4
  %7 = icmp slt i32 %1, 1
  br i1 %7, label %8, label %9

8:                                                ; preds = %6
  tail call void @_ZNK6Matrix5errorEPc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull @.str.1)
  br label %9

9:                                                ; preds = %8, %6
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %.not11 = icmp eq i32 %11, %1
  br i1 %.not11, label %24, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr %0, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %13, i64 32
  %15 = load ptr, ptr %14, align 8
  tail call void %15(ptr noundef nonnull align 8 dereferenceable(32) %0)
  store i32 %1, ptr %10, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 1, ptr %16, align 4, !tbaa !13
  %17 = zext nneg i32 %1 to i64
  %18 = icmp slt i32 %1, 0
  %19 = shl nuw nsw i64 %17, 3
  %20 = select i1 %18, i64 -1, i64 %19
  %21 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #3
  %22 = getelementptr inbounds i8, ptr %21, i64 -8
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %22, ptr %23, align 8, !tbaa !14
  br label %24

24:                                               ; preds = %12, %9
  br i1 %7, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %24
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = add nuw i32 %1, 1
  %wide.trip.count = zext i32 %27 to i64
  %28 = zext nneg i32 %1 to i64
  %min.iters.check = icmp ult i32 %1, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %28, 2147483644
  %ind.end = or disjoint i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <2 x double> poison, double %3, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %29 = getelementptr inbounds double, ptr %26, i64 %offset.idx
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <2 x double> %broadcast.splat, ptr %29, align 8, !tbaa !16
  store <2 x double> %broadcast.splat, ptr %30, align 8, !tbaa !16
  %index.next = add nuw i64 %index, 4
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %28
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %32 = getelementptr inbounds double, ptr %26, i64 %indvars.iv
  store double %3, ptr %32, align 8, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %24
  ret void
}

attributes #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 = { nobuiltin 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 #2 = { mustprogress 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 #3 = { builtin 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, !10, i64 16}
!6 = !{!"_ZTS6Matrix", !7, i64 8, !10, i64 16, !10, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !9, i64 0}
!13 = !{!6, !10, i64 20}
!14 = !{!15, !7, i64 24}
!15 = !{!"_ZTS6Vector", !6, i64 0, !7, i64 24}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !19, !20, !21}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.isvectorized", i32 1}
!21 = !{!"llvm.loop.unroll.runtime.disable"}
!22 = distinct !{!22, !19, !21, !20}


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