; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl/scalespace.ll (vl_scalespace_fill_octave)

; 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._VlScaleSpaceOctaveGeometry = type { i64, i64, double }
%struct._VlScaleSpace = type { %struct._VlScaleSpaceGeometry, ptr }
%struct._VlScaleSpaceGeometry = type { i64, i64, i64, i64, i64, i64, i64, double, double }

; Function Attrs: nounwind uwtable
declare dso_local void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind noalias writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8, ptr noundef, i64 noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @_vl_scalespace_fill_octave(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca %struct._VlScaleSpaceOctaveGeometry, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i64, ptr %4, align 8, !tbaa !9
  call void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %6, ptr noundef %12, i64 noundef %13)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._VlScaleSpace, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %15, i32 0, i32 5
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %5, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %73, %2
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._VlScaleSpace, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %22, i32 0, i32 6
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = icmp sle i64 %20, %24
  br i1 %25, label %26, label %76

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !9
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = call double @vl_scalespace_get_level_sigma(ptr noundef %27, i64 noundef %28, i64 noundef %29)
  store double %30, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i64, ptr %4, align 8, !tbaa !9
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = sub nsw i64 %33, 1
  %35 = call double @vl_scalespace_get_level_sigma(ptr noundef %31, i64 noundef %32, i64 noundef %34)
  store double %35, ptr %8, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %36 = load double, ptr %7, align 8, !tbaa !16
  %37 = load double, ptr %7, align 8, !tbaa !16
  %38 = load double, ptr %8, align 8, !tbaa !16
  %39 = load double, ptr %8, align 8, !tbaa !16
  %40 = fmul double %38, %39
  %41 = fneg double %40
  %42 = call double @llvm.fmuladd.f64(double %36, double %37, double %41)
  %43 = fptrunc double %42 to float
  %44 = call float @sqrtf(float noundef %43) #5
  %45 = fpext float %44 to double
  store double %45, ptr %9, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load i64, ptr %4, align 8, !tbaa !9
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = call ptr @vl_scalespace_get_level(ptr noundef %46, i64 noundef %47, i64 noundef %48)
  store ptr %49, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i64, ptr %4, align 8, !tbaa !9
  %52 = load i64, ptr %5, align 8, !tbaa !9
  %53 = sub nsw i64 %52, 1
  %54 = call ptr @vl_scalespace_get_level(ptr noundef %50, i64 noundef %51, i64 noundef %53)
  store ptr %54, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 0
  %57 = load i64, ptr %56, align 8, !tbaa !17
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 0
  %60 = load i64, ptr %59, align 8, !tbaa !17
  %61 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !19
  %63 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 0
  %64 = load i64, ptr %63, align 8, !tbaa !17
  %65 = load double, ptr %9, align 8, !tbaa !16
  %66 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 2
  %67 = load double, ptr %66, align 8, !tbaa !20
  %68 = fdiv double %65, %67
  %69 = load double, ptr %9, align 8, !tbaa !16
  %70 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %6, i32 0, i32 2
  %71 = load double, ptr %70, align 8, !tbaa !20
  %72 = fdiv double %69, %71
  call void @vl_imsmooth_f(ptr noundef %55, i64 noundef %57, ptr noundef %58, i64 noundef %60, i64 noundef %62, i64 noundef %64, double noundef %68, double noundef %72)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %73

73:                                               ; preds = %26
  %74 = load i64, ptr %5, align 8, !tbaa !9
  %75 = add nsw i64 %74, 1
  store i64 %75, ptr %5, align 8, !tbaa !9
  br label %19, !llvm.loop !21

76:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

declare void @vl_imsmooth_f(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"_VlScaleSpace", !13, i64 0, !6, i64 72}
!13 = !{!"_VlScaleSpaceGeometry", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !14, i64 64}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !10, i64 48}
!16 = !{!14, !14, i64 0}
!17 = !{!18, !10, i64 0}
!18 = !{!"_VlScaleSpaceOctaveGeometry", !10, i64 0, !10, i64 8, !14, i64 16}
!19 = !{!18, !10, i64 8}
!20 = !{!18, !14, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"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"

%struct._VlScaleSpaceOctaveGeometry = type { i64, i64, double }

; Function Attrs: nounwind uwtable
declare dso_local void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind noalias writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @_vl_scalespace_fill_octave(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct._VlScaleSpaceOctaveGeometry, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  call void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind nonnull writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %3, ptr noundef %0, i64 noundef %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not25 = icmp slt i64 %5, %7
  br i1 %.not.not25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %.0.in26 = phi i64 [ %5, %.lr.ph ], [ %.0, %10 ]
  %.0 = add nsw i64 %.0.in26, 1
  %11 = call double @vl_scalespace_get_level_sigma(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %.0)
  %12 = call double @vl_scalespace_get_level_sigma(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %.0.in26)
  %13 = fneg double %12
  %14 = fmul double %12, %13
  %15 = call double @llvm.fmuladd.f64(double %11, double %11, double %14)
  %16 = fptrunc double %15 to float
  %17 = call float @sqrtf(float noundef %16) #5
  %18 = fpext float %17 to double
  %19 = call ptr @vl_scalespace_get_level(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %.0)
  %20 = call ptr @vl_scalespace_get_level(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %.0.in26)
  %21 = load i64, ptr %3, align 8, !tbaa !14
  %22 = load i64, ptr %8, align 8, !tbaa !16
  %23 = load double, ptr %9, align 8, !tbaa !17
  %24 = fdiv double %18, %23
  call void @vl_imsmooth_f(ptr noundef %19, i64 noundef %21, ptr noundef %20, i64 noundef %21, i64 noundef %22, i64 noundef %21, double noundef %24, double noundef %24) #5
  %25 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not = icmp slt i64 %.0, %25
  br i1 %.not.not, label %10, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %10, %2
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

declare void @vl_imsmooth_f(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 speculatable willreturn memory(none) }
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, !8, i64 40}
!6 = !{!"_VlScaleSpace", !7, i64 0, !12, i64 72}
!7 = !{!"_VlScaleSpaceGeometry", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !11, i64 56, !11, i64 64}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!6, !8, i64 48}
!14 = !{!15, !8, i64 0}
!15 = !{!"_VlScaleSpaceOctaveGeometry", !8, i64 0, !8, i64 8, !11, i64 16}
!16 = !{!15, !8, i64 8}
!17 = !{!15, !11, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass