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

; 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: 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) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @vl_scalespace_new_copy(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct._VlScaleSpaceOctaveGeometry, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call ptr @vl_scalespace_new_shallow_copy(ptr noundef %9)
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %74

14:                                               ; preds = %1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._VlScaleSpace, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %18, ptr %4, align 8, !tbaa !14
  br label %19

19:                                               ; preds = %69, %14
  %20 = load i64, ptr %4, align 8, !tbaa !14
  %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 3
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = icmp sle i64 %20, %24
  br i1 %25, label %26, label %72

26:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !14
  call void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %7, ptr noundef %27, i64 noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._VlScaleSpace, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %30, i32 0, i32 6
  %32 = load i64, ptr %31, align 8, !tbaa !16
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._VlScaleSpace, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %34, i32 0, i32 5
  %36 = load i64, ptr %35, align 8, !tbaa !17
  %37 = sub nsw i64 %32, %36
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %8, align 8, !tbaa !14
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._VlScaleSpace, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = load i64, ptr %4, align 8, !tbaa !14
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._VlScaleSpace, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %44, i32 0, i32 2
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = sub nsw i64 %42, %46
  %48 = getelementptr inbounds ptr, ptr %41, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._VlScaleSpace, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load i64, ptr %4, align 8, !tbaa !14
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._VlScaleSpace, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct._VlScaleSpaceGeometry, ptr %55, i32 0, i32 2
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = sub nsw i64 %53, %57
  %59 = getelementptr inbounds ptr, ptr %52, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %7, i32 0, i32 0
  %62 = load i64, ptr %61, align 8, !tbaa !19
  %63 = getelementptr inbounds %struct._VlScaleSpaceOctaveGeometry, ptr %7, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !21
  %65 = mul i64 %62, %64
  %66 = load i64, ptr %8, align 8, !tbaa !14
  %67 = mul i64 %65, %66
  %68 = mul i64 %67, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %60, i64 %68, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  br label %69

69:                                               ; preds = %26
  %70 = load i64, ptr %4, align 8, !tbaa !14
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %4, align 8, !tbaa !14
  br label %19, !llvm.loop !22

72:                                               ; preds = %19
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %73, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %74

74:                                               ; preds = %72, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %75 = load ptr, ptr %2, align 8
  ret ptr %75
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @vl_scalespace_new_shallow_copy(ptr noundef) #1

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

; 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 #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @vl_scalespace_new_copy(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct._VlScaleSpaceOctaveGeometry, align 8
  %3 = tail call ptr @vl_scalespace_new_shallow_copy(ptr noundef %0)
  %4 = icmp eq ptr %3, null
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %.not20 = icmp sgt i64 %7, %9
  br i1 %.not20, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %3, i64 72
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  br label %15

15:                                               ; preds = %.lr.ph, %15
  %.01821 = phi i64 [ %7, %.lr.ph ], [ %33, %15 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  call void @vl_scalespace_get_octave_geometry(ptr dead_on_unwind nonnull writable sret(%struct._VlScaleSpaceOctaveGeometry) align 8 %2, ptr noundef nonnull %0, i64 noundef %.01821)
  %16 = load i64, ptr %10, align 8, !tbaa !14
  %17 = load i64, ptr %11, align 8, !tbaa !15
  %18 = add i64 %16, 1
  %19 = sub i64 %18, %17
  %20 = load ptr, ptr %12, align 8, !tbaa !16
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = sub nsw i64 %.01821, %21
  %23 = getelementptr inbounds ptr, ptr %20, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = load ptr, ptr %13, align 8, !tbaa !16
  %26 = getelementptr inbounds ptr, ptr %25, i64 %22
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = load i64, ptr %2, align 8, !tbaa !18
  %29 = load i64, ptr %14, align 8, !tbaa !20
  %30 = shl i64 %19, 2
  %31 = mul i64 %30, %28
  %32 = mul i64 %31, %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %27, i64 %32, i1 false)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  %33 = add nsw i64 %.01821, 1
  %34 = load i64, ptr %8, align 8, !tbaa !13
  %.not.not = icmp slt i64 %.01821, %34
  br i1 %.not.not, label %15, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %15, %5, %1
  ret ptr %3
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @vl_scalespace_new_shallow_copy(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 16}
!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 24}
!14 = !{!6, !8, i64 48}
!15 = !{!6, !8, i64 40}
!16 = !{!6, !12, i64 72}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !8, i64 0}
!19 = !{!"_VlScaleSpaceOctaveGeometry", !8, i64 0, !8, i64 8, !11, i64 16}
!20 = !{!19, !8, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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