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

; 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.network = type { ptr, i32, i32, ptr, float, i32, float, float, ptr, i32, ptr, i32, float, float, float, float, i32, i32, i32, ptr, ptr, i32, i32, i32, float, float, float, i32, i32, i32, i32, i32, i32, float, float, float, float, float, i32, ptr }
%struct.layer = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, i32, float, float, float, float, float, float, float, i32, i32, float, i32, i32, i32, i32, float, float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64 }

; 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 float @get_current_rate(ptr noundef byval(%struct.network) align 8) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @update_network(ptr noundef byval(%struct.network) align 8 %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca %struct.layer, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %6 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 2
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 5
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = mul nsw i32 %7, %9
  store i32 %10, ptr %3, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %11 = call float @get_current_rate(ptr noundef byval(%struct.network) align 8 %0)
  store float %11, ptr %4, align 4, !tbaa !14
  store i32 0, ptr %2, align 4, !tbaa !13
  br label %12

12:                                               ; preds = %36, %1
  %13 = load i32, ptr %2, align 4, !tbaa !13
  %14 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = icmp slt i32 %13, %15
  br i1 %16, label %17, label %39

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 808, ptr %5) #3
  %18 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 8
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = load i32, ptr %2, align 4, !tbaa !13
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds %struct.layer, ptr %19, i64 %21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %22, i64 808, i1 false), !tbaa.struct !17
  %23 = getelementptr inbounds %struct.layer, ptr %5, i32 0, i32 5
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %35

26:                                               ; preds = %17
  %27 = getelementptr inbounds %struct.layer, ptr %5, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = load i32, ptr %3, align 4, !tbaa !13
  %30 = load float, ptr %4, align 4, !tbaa !14
  %31 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 6
  %32 = load float, ptr %31, align 8, !tbaa !23
  %33 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 7
  %34 = load float, ptr %33, align 4, !tbaa !24
  call void %28(ptr noundef byval(%struct.layer) align 8 %5, i32 noundef %29, float noundef %30, float noundef %32, float noundef %34)
  br label %35

35:                                               ; preds = %26, %17
  call void @llvm.lifetime.end.p0(i64 808, ptr %5) #3
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %2, align 4, !tbaa !13
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !13
  br label %12, !llvm.loop !25

39:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 12}
!6 = !{!"network", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !11, i64 24, !10, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !10, i64 48, !7, i64 56, !10, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !7, i64 96, !7, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176, !10, i64 180, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 28}
!13 = !{!10, !10, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !7, i64 40}
!17 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 4, !13, i64 16, i64 8, !18, i64 24, i64 8, !18, i64 32, i64 8, !18, i64 40, i64 8, !18, i64 48, i64 8, !18, i64 56, i64 8, !18, i64 64, i64 4, !13, i64 68, i64 4, !13, i64 72, i64 4, !13, i64 76, i64 4, !13, i64 80, i64 4, !13, i64 84, i64 4, !13, i64 88, i64 4, !13, i64 92, i64 4, !13, i64 96, i64 4, !13, i64 100, i64 4, !13, i64 104, i64 4, !13, i64 108, i64 4, !13, i64 112, i64 4, !13, i64 116, i64 4, !13, i64 120, i64 4, !13, i64 124, i64 4, !13, i64 128, i64 4, !13, i64 132, i64 4, !13, i64 136, i64 4, !13, i64 140, i64 4, !13, i64 144, i64 4, !13, i64 148, i64 4, !13, i64 152, i64 4, !13, i64 156, i64 4, !13, i64 160, i64 4, !13, i64 164, i64 4, !13, i64 168, i64 4, !13, i64 172, i64 4, !13, i64 176, i64 4, !13, i64 180, i64 4, !14, i64 184, i64 4, !14, i64 188, i64 4, !14, i64 192, i64 4, !14, i64 196, i64 4, !14, i64 200, i64 4, !14, i64 204, i64 4, !14, i64 208, i64 4, !13, i64 212, i64 4, !13, i64 216, i64 4, !13, i64 220, i64 4, !13, i64 224, i64 4, !13, i64 228, i64 4, !13, i64 232, i64 4, !13, i64 236, i64 4, !13, i64 240, i64 4, !13, i64 244, i64 4, !13, i64 248, i64 4, !13, i64 252, i64 4, !13, i64 256, i64 4, !14, i64 260, i64 4, !14, i64 264, i64 4, !14, i64 268, i64 4, !13, i64 272, i64 4, !14, i64 276, i64 4, !14, i64 280, i64 4, !14, i64 284, i64 4, !14, i64 288, i64 4, !14, i64 292, i64 4, !14, i64 296, i64 4, !14, i64 300, i64 4, !13, i64 304, i64 4, !13, i64 308, i64 4, !14, i64 312, i64 4, !13, i64 316, i64 4, !13, i64 320, i64 4, !13, i64 324, i64 4, !13, i64 328, i64 4, !14, i64 332, i64 4, !14, i64 336, i64 4, !14, i64 344, i64 8, !18, i64 352, i64 8, !18, i64 360, i64 8, !18, i64 368, i64 8, !18, i64 376, i64 8, !18, i64 384, i64 8, !18, i64 392, i64 8, !18, i64 400, i64 8, !18, i64 408, i64 8, !18, i64 416, i64 8, !18, i64 424, i64 8, !18, i64 432, i64 8, !18, i64 440, i64 8, !18, i64 448, i64 8, !18, i64 456, i64 8, !18, i64 464, i64 8, !18, i64 472, i64 8, !18, i64 480, i64 8, !18, i64 488, i64 8, !18, i64 496, i64 8, !18, i64 504, i64 8, !18, i64 512, i64 8, !18, i64 520, i64 8, !18, i64 528, i64 8, !18, i64 536, i64 8, !18, i64 544, i64 8, !18, i64 552, i64 8, !18, i64 560, i64 8, !18, i64 568, i64 8, !18, i64 576, i64 8, !18, i64 584, i64 8, !18, i64 592, i64 8, !18, i64 600, i64 8, !18, i64 608, i64 8, !18, i64 616, i64 8, !18, i64 624, i64 8, !18, i64 632, i64 8, !18, i64 640, i64 8, !18, i64 648, i64 8, !18, i64 656, i64 8, !18, i64 664, i64 8, !18, i64 672, i64 8, !18, i64 680, i64 8, !18, i64 688, i64 8, !18, i64 696, i64 8, !18, i64 704, i64 8, !18, i64 712, i64 8, !18, i64 720, i64 8, !18, i64 728, i64 8, !18, i64 736, i64 8, !18, i64 744, i64 8, !18, i64 752, i64 8, !18, i64 760, i64 8, !18, i64 768, i64 8, !18, i64 776, i64 8, !18, i64 784, i64 8, !18, i64 792, i64 8, !18, i64 800, i64 8, !19}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"long", !8, i64 0}
!21 = !{!22, !7, i64 32}
!22 = !{!"layer", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !10, i64 232, !10, i64 236, !10, i64 240, !10, i64 244, !10, i64 248, !10, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !10, i64 268, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !11, i64 296, !10, i64 300, !10, i64 304, !11, i64 308, !10, i64 312, !10, i64 316, !10, i64 320, !10, i64 324, !11, i64 328, !11, i64 332, !11, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376, !7, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !7, i64 496, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !7, i64 536, !7, i64 544, !7, i64 552, !7, i64 560, !7, i64 568, !7, i64 576, !7, i64 584, !7, i64 592, !7, i64 600, !7, i64 608, !7, i64 616, !7, i64 624, !7, i64 632, !7, i64 640, !7, i64 648, !7, i64 656, !7, i64 664, !7, i64 672, !7, i64 680, !7, i64 688, !7, i64 696, !7, i64 704, !7, i64 712, !7, i64 720, !7, i64 728, !7, i64 736, !7, i64 744, !7, i64 752, !7, i64 760, !7, i64 768, !7, i64 776, !7, i64 784, !7, i64 792, !20, i64 800}
!23 = !{!6, !11, i64 32}
!24 = !{!6, !11, i64 36}
!25 = distinct !{!25, !26}
!26 = !{!"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.network = type { ptr, i32, i32, ptr, float, i32, float, float, ptr, i32, ptr, i32, float, float, float, float, i32, i32, i32, ptr, ptr, i32, i32, i32, float, float, float, i32, i32, i32, i32, i32, i32, float, float, float, float, float, i32, ptr }
%struct.layer = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, i32, float, float, float, float, float, float, float, i32, i32, float, i32, i32, i32, i32, float, float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64 }

; Function Attrs: nounwind uwtable
declare dso_local float @get_current_rate(ptr noundef byval(%struct.network) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @update_network(ptr noundef byval(%struct.network) align 8 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 28
  %5 = load i32, ptr %4, align 4, !tbaa !12
  %6 = mul nsw i32 %5, %3
  %7 = tail call float @get_current_rate(ptr noundef nonnull byval(%struct.network) align 8 %0)
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = getelementptr inbounds i8, ptr %0, i64 36
  br label %14

14:                                               ; preds = %.lr.ph, %21
  %15 = phi i32 [ %9, %.lr.ph ], [ %22, %21 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %21 ]
  %16 = load ptr, ptr %11, align 8, !tbaa !14
  %17 = getelementptr inbounds %struct.layer, ptr %16, i64 %indvars.iv
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %17, i64 32
  %.sroa.3.0.copyload = load ptr, ptr %.sroa.3.0..sroa_idx, align 8, !tbaa !15
  %.not = icmp eq ptr %.sroa.3.0.copyload, null
  br i1 %.not, label %21, label %18

18:                                               ; preds = %14
  %19 = load float, ptr %12, align 8, !tbaa !16
  %20 = load float, ptr %13, align 4, !tbaa !17
  tail call void %.sroa.3.0.copyload(ptr noundef nonnull byval(%struct.layer) align 8 %17, i32 noundef %6, float noundef %7, float noundef %19, float noundef %20) #1
  %.pre = load i32, ptr %8, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %18, %14
  %22 = phi i32 [ %.pre, %18 ], [ %15, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next, %23
  br i1 %24, label %14, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %21, %1
  ret void
}

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 = { 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, !10, i64 12}
!6 = !{!"network", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !11, i64 24, !10, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !10, i64 48, !7, i64 56, !10, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !7, i64 96, !7, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !11, i64 176, !10, i64 180, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 28}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !7, i64 40}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !11, i64 32}
!17 = !{!6, !11, i64 36}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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