; LLVM IR from bbrister/SIFT3D :: reg (reg)

; 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._Reg_SIFT3D = type { [3 x double], [3 x double], %struct._SIFT3D, %struct._Ransac, %struct._SIFT3D_Descriptor_store, %struct._SIFT3D_Descriptor_store, %struct._Mat_rm, %struct._Mat_rm, double, i32 }
%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 }
%struct._Ransac = type { double, i32 }
%struct._SIFT3D_Descriptor_store = type { ptr, i64, i32, i32, i32 }
%struct._Mat_rm = type { %union.anon, i64, i32, i32, i32, i32 }
%union.anon = type { ptr }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @set_nn_thresh_Reg_SIFT3D(ptr noundef %0, double noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = fcmp ole double %6, 0.000000e+00
  br i1 %7, label %11, label %8

8:                                                ; preds = %2
  %9 = load double, ptr %5, align 8, !tbaa !9
  %10 = fcmp ogt double %9, 1.000000e+00
  br i1 %10, label %11, label %15

11:                                               ; preds = %8, %2
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = load double, ptr %5, align 8, !tbaa !9
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str.1, double noundef %13) #2
  store i32 -1, ptr %3, align 4
  br label %19

15:                                               ; preds = %8
  %16 = load double, ptr %5, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._Reg_SIFT3D, ptr %17, i32 0, i32 8
  store double %16, ptr %18, align 8, !tbaa !11
  store i32 0, ptr %3, align 4
  br label %19

19:                                               ; preds = %15, %11
  %20 = load i32, ptr %3, align 4
  ret i32 %20
}

attributes #0 = { 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 #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 = { 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, !10, i64 496}
!12 = !{!"_Reg_SIFT3D", !7, i64 0, !7, i64 24, !13, i64 48, !23, i64 352, !24, i64 368, !24, i64 400, !25, i64 432, !25, i64 464, !10, i64 496, !15, i64 504}
!13 = !{!"_SIFT3D", !14, i64 0, !16, i64 16, !19, i64 72, !20, i64 80, !20, i64 128, !21, i64 176, !10, i64 280, !10, i64 288, !15, i64 296}
!14 = !{!"_Mesh", !6, i64 0, !15, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_GSS_filters", !17, i64 0, !6, i64 40, !15, i64 48, !15, i64 52}
!17 = !{!"_Gauss_filter", !10, i64 0, !18, i64 8}
!18 = !{!"_Sep_FIR_filter", !15, i64 0, !6, i64 8, !15, i64 16, !15, i64 20, !15, i64 24}
!19 = !{!"_SIFT_cl_kernels", !15, i64 0}
!20 = !{!"_Pyramid", !6, i64 0, !10, i64 8, !10, i64 16, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40}
!21 = !{!"_Image", !6, i64 0, !15, i64 8, !10, i64 16, !22, i64 24, !15, i64 32, !15, i64 36, !15, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !22, i64 72, !22, i64 80, !22, i64 88, !15, i64 96, !15, i64 100}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_Ransac", !10, i64 0, !15, i64 8}
!24 = !{!"_SIFT3D_Descriptor_store", !6, i64 0, !22, i64 8, !15, i64 16, !15, i64 20, !15, i64 24}
!25 = !{!"_Mat_rm", !7, i64 0, !22, i64 8, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 -1, 1) i32 @set_nn_thresh_Reg_SIFT3D(ptr nocapture noundef writeonly %0, double noundef %1) local_unnamed_addr #1 {
  %3 = fcmp ole double %1, 0.000000e+00
  %4 = fcmp ogt double %1, 1.000000e+00
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %5, label %8

5:                                                ; preds = %2
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.1, double noundef %1) #2
  br label %10

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 496
  store double %1, ptr %9, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %8, %5
  %.0 = phi i32 [ -1, %5 ], [ 0, %8 ]
  ret i32 %.0
}

attributes #0 = { nofree 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 #1 = { nofree 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 = { cold 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, !16, i64 496}
!10 = !{!"_Reg_SIFT3D", !7, i64 0, !7, i64 24, !11, i64 48, !22, i64 352, !23, i64 368, !23, i64 400, !24, i64 432, !24, i64 464, !16, i64 496, !13, i64 504}
!11 = !{!"_SIFT3D", !12, i64 0, !14, i64 16, !18, i64 72, !19, i64 80, !19, i64 128, !20, i64 176, !16, i64 280, !16, i64 288, !13, i64 296}
!12 = !{!"_Mesh", !6, i64 0, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_GSS_filters", !15, i64 0, !6, i64 40, !13, i64 48, !13, i64 52}
!15 = !{!"_Gauss_filter", !16, i64 0, !17, i64 8}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_Sep_FIR_filter", !13, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24}
!18 = !{!"_SIFT_cl_kernels", !13, i64 0}
!19 = !{!"_Pyramid", !6, i64 0, !16, i64 8, !16, i64 16, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40}
!20 = !{!"_Image", !6, i64 0, !13, i64 8, !16, i64 16, !21, i64 24, !13, i64 32, !13, i64 36, !13, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !21, i64 72, !21, i64 80, !21, i64 88, !13, i64 96, !13, i64 100}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_Ransac", !16, i64 0, !13, i64 8}
!23 = !{!"_SIFT3D_Descriptor_store", !6, i64 0, !21, i64 8, !13, i64 16, !13, i64 20, !13, i64 24}
!24 = !{!"_Mat_rm", !7, i64 0, !21, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28}


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