; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/src (test_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._VlRand = type { [624 x i32], i32 }

; 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 %struct._VlRand, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca double, 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 2500, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 100000, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 256, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 400, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 10, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 100, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 1, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 1, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 1, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %21 = load i32, ptr %18, align 4, !tbaa !5
  %22 = call ptr @vl_kmeans_new(i32 noundef 2, i32 noundef %21)
  store ptr %22, ptr %19, align 8, !tbaa !9
  call void @vl_rand_init(ptr noundef %6)
  call void @vl_rand_seed(ptr noundef %6, i32 noundef 1000)
  %23 = load i64, ptr %8, align 8, !tbaa !11
  %24 = mul i64 8, %23
  %25 = load i64, ptr %7, align 8, !tbaa !11
  %26 = mul i64 %24, %25
  %27 = call ptr @vl_malloc(i64 noundef %26)
  store ptr %27, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %28

28:                                               ; preds = %52, %2
  %29 = load i64, ptr %15, align 8, !tbaa !11
  %30 = load i64, ptr %7, align 8, !tbaa !11
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %32, label %55

32:                                               ; preds = %28
  store i64 0, ptr %16, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %48, %32
  %34 = load i64, ptr %16, align 8, !tbaa !11
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %37, label %51

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %38 = call double @vl_rand_real3(ptr noundef %6)
  %39 = fadd double %38, 1.000000e+00
  store double %39, ptr %20, align 8, !tbaa !13
  %40 = load double, ptr %20, align 8, !tbaa !13
  %41 = load ptr, ptr %14, align 8, !tbaa !9
  %42 = load i64, ptr %15, align 8, !tbaa !11
  %43 = load i64, ptr %8, align 8, !tbaa !11
  %44 = mul i64 %42, %43
  %45 = load i64, ptr %16, align 8, !tbaa !11
  %46 = add i64 %44, %45
  %47 = getelementptr inbounds double, ptr %41, i64 %46
  store double %40, ptr %47, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %48

48:                                               ; preds = %37
  %49 = load i64, ptr %16, align 8, !tbaa !11
  %50 = add i64 %49, 1
  store i64 %50, ptr %16, align 8, !tbaa !11
  br label %33, !llvm.loop !15

51:                                               ; preds = %33
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %15, align 8, !tbaa !11
  %54 = add i64 %53, 1
  store i64 %54, ptr %15, align 8, !tbaa !11
  br label %28, !llvm.loop !17

55:                                               ; preds = %28
  %56 = load ptr, ptr %19, align 8, !tbaa !9
  call void @vl_kmeans_set_verbosity(ptr noundef %56, i32 noundef 1)
  %57 = load ptr, ptr %19, align 8, !tbaa !9
  %58 = load i64, ptr %10, align 8, !tbaa !11
  call void @vl_kmeans_set_max_num_iterations(ptr noundef %57, i64 noundef %58)
  %59 = load ptr, ptr %19, align 8, !tbaa !9
  %60 = load i64, ptr %11, align 8, !tbaa !11
  call void @vl_kmeans_set_max_num_comparisons(ptr noundef %59, i64 noundef %60)
  %61 = load ptr, ptr %19, align 8, !tbaa !9
  %62 = load i64, ptr %12, align 8, !tbaa !11
  call void @vl_kmeans_set_num_repetitions(ptr noundef %61, i64 noundef %62)
  %63 = load ptr, ptr %19, align 8, !tbaa !9
  %64 = load i64, ptr %13, align 8, !tbaa !11
  call void @vl_kmeans_set_num_trees(ptr noundef %63, i64 noundef %64)
  %65 = load ptr, ptr %19, align 8, !tbaa !9
  %66 = load i32, ptr %17, align 4, !tbaa !5
  call void @vl_kmeans_set_algorithm(ptr noundef %65, i32 noundef %66)
  %67 = load ptr, ptr %19, align 8, !tbaa !9
  %68 = load ptr, ptr %14, align 8, !tbaa !9
  %69 = load i64, ptr %8, align 8, !tbaa !11
  %70 = load i64, ptr %7, align 8, !tbaa !11
  %71 = load i64, ptr %9, align 8, !tbaa !11
  %72 = call double @vl_kmeans_cluster(ptr noundef %67, ptr noundef %68, i64 noundef %69, i64 noundef %70, i64 noundef %71)
  %73 = load ptr, ptr %19, align 8, !tbaa !9
  call void @vl_kmeans_delete(ptr noundef %73)
  %74 = load ptr, ptr %14, align 8, !tbaa !9
  call void @vl_free(ptr noundef %74)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #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 2500, ptr %6) #4
  ret i32 0
}

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

declare ptr @vl_kmeans_new(i32 noundef, i32 noundef) #2

declare void @vl_rand_init(ptr noundef) #2

declare void @vl_rand_seed(ptr noundef, i32 noundef) #2

declare ptr @vl_malloc(i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @vl_rand_real3(ptr noundef) #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_verbosity(ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_max_num_iterations(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_max_num_comparisons(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_num_repetitions(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_num_trees(ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_algorithm(ptr noundef, i32 noundef) #3

declare double @vl_kmeans_cluster(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) #2

declare void @vl_kmeans_delete(ptr noundef) #2

declare void @vl_free(ptr noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long 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._VlRand = type { [624 x i32], i32 }

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct._VlRand, align 4
  call void @llvm.lifetime.start.p0(i64 2500, ptr nonnull %3) #4
  %4 = tail call ptr @vl_kmeans_new(i32 noundef 2, i32 noundef 1) #4
  call void @vl_rand_init(ptr noundef nonnull %3) #4
  call void @vl_rand_seed(ptr noundef nonnull %3, i32 noundef 1000) #4
  %5 = call ptr @vl_malloc(i64 noundef 204800000) #4
  br label %.preheader

.preheader:                                       ; preds = %2, %10
  %.033 = phi i64 [ 0, %2 ], [ %11, %10 ]
  %.idx = shl nsw i64 %.033, 11
  %invariant.gep = getelementptr inbounds i8, ptr %5, i64 %.idx
  br label %6

6:                                                ; preds = %.preheader, %6
  %.03132 = phi i64 [ 0, %.preheader ], [ %9, %6 ]
  %7 = call double @vl_rand_real3(ptr noundef nonnull %3)
  %8 = fadd double %7, 1.000000e+00
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %.03132
  store double %8, ptr %gep, align 8, !tbaa !5
  %9 = add nuw nsw i64 %.03132, 1
  %exitcond.not = icmp eq i64 %9, 256
  br i1 %exitcond.not, label %10, label %6, !llvm.loop !9

10:                                               ; preds = %6
  %11 = add nuw nsw i64 %.033, 1
  %exitcond34.not = icmp eq i64 %11, 100000
  br i1 %exitcond34.not, label %12, label %.preheader, !llvm.loop !11

12:                                               ; preds = %10
  call void @vl_kmeans_set_verbosity(ptr noundef %4, i32 noundef 1)
  call void @vl_kmeans_set_max_num_iterations(ptr noundef %4, i64 noundef 10)
  call void @vl_kmeans_set_max_num_comparisons(ptr noundef %4, i64 noundef 100)
  call void @vl_kmeans_set_num_repetitions(ptr noundef %4, i64 noundef 1)
  call void @vl_kmeans_set_num_trees(ptr noundef %4, i64 noundef 1)
  call void @vl_kmeans_set_algorithm(ptr noundef %4, i32 noundef 0)
  %13 = call double @vl_kmeans_cluster(ptr noundef %4, ptr noundef nonnull %5, i64 noundef 256, i64 noundef 100000, i64 noundef 400) #4
  call void @vl_kmeans_delete(ptr noundef %4) #4
  call void @vl_free(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 2500, ptr nonnull %3) #4
  ret i32 0
}

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

declare ptr @vl_kmeans_new(i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @vl_rand_init(ptr noundef) local_unnamed_addr #2

declare void @vl_rand_seed(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @vl_malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @vl_rand_real3(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_verbosity(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_max_num_iterations(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_max_num_comparisons(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_num_repetitions(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_num_trees(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @vl_kmeans_set_algorithm(ptr noundef, i32 noundef) local_unnamed_addr #3

declare double @vl_kmeans_cluster(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare void @vl_kmeans_delete(ptr noundef) local_unnamed_addr #2

declare void @vl_free(ptr noundef) local_unnamed_addr #2

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


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