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

; 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.VlDsiftFilter_ = type { i32, i32, i32, i32, i32, i32, i32, i32, %struct.VlDsiftDescriptorGeometry_, i32, double, i32, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr }
%struct.VlDsiftDescriptorGeometry_ = type { i32, i32, i32, 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 void @_vl_dsift_update_buffers(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %11, i32 0, i32 4
  %13 = load i32, ptr %12, align 8, !tbaa !9
  store i32 %13, ptr %3, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %14, i32 0, i32 6
  %16 = load i32, ptr %15, align 8, !tbaa !15
  store i32 %16, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %17, i32 0, i32 5
  %19 = load i32, ptr %18, align 4, !tbaa !16
  store i32 %19, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %20, i32 0, i32 7
  %22 = load i32, ptr %21, align 4, !tbaa !17
  store i32 %22, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %23 = load i32, ptr %4, align 4, !tbaa !14
  %24 = load i32, ptr %3, align 4, !tbaa !14
  %25 = sub nsw i32 %23, %24
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %26, i32 0, i32 8
  %28 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !18
  %30 = sub nsw i32 %29, 1
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %31, i32 0, i32 8
  %33 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 4, !tbaa !19
  %35 = mul nsw i32 %30, %34
  %36 = sub nsw i32 %25, %35
  store i32 %36, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %37 = load i32, ptr %6, align 4, !tbaa !14
  %38 = load i32, ptr %5, align 4, !tbaa !14
  %39 = sub nsw i32 %37, %38
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %40, i32 0, i32 8
  %42 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = sub nsw i32 %43, 1
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %45, i32 0, i32 8
  %47 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %46, i32 0, i32 4
  %48 = load i32, ptr %47, align 8, !tbaa !21
  %49 = mul nsw i32 %44, %48
  %50 = sub nsw i32 %39, %49
  store i32 %50, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %51 = load i32, ptr %7, align 4, !tbaa !14
  %52 = icmp sge i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %1
  %54 = load i32, ptr %7, align 4, !tbaa !14
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 8, !tbaa !22
  %58 = sdiv i32 %54, %57
  %59 = add nsw i32 %58, 1
  br label %61

60:                                               ; preds = %1
  br label %61

61:                                               ; preds = %60, %53
  %62 = phi i32 [ %59, %53 ], [ 0, %60 ]
  store i32 %62, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %63 = load i32, ptr %8, align 4, !tbaa !14
  %64 = icmp sge i32 %63, 0
  br i1 %64, label %65, label %72

65:                                               ; preds = %61
  %66 = load i32, ptr %8, align 4, !tbaa !14
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !23
  %70 = sdiv i32 %66, %69
  %71 = add nsw i32 %70, 1
  br label %73

72:                                               ; preds = %61
  br label %73

73:                                               ; preds = %72, %65
  %74 = phi i32 [ %71, %65 ], [ 0, %72 ]
  store i32 %74, ptr %10, align 4, !tbaa !14
  %75 = load i32, ptr %9, align 4, !tbaa !14
  %76 = load i32, ptr %10, align 4, !tbaa !14
  %77 = mul nsw i32 %75, %76
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %78, i32 0, i32 11
  store i32 %77, ptr %79, align 8, !tbaa !24
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %80, i32 0, i32 8
  %82 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !25
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %84, i32 0, i32 8
  %86 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !18
  %88 = mul nsw i32 %83, %87
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %89, i32 0, i32 8
  %91 = getelementptr inbounds %struct.VlDsiftDescriptorGeometry_, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 8, !tbaa !20
  %93 = mul nsw i32 %88, %92
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.VlDsiftFilter_, ptr %94, i32 0, i32 12
  store i32 %93, ptr %95, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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 = { 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, !11, i64 16}
!10 = !{!"VlDsiftFilter_", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32, !11, i64 52, !13, i64 56, !11, i64 64, !11, i64 68, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"VlDsiftDescriptorGeometry_", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!13 = !{!"double", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 20}
!17 = !{!10, !11, i64 28}
!18 = !{!10, !11, i64 36}
!19 = !{!10, !11, i64 44}
!20 = !{!10, !11, i64 40}
!21 = !{!10, !11, i64 48}
!22 = !{!10, !11, i64 8}
!23 = !{!10, !11, i64 12}
!24 = !{!10, !11, i64 64}
!25 = !{!10, !11, i64 32}
!26 = !{!10, !11, i64 68}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_vl_dsift_update_buffers(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  %7 = load i32, ptr %6, align 4, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  %9 = load i32, ptr %8, align 4, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %0, i64 36
  %11 = load i32, ptr %10, align 4, !tbaa !16
  %.neg30 = sub i32 1, %11
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  %13 = load i32, ptr %12, align 4, !tbaa !17
  %.neg31 = mul i32 %.neg30, %13
  %.neg26 = sub i32 %5, %3
  %14 = add i32 %.neg26, %.neg31
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load i32, ptr %15, align 8, !tbaa !18
  %.neg = sub i32 1, %16
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %.neg32 = mul i32 %.neg, %18
  %.neg29 = sub i32 %9, %7
  %19 = add i32 %.neg29, %.neg32
  %20 = icmp sgt i32 %14, -1
  br i1 %20, label %21, label %26

21:                                               ; preds = %1
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = sdiv i32 %14, %23
  %25 = add nsw i32 %24, 1
  br label %26

26:                                               ; preds = %1, %21
  %27 = phi i32 [ %25, %21 ], [ 0, %1 ]
  %28 = icmp sgt i32 %19, -1
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !21
  %32 = sdiv i32 %19, %31
  %33 = add nsw i32 %32, 1
  br label %34

34:                                               ; preds = %26, %29
  %35 = phi i32 [ %33, %29 ], [ 0, %26 ]
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  %37 = mul nsw i32 %35, %27
  %38 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %37, ptr %38, align 8, !tbaa !22
  %39 = load i32, ptr %36, align 8, !tbaa !23
  %40 = mul i32 %16, %11
  %41 = mul i32 %40, %39
  %42 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 %41, ptr %42, align 4, !tbaa !24
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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, !7, i64 16}
!6 = !{!"VlDsiftFilter_", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !10, i64 32, !7, i64 52, !11, i64 56, !7, i64 64, !7, i64 68, !12, i64 72, !12, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !12, i64 104, !12, i64 112, !12, i64 120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"VlDsiftDescriptorGeometry_", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16}
!11 = !{!"double", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !7, i64 20}
!15 = !{!6, !7, i64 28}
!16 = !{!6, !7, i64 36}
!17 = !{!6, !7, i64 44}
!18 = !{!6, !7, i64 40}
!19 = !{!6, !7, i64 48}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !7, i64 12}
!22 = !{!6, !7, i64 64}
!23 = !{!6, !7, i64 32}
!24 = !{!6, !7, i64 68}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass