; LLVM IR from hans-ob1/neural_cam_ros :: src/detector (data)

; 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.data = type { i32, i32, %struct.matrix, %struct.matrix, i32, ptr, ptr }
%struct.matrix = type { i32, i32, ptr }

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

; Function Attrs: nounwind uwtable
define dso_local void @get_next_batch(ptr noundef byval(%struct.data) align 8 %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  store ptr %4, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %60, %5
  %13 = load i32, ptr %10, align 4, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %63

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = add nsw i32 %17, %18
  store i32 %19, ptr %11, align 4, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !5
  %22 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 2
  %23 = getelementptr inbounds %struct.matrix, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = mul nsw i32 %21, %24
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds float, ptr %20, i64 %26
  %28 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 2
  %29 = getelementptr inbounds %struct.matrix, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 2
  %36 = getelementptr inbounds %struct.matrix, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = mul i64 %38, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %34, i64 %39, i1 false)
  %40 = load ptr, ptr %9, align 8, !tbaa !9
  %41 = load i32, ptr %10, align 4, !tbaa !5
  %42 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 3
  %43 = getelementptr inbounds %struct.matrix, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !15
  %45 = mul nsw i32 %41, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %40, i64 %46
  %48 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 3
  %49 = getelementptr inbounds %struct.matrix, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.data, ptr %0, i32 0, i32 3
  %56 = getelementptr inbounds %struct.matrix, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !15
  %58 = sext i32 %57 to i64
  %59 = mul i64 %58, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 4 %54, i64 %59, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %60

60:                                               ; preds = %16
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %10, align 4, !tbaa !5
  br label %12, !llvm.loop !17

63:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 12}
!12 = !{!"", !6, i64 0, !6, i64 4, !13, i64 8, !13, i64 24, !6, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!"matrix", !6, i64 0, !6, i64 4, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !6, i64 28}
!16 = !{!12, !10, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"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.data = type { i32, i32, %struct.matrix, %struct.matrix, i32, ptr, ptr }
%struct.matrix = type { i32, i32, ptr }

; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @get_next_batch(ptr nocapture noundef readonly byval(%struct.data) align 8 %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = sext i32 %8 to i64
  %12 = shl nsw i64 %11, 2
  %13 = getelementptr inbounds i8, ptr %0, i64 28
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = sext i32 %14 to i64
  %18 = shl nsw i64 %17, 2
  %19 = sext i32 %2 to i64
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = add nsw i64 %indvars.iv, %19
  %22 = mul nsw i64 %indvars.iv, %11
  %23 = getelementptr inbounds float, ptr %3, i64 %22
  %24 = getelementptr inbounds ptr, ptr %10, i64 %21
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %25, i64 %12, i1 false)
  %26 = mul nsw i64 %indvars.iv, %17
  %27 = getelementptr inbounds float, ptr %4, i64 %26
  %28 = getelementptr inbounds ptr, ptr %16, i64 %21
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %29, i64 %18, i1 false)
  %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 %._crit_edge, label %20, !llvm.loop !16

._crit_edge:                                      ; preds = %20, %5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 12}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 24, !7, i64 40, !11, i64 48, !11, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"matrix", !7, i64 0, !7, i64 4, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !7, i64 28}
!14 = !{!6, !11, i64 32}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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