; LLVM IR from bbrister/SIFT3D :: sift3d (sift)

; 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._SIFT3D = type { %struct._Mesh, %struct._GSS_filters, %struct._SIFT_cl_kernels, %struct._Pyramid, %struct._Pyramid, %struct._Image, double, double, i32 }
%struct._Mesh = type { ptr, i32 }
%struct._GSS_filters = type { %struct._Gauss_filter, ptr, i32, i32 }
%struct._Gauss_filter = type { double, %struct._Sep_FIR_filter }
%struct._Sep_FIR_filter = type { i32, ptr, i32, i32, i32 }
%struct._SIFT_cl_kernels = type { i32 }
%struct._Pyramid = type { ptr, double, double, i32, i32, i32, i32, i32 }
%struct._Image = type { ptr, i32, double, i64, i32, i32, i32, double, double, double, i64, i64, i64, i32, i32 }

; 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
declare dso_local i32 @set_peak_thresh_SIFT3D(ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_corner_thresh_SIFT3D(ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_num_kp_levels_SIFT3D(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma_n_SIFT3D(ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @set_sigma0_SIFT3D(ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @init_SIFT3D(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._SIFT3D, ptr %14, i32 0, i32 4
  store ptr %15, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._SIFT3D, ptr %16, i32 0, i32 3
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._SIFT3D, ptr %18, i32 0, i32 1
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 1.000000e-01, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 4.000000e-01, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store double 1.150000e+00, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store double 1.600000e+00, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !11
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  call void @init_Pyramid(ptr noundef %20)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  call void @init_Pyramid(ptr noundef %21)
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  call void @init_GSS_filters(ptr noundef %22)
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call i32 @init_geometry(ptr noundef %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %1
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %13, align 4
  br label %62

27:                                               ; preds = %1
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i32 @init_cl_SIFT3D(ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %13, align 4
  br label %62

32:                                               ; preds = %27
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._SIFT3D, ptr %33, i32 0, i32 5
  call void @init_im(ptr noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._Pyramid, ptr %35, i32 0, i32 6
  store i32 -1, ptr %36, align 4, !tbaa !13
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._Pyramid, ptr %37, i32 0, i32 6
  store i32 -1, ptr %38, align 4, !tbaa !13
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._SIFT3D, ptr %39, i32 0, i32 8
  store i32 0, ptr %40, align 8, !tbaa !15
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i32 @set_sigma_n_SIFT3D(ptr noundef %41, double noundef 1.150000e+00)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %60, label %44

44:                                               ; preds = %32
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = call i32 @set_sigma0_SIFT3D(ptr noundef %45, double noundef 1.600000e+00)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %60, label %48

48:                                               ; preds = %44
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call i32 @set_peak_thresh_SIFT3D(ptr noundef %49, double noundef 1.000000e-01)
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %60, label %52

52:                                               ; preds = %48
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = call i32 @set_corner_thresh_SIFT3D(ptr noundef %53, double noundef 4.000000e-01)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %60, label %56

56:                                               ; preds = %52
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call i32 @set_num_kp_levels_SIFT3D(ptr noundef %57, i32 noundef 3)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %56, %52, %48, %44, %32
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %13, align 4
  br label %62

61:                                               ; preds = %56
  store i32 0, ptr %2, align 4
  store i32 1, ptr %13, align 4
  br label %62

62:                                               ; preds = %61, %60, %31, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %63 = load i32, ptr %2, align 4
  ret i32 %63
}

declare void @init_Pyramid(ptr noundef) #2

declare void @init_GSS_filters(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @init_geometry(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @init_cl_SIFT3D(ptr noundef) #1

declare void @init_im(ptr noundef) #2

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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 36}
!14 = !{!"_Pyramid", !6, i64 0, !10, i64 8, !10, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40}
!15 = !{!16, !12, i64 296}
!16 = !{!"_SIFT3D", !17, i64 0, !18, i64 16, !21, i64 72, !14, i64 80, !14, i64 128, !22, i64 176, !10, i64 280, !10, i64 288, !12, i64 296}
!17 = !{!"_Mesh", !6, i64 0, !12, i64 8}
!18 = !{!"_GSS_filters", !19, i64 0, !6, i64 40, !12, i64 48, !12, i64 52}
!19 = !{!"_Gauss_filter", !10, i64 0, !20, i64 8}
!20 = !{!"_Sep_FIR_filter", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24}
!21 = !{!"_SIFT_cl_kernels", !12, i64 0}
!22 = !{!"_Image", !6, i64 0, !12, i64 8, !10, i64 16, !23, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !23, i64 72, !23, i64 80, !23, i64 88, !12, i64 96, !12, i64 100}
!23 = !{!"long", !7, 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
declare dso_local i32 @set_peak_thresh_SIFT3D(ptr noundef, double noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @init_SIFT3D(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 128
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @init_Pyramid(ptr noundef nonnull %2) #2
  tail call void @init_Pyramid(ptr noundef nonnull %3) #2
  tail call void @init_GSS_filters(ptr noundef nonnull %4) #2
  %5 = tail call i32 @init_geometry(ptr noundef %0)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %22

6:                                                ; preds = %1
  %7 = tail call i32 @init_cl_SIFT3D(ptr noundef %0)
  %.not17 = icmp eq i32 %7, 0
  br i1 %.not17, label %8, label %22

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @init_im(ptr noundef nonnull %9) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 116
  store i32 -1, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 164
  store i32 -1, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 296
  store i32 0, ptr %12, align 8, !tbaa !12
  %13 = tail call i32 @set_sigma_n_SIFT3D(ptr noundef %0, double noundef 1.150000e+00)
  %.not18 = icmp eq i32 %13, 0
  br i1 %.not18, label %14, label %22

14:                                               ; preds = %8
  %15 = tail call i32 @set_sigma0_SIFT3D(ptr noundef nonnull %0, double noundef 1.600000e+00)
  %.not19 = icmp eq i32 %15, 0
  br i1 %.not19, label %16, label %22

16:                                               ; preds = %14
  %17 = tail call i32 @set_peak_thresh_SIFT3D(ptr noundef nonnull %0, double noundef 1.000000e-01)
  %.not20 = icmp eq i32 %17, 0
  br i1 %.not20, label %18, label %22

18:                                               ; preds = %16
  %19 = tail call i32 @set_corner_thresh_SIFT3D(ptr noundef nonnull %0, double noundef 4.000000e-01)
  %.not21 = icmp eq i32 %19, 0
  br i1 %.not21, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call i32 @set_num_kp_levels_SIFT3D(ptr noundef nonnull %0, i32 noundef 3)
  %.not22 = icmp ne i32 %21, 0
  %spec.select = sext i1 %.not22 to i32
  br label %22

22:                                               ; preds = %20, %8, %14, %16, %18, %6, %1
  %.0 = phi i32 [ -1, %1 ], [ -1, %6 ], [ -1, %18 ], [ -1, %16 ], [ -1, %14 ], [ -1, %8 ], [ %spec.select, %20 ]
  ret i32 %.0
}

declare void @init_Pyramid(ptr noundef) local_unnamed_addr #1

declare void @init_GSS_filters(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @init_geometry(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @init_cl_SIFT3D(ptr noundef) local_unnamed_addr #0

declare void @init_im(ptr noundef) local_unnamed_addr #1

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 = { 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, !11, i64 36}
!6 = !{!"_Pyramid", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 296}
!13 = !{!"_SIFT3D", !14, i64 0, !15, i64 16, !18, i64 72, !6, i64 80, !6, i64 128, !19, i64 176, !10, i64 280, !10, i64 288, !11, i64 296}
!14 = !{!"_Mesh", !7, i64 0, !11, i64 8}
!15 = !{!"_GSS_filters", !16, i64 0, !7, i64 40, !11, i64 48, !11, i64 52}
!16 = !{!"_Gauss_filter", !10, i64 0, !17, i64 8}
!17 = !{!"_Sep_FIR_filter", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24}
!18 = !{!"_SIFT_cl_kernels", !11, i64 0}
!19 = !{!"_Image", !7, i64 0, !11, i64 8, !10, i64 16, !20, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !20, i64 72, !20, i64 80, !20, i64 88, !11, i64 96, !11, i64 100}
!20 = !{!"long", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass