; 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._Keypoint_store = type { ptr, %struct._Slab, i32, i32, i32 }
%struct._Slab = type { ptr, i64, i64 }
%struct._Mat_rm = type { %union.anon, i64, i32, i32, i32, i32 }
%union.anon = type { ptr }
%struct._Keypoint = type { [9 x float], %struct._Mat_rm, double, double, double, double, 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
define dso_local i32 @Keypoint_store_to_Mat_rm(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._Keypoint_store, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds %struct._Slab, ptr %12, i32 0, i32 1
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr %7, align 4, !tbaa !14
  %16 = load i32, ptr %7, align 4, !tbaa !14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._Mat_rm, ptr %17, i32 0, i32 3
  store i32 %16, ptr %18, align 4, !tbaa !15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._Mat_rm, ptr %19, i32 0, i32 2
  store i32 3, ptr %20, align 8, !tbaa !17
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._Mat_rm, ptr %21, i32 0, i32 5
  store i32 0, ptr %22, align 4, !tbaa !18
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 @resize_Mat_rm(ptr noundef %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %95

27:                                               ; preds = %2
  store i32 0, ptr %6, align 4, !tbaa !14
  br label %28

28:                                               ; preds = %91, %27
  %29 = load i32, ptr %6, align 4, !tbaa !14
  %30 = load i32, ptr %7, align 4, !tbaa !14
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %94

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._Keypoint_store, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = load i32, ptr %6, align 4, !tbaa !14
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct._Keypoint, ptr %35, i64 %37
  store ptr %38, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._Keypoint, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %40, align 8, !tbaa !20
  %42 = call double @ldexp(double noundef 1.000000e+00, i32 noundef %41) #4
  store double %42, ptr %10, align 8, !tbaa !23
  %43 = load double, ptr %10, align 8, !tbaa !23
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._Keypoint, ptr %44, i32 0, i32 2
  %46 = load double, ptr %45, align 8, !tbaa !24
  %47 = fmul double %43, %46
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._Mat_rm, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !25
  %51 = load i32, ptr %6, align 4, !tbaa !14
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._Mat_rm, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !17
  %55 = mul nsw i32 %51, %54
  %56 = add nsw i32 0, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %50, i64 %57
  store double %47, ptr %58, align 8, !tbaa !23
  %59 = load double, ptr %10, align 8, !tbaa !23
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._Keypoint, ptr %60, i32 0, i32 3
  %62 = load double, ptr %61, align 8, !tbaa !26
  %63 = fmul double %59, %62
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._Mat_rm, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !25
  %67 = load i32, ptr %6, align 4, !tbaa !14
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._Mat_rm, ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !17
  %71 = mul nsw i32 %67, %70
  %72 = add nsw i32 1, %71
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %66, i64 %73
  store double %63, ptr %74, align 8, !tbaa !23
  %75 = load double, ptr %10, align 8, !tbaa !23
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._Keypoint, ptr %76, i32 0, i32 4
  %78 = load double, ptr %77, align 8, !tbaa !27
  %79 = fmul double %75, %78
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._Mat_rm, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !25
  %83 = load i32, ptr %6, align 4, !tbaa !14
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._Mat_rm, ptr %84, i32 0, i32 2
  %86 = load i32, ptr %85, align 8, !tbaa !17
  %87 = mul nsw i32 %83, %86
  %88 = add nsw i32 2, %87
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %82, i64 %89
  store double %79, ptr %90, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %91

91:                                               ; preds = %32
  %92 = load i32, ptr %6, align 4, !tbaa !14
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %6, align 4, !tbaa !14
  br label %28, !llvm.loop !28

94:                                               ; preds = %28
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %95

95:                                               ; preds = %94, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %96 = load i32, ptr %3, align 4
  ret i32 %96
}

declare i32 @resize_Mat_rm(ptr noundef) #2

; Function Attrs: nounwind
declare double @ldexp(double noundef, i32 noundef) #3

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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"_Keypoint_store", !6, i64 0, !11, i64 8, !13, i64 32, !13, i64 36, !13, i64 40}
!11 = !{!"_Slab", !6, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !13, i64 20}
!16 = !{!"_Mat_rm", !7, i64 0, !12, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28}
!17 = !{!16, !13, i64 16}
!18 = !{!16, !13, i64 28}
!19 = !{!10, !6, i64 0}
!20 = !{!21, !13, i64 104}
!21 = !{!"_Keypoint", !7, i64 0, !16, i64 40, !22, i64 72, !22, i64 80, !22, i64 88, !22, i64 96, !13, i64 104, !13, i64 108}
!22 = !{!"double", !7, i64 0}
!23 = !{!22, !22, i64 0}
!24 = !{!21, !22, i64 72}
!25 = !{!7, !7, i64 0}
!26 = !{!21, !22, i64 80}
!27 = !{!21, !22, i64 88}
!28 = distinct !{!28, !29}
!29 = !{!"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._Keypoint = type { [9 x float], %struct._Mat_rm, double, double, double, double, i32, i32 }
%struct._Mat_rm = type { %union.anon, i64, i32, i32, i32, i32 }
%union.anon = type { ptr }

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @Keypoint_store_to_Mat_rm(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = trunc i64 %4 to i32
  %6 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %5, ptr %6, align 4, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 3, ptr %7, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %1, i64 28
  store i32 0, ptr %8, align 4, !tbaa !16
  %9 = tail call i32 @resize_Mat_rm(ptr noundef %1) #3
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %10 = icmp sgt i32 %5, 0
  br i1 %10, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = and i64 %4, 2147483647
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %11 = load ptr, ptr %0, align 8, !tbaa !17
  %12 = getelementptr inbounds %struct._Keypoint, ptr %11, i64 %indvars.iv
  %13 = getelementptr inbounds i8, ptr %12, i64 104
  %14 = load i32, ptr %13, align 8, !tbaa !18
  %15 = tail call double @ldexp(double noundef 1.000000e+00, i32 noundef %14) #3
  %16 = getelementptr inbounds i8, ptr %12, i64 72
  %17 = load double, ptr %16, align 8, !tbaa !21
  %18 = fmul double %15, %17
  %19 = load ptr, ptr %1, align 8, !tbaa !22
  %20 = load i32, ptr %7, align 8, !tbaa !15
  %21 = trunc nuw nsw i64 %indvars.iv to i32
  %22 = mul nsw i32 %20, %21
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds double, ptr %19, i64 %23
  store double %18, ptr %24, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %12, i64 80
  %26 = load double, ptr %25, align 8, !tbaa !24
  %27 = fmul double %15, %26
  %28 = load ptr, ptr %1, align 8, !tbaa !22
  %29 = getelementptr double, ptr %28, i64 %23
  %30 = getelementptr i8, ptr %29, i64 8
  store double %27, ptr %30, align 8, !tbaa !23
  %31 = getelementptr inbounds i8, ptr %12, i64 88
  %32 = load double, ptr %31, align 8, !tbaa !25
  %33 = fmul double %15, %32
  %34 = load ptr, ptr %1, align 8, !tbaa !22
  %35 = getelementptr double, ptr %34, i64 %23
  %36 = getelementptr i8, ptr %35, i64 16
  store double %33, ptr %36, align 8, !tbaa !23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !26

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %2
  %.0 = phi i32 [ -1, %2 ], [ 0, %.preheader ], [ 0, %.lr.ph ]
  ret i32 %.0
}

declare i32 @resize_Mat_rm(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn
declare double @ldexp(double noundef, i32 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 = { "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 nofree nounwind willreturn "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, !11, i64 16}
!6 = !{!"_Keypoint_store", !7, i64 0, !10, i64 8, !12, i64 32, !12, i64 36, !12, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Slab", !7, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !12, i64 20}
!14 = !{!"_Mat_rm", !8, i64 0, !11, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!15 = !{!14, !12, i64 16}
!16 = !{!14, !12, i64 28}
!17 = !{!6, !7, i64 0}
!18 = !{!19, !12, i64 104}
!19 = !{!"_Keypoint", !8, i64 0, !14, i64 40, !20, i64 72, !20, i64 80, !20, i64 88, !20, i64 96, !12, i64 104, !12, i64 108}
!20 = !{!"double", !8, i64 0}
!21 = !{!19, !20, i64 72}
!22 = !{!8, !8, i64 0}
!23 = !{!20, !20, i64 0}
!24 = !{!19, !20, i64 80}
!25 = !{!19, !20, i64 88}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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