; 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
define dso_local float @get_network_cost(ptr noundef byval(%struct.network) align 8 %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store float 0.000000e+00, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %34, %1
  %6 = load i32, ptr %2, align 4, !tbaa !9
  %7 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 1
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = icmp slt i32 %6, %8
  br i1 %9, label %10, label %37

10:                                               ; preds = %5
  %11 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 8
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds %struct.layer, ptr %12, i64 %14
  %16 = getelementptr inbounds %struct.layer, ptr %15, i32 0, i32 84
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %33

19:                                               ; preds = %10
  %20 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 8
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = load i32, ptr %2, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.layer, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct.layer, ptr %24, i32 0, i32 84
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds float, ptr %26, i64 0
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = load float, ptr %3, align 4, !tbaa !5
  %30 = fadd float %29, %28
  store float %30, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %19, %10
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %2, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !9
  br label %5, !llvm.loop !18

37:                                               ; preds = %5
  %38 = load float, ptr %3, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = sitofp i32 %39 to float
  %41 = fdiv float %38, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  ret float %41
}

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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"network", !13, i64 0, !10, i64 8, !10, i64 12, !13, i64 16, !6, i64 24, !10, i64 28, !6, i64 32, !6, i64 36, !13, i64 40, !10, i64 48, !13, i64 56, !10, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !13, i64 96, !13, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !6, i64 124, !6, i64 128, !6, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !6, i64 176, !10, i64 180, !13, i64 184}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !13, i64 40}
!15 = !{!16, !13, i64 392}
!16 = !{!"layer", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, 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, !6, i64 180, !6, i64 184, !6, i64 188, !6, i64 192, !6, i64 196, !6, i64 200, !6, 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, !6, i64 256, !6, i64 260, !6, i64 264, !10, i64 268, !6, i64 272, !6, i64 276, !6, i64 280, !6, i64 284, !6, i64 288, !6, i64 292, !6, i64 296, !10, i64 300, !10, i64 304, !6, i64 308, !10, i64 312, !10, i64 316, !10, i64 320, !10, i64 324, !6, i64 328, !6, i64 332, !6, i64 336, !13, i64 344, !13, i64 352, !13, i64 360, !13, i64 368, !13, i64 376, !13, i64 384, !13, i64 392, !13, i64 400, !13, i64 408, !13, i64 416, !13, i64 424, !13, i64 432, !13, i64 440, !13, i64 448, !13, i64 456, !13, i64 464, !13, i64 472, !13, i64 480, !13, i64 488, !13, i64 496, !13, i64 504, !13, i64 512, !13, i64 520, !13, i64 528, !13, i64 536, !13, i64 544, !13, i64 552, !13, i64 560, !13, i64 568, !13, i64 576, !13, i64 584, !13, i64 592, !13, i64 600, !13, i64 608, !13, i64 616, !13, i64 624, !13, i64 632, !13, i64 640, !13, i64 648, !13, i64 656, !13, i64 664, !13, i64 672, !13, i64 680, !13, i64 688, !13, i64 696, !13, i64 704, !13, i64 712, !13, i64 720, !13, i64 728, !13, i64 736, !13, i64 744, !13, i64 752, !13, i64 760, !13, i64 768, !13, i64 776, !13, i64 784, !13, i64 792, !17, i64 800}
!17 = !{!"long", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local float @get_network_cost(ptr nocapture noundef readonly byval(%struct.network) align 8 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %wide.trip.count = zext nneg i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %7 = icmp eq i32 %3, 1
  br i1 %7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %8

8:                                                ; preds = %22, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %22 ]
  %.013 = phi i32 [ 0, %.lr.ph.new ], [ %.1.1, %22 ]
  %.0712 = phi float [ 0.000000e+00, %.lr.ph.new ], [ %.18.1, %22 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %22 ]
  %9 = getelementptr inbounds %struct.layer, ptr %6, i64 %indvars.iv, i32 84
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %15, label %11

11:                                               ; preds = %8
  %12 = load float, ptr %10, align 4, !tbaa !16
  %13 = fadd float %.0712, %12
  %14 = add nsw i32 %.013, 1
  br label %15

15:                                               ; preds = %8, %11
  %.18 = phi float [ %13, %11 ], [ %.0712, %8 ]
  %.1 = phi i32 [ %14, %11 ], [ %.013, %8 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = getelementptr inbounds %struct.layer, ptr %6, i64 %indvars.iv.next, i32 84
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %.not.1 = icmp eq ptr %17, null
  br i1 %.not.1, label %22, label %18

18:                                               ; preds = %15
  %19 = load float, ptr %17, align 4, !tbaa !16
  %20 = fadd float %.18, %19
  %21 = add nsw i32 %.1, 1
  br label %22

22:                                               ; preds = %18, %15
  %.18.1 = phi float [ %20, %18 ], [ %.18, %15 ]
  %.1.1 = phi i32 [ %21, %18 ], [ %.1, %15 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %8, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %22, %.lr.ph
  %.18.lcssa.ph = phi float [ poison, %.lr.ph ], [ %.18.1, %22 ]
  %.1.lcssa.ph = phi i32 [ poison, %.lr.ph ], [ %.1.1, %22 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %22 ]
  %.013.unr = phi i32 [ 0, %.lr.ph ], [ %.1.1, %22 ]
  %.0712.unr = phi float [ 0.000000e+00, %.lr.ph ], [ %.18.1, %22 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %23 = getelementptr inbounds %struct.layer, ptr %6, i64 %indvars.iv.unr, i32 84
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %.not.epil = icmp eq ptr %24, null
  br i1 %.not.epil, label %._crit_edge.loopexit, label %25

25:                                               ; preds = %.epil.preheader
  %26 = load float, ptr %24, align 4, !tbaa !16
  %27 = fadd float %.0712.unr, %26
  %28 = add nsw i32 %.013.unr, 1
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %.epil.preheader, %25, %._crit_edge.loopexit.unr-lcssa
  %.18.lcssa = phi float [ %.18.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %27, %25 ], [ %.0712.unr, %.epil.preheader ]
  %.1.lcssa = phi i32 [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %28, %25 ], [ %.013.unr, %.epil.preheader ]
  %29 = sitofp i32 %.1.lcssa to float
  %30 = fdiv float %.18.lcssa, %29
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %31 = phi float [ 0x7FF8000000000000, %1 ], [ %30, %._crit_edge.loopexit ]
  ret float %31
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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, !10, i64 8}
!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, !7, i64 40}
!13 = !{!14, !7, i64 392}
!14 = !{!"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, !15, i64 800}
!15 = !{!"long", !8, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass