; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (kmeans)

; 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._VlKMeans = type { i32, i64, i64, i64, i64, i32, i32, i32, i64, double, i64, i32, ptr, ptr, double, ptr, ptr }

; 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 ptr @vl_kmeans_new_copy(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %6 = call ptr @vl_malloc(i64 noundef 128)
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._VlKMeans, ptr %7, i32 0, i32 6
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._VlKMeans, ptr %10, i32 0, i32 6
  store i32 %9, ptr %11, align 4, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._VlKMeans, ptr %12, i32 0, i32 7
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._VlKMeans, ptr %15, i32 0, i32 7
  store i32 %14, ptr %16, align 8, !tbaa !14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._VlKMeans, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._VlKMeans, ptr %20, i32 0, i32 0
  store i32 %19, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._VlKMeans, ptr %22, i32 0, i32 11
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._VlKMeans, ptr %25, i32 0, i32 11
  store i32 %24, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._VlKMeans, ptr %27, i32 0, i32 8
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._VlKMeans, ptr %30, i32 0, i32 8
  store i64 %29, ptr %31, align 8, !tbaa !17
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._VlKMeans, ptr %32, i32 0, i32 10
  %34 = load i64, ptr %33, align 8, !tbaa !18
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._VlKMeans, ptr %35, i32 0, i32 10
  store i64 %34, ptr %36, align 8, !tbaa !18
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._VlKMeans, ptr %37, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !19
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._VlKMeans, ptr %40, i32 0, i32 1
  store i64 %39, ptr %41, align 8, !tbaa !19
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._VlKMeans, ptr %42, i32 0, i32 2
  %44 = load i64, ptr %43, align 8, !tbaa !20
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._VlKMeans, ptr %45, i32 0, i32 2
  store i64 %44, ptr %46, align 8, !tbaa !20
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._VlKMeans, ptr %47, i32 0, i32 12
  store ptr null, ptr %48, align 8, !tbaa !21
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._VlKMeans, ptr %49, i32 0, i32 13
  store ptr null, ptr %50, align 8, !tbaa !22
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._VlKMeans, ptr %51, i32 0, i32 3
  %53 = load i64, ptr %52, align 8, !tbaa !23
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._VlKMeans, ptr %54, i32 0, i32 3
  store i64 %53, ptr %55, align 8, !tbaa !23
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._VlKMeans, ptr %56, i32 0, i32 4
  %58 = load i64, ptr %57, align 8, !tbaa !24
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._VlKMeans, ptr %59, i32 0, i32 4
  store i64 %58, ptr %60, align 8, !tbaa !24
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._VlKMeans, ptr %61, i32 0, i32 12
  %63 = load ptr, ptr %62, align 8, !tbaa !21
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %89

65:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._VlKMeans, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !15
  %69 = call i64 @vl_get_type_size(i32 noundef %68)
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._VlKMeans, ptr %70, i32 0, i32 1
  %72 = load i64, ptr %71, align 8, !tbaa !19
  %73 = mul i64 %69, %72
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._VlKMeans, ptr %74, i32 0, i32 2
  %76 = load i64, ptr %75, align 8, !tbaa !20
  %77 = mul i64 %73, %76
  store i64 %77, ptr %4, align 8, !tbaa !25
  %78 = load i64, ptr %4, align 8, !tbaa !25
  %79 = call ptr @vl_malloc(i64 noundef %78)
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._VlKMeans, ptr %80, i32 0, i32 12
  store ptr %79, ptr %81, align 8, !tbaa !21
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._VlKMeans, ptr %82, i32 0, i32 12
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._VlKMeans, ptr %85, i32 0, i32 12
  %87 = load ptr, ptr %86, align 8, !tbaa !21
  %88 = load i64, ptr %4, align 8, !tbaa !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 1 %87, i64 %88, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %89

89:                                               ; preds = %65, %1
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._VlKMeans, ptr %90, i32 0, i32 13
  %92 = load ptr, ptr %91, align 8, !tbaa !22
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %118

94:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct._VlKMeans, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 8, !tbaa !15
  %98 = call i64 @vl_get_type_size(i32 noundef %97)
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._VlKMeans, ptr %99, i32 0, i32 2
  %101 = load i64, ptr %100, align 8, !tbaa !20
  %102 = mul i64 %98, %101
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._VlKMeans, ptr %103, i32 0, i32 2
  %105 = load i64, ptr %104, align 8, !tbaa !20
  %106 = mul i64 %102, %105
  store i64 %106, ptr %5, align 8, !tbaa !25
  %107 = load i64, ptr %5, align 8, !tbaa !25
  %108 = call ptr @vl_malloc(i64 noundef %107)
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._VlKMeans, ptr %109, i32 0, i32 13
  store ptr %108, ptr %110, align 8, !tbaa !22
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._VlKMeans, ptr %111, i32 0, i32 13
  %113 = load ptr, ptr %112, align 8, !tbaa !22
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct._VlKMeans, ptr %114, i32 0, i32 13
  %116 = load ptr, ptr %115, align 8, !tbaa !22
  %117 = load i64, ptr %5, align 8, !tbaa !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %113, ptr align 1 %116, i64 %117, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %118

118:                                              ; preds = %94, %89
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %119
}

declare ptr @vl_malloc(i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @vl_get_type_size(i32 noundef) #3

; 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) #4

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 = { inlinehint 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 44}
!10 = !{!"_VlKMeans", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !12, i64 56, !13, i64 64, !12, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !13, i64 104, !6, i64 112, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!10, !11, i64 48}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 80}
!17 = !{!10, !12, i64 56}
!18 = !{!10, !12, i64 72}
!19 = !{!10, !12, i64 8}
!20 = !{!10, !12, i64 16}
!21 = !{!10, !6, i64 88}
!22 = !{!10, !6, i64 96}
!23 = !{!10, !12, i64 24}
!24 = !{!10, !12, i64 32}
!25 = !{!12, !12, 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"

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @vl_kmeans_new_copy(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call ptr @vl_malloc(i64 noundef 128) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 44
  %4 = getelementptr inbounds i8, ptr %2, i64 44
  %5 = load <2 x i32>, ptr %3, align 4, !tbaa !5
  store <2 x i32> %5, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr %0, align 8, !tbaa !9
  store i32 %6, ptr %2, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %2, i64 80
  store i32 %8, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %2, i64 56
  store i64 %11, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %14 = load i64, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %2, i64 72
  store i64 %14, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = getelementptr inbounds i8, ptr %2, i64 8
  %18 = getelementptr inbounds i8, ptr %2, i64 16
  %19 = load <2 x i64>, ptr %16, align 8, !tbaa !17
  store <2 x i64> %19, ptr %17, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %2, i64 88
  %21 = getelementptr inbounds i8, ptr %2, i64 96
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %20, i8 0, i64 16, i1 false)
  %23 = getelementptr inbounds i8, ptr %2, i64 24
  %24 = load <2 x i64>, ptr %22, align 8, !tbaa !17
  store <2 x i64> %24, ptr %23, align 8, !tbaa !17
  %25 = getelementptr inbounds i8, ptr %0, i64 88
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %35, label %27

27:                                               ; preds = %1
  %28 = tail call i64 @vl_get_type_size(i32 noundef %6)
  %29 = load i64, ptr %17, align 8, !tbaa !19
  %30 = mul i64 %29, %28
  %31 = load i64, ptr %18, align 8, !tbaa !20
  %32 = mul i64 %30, %31
  %33 = tail call ptr @vl_malloc(i64 noundef %32) #5
  store ptr %33, ptr %20, align 8, !tbaa !18
  %34 = load ptr, ptr %25, align 8, !tbaa !18
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %33, ptr align 1 %34, i64 %32, i1 false)
  br label %35

35:                                               ; preds = %27, %1
  %36 = getelementptr inbounds i8, ptr %0, i64 96
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %.not40 = icmp eq ptr %37, null
  br i1 %.not40, label %46, label %38

38:                                               ; preds = %35
  %39 = load i32, ptr %2, align 8, !tbaa !9
  %40 = tail call i64 @vl_get_type_size(i32 noundef %39)
  %41 = load i64, ptr %18, align 8, !tbaa !20
  %42 = mul i64 %41, %40
  %43 = mul i64 %42, %41
  %44 = tail call ptr @vl_malloc(i64 noundef %43) #5
  store ptr %44, ptr %21, align 8, !tbaa !21
  %45 = load ptr, ptr %36, align 8, !tbaa !21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %44, ptr align 1 %45, i64 %43, i1 false)
  br label %46

46:                                               ; preds = %38, %35
  ret ptr %2
}

declare ptr @vl_malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @vl_get_type_size(i32 noundef) local_unnamed_addr #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: 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 = { "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 = { inlinehint 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"_VlKMeans", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !11, i64 56, !12, i64 64, !11, i64 72, !6, i64 80, !13, i64 88, !13, i64 96, !12, i64 104, !13, i64 112, !13, i64 120}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!10, !6, i64 80}
!15 = !{!10, !11, i64 56}
!16 = !{!10, !11, i64 72}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !13, i64 88}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !11, i64 16}
!21 = !{!10, !13, i64 96}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass