; 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 }

@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1

; 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 @visualize_network(ptr noundef byval(%struct.network) align 8 %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [256 x i8], align 16
  %5 = alloca %struct.layer, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store ptr null, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 256, ptr %4) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

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

11:                                               ; preds = %6
  %12 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %12, ptr noundef @.str.27, i32 noundef %13) #5
  call void @llvm.lifetime.start.p0(i64 808, ptr %5) #5
  %15 = getelementptr inbounds %struct.network, ptr %0, i32 0, i32 8
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %struct.layer, ptr %16, i64 %18
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %19, i64 808, i1 false), !tbaa.struct !15
  %20 = getelementptr inbounds %struct.layer, ptr %5, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !19
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %11
  %24 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = call ptr @visualize_convolutional_layer(ptr noundef byval(%struct.layer) align 8 %5, ptr noundef %24, ptr noundef %25)
  store ptr %26, ptr %2, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %23, %11
  call void @llvm.lifetime.end.p0(i64 808, ptr %5) #5
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !21

31:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 256, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret void
}

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #3

declare ptr @visualize_convolutional_layer(ptr noundef byval(%struct.layer) align 8, ptr noundef, ptr noundef) #4

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

@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 @visualize_network(ptr nocapture noundef readonly byval(%struct.network) align 8 %0) local_unnamed_addr #1 {
  %2 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  br label %7

7:                                                ; preds = %.lr.ph, %16
  %8 = phi i32 [ %4, %.lr.ph ], [ %17, %16 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %.045 = phi ptr [ null, %.lr.ph ], [ %.1, %16 ]
  %9 = trunc nuw nsw i64 %indvars.iv to i32
  %10 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.27, i32 noundef %9) #4
  %11 = load ptr, ptr %6, align 8, !tbaa !12
  %12 = getelementptr inbounds %struct.layer, ptr %11, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %12, align 8, !tbaa !13
  %13 = icmp eq i32 %.sroa.0.0.copyload, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %7
  %15 = call ptr @visualize_convolutional_layer(ptr noundef nonnull byval(%struct.layer) align 8 %12, ptr noundef nonnull %2, ptr noundef %.045) #4
  %.pre = load i32, ptr %3, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %14, %7
  %17 = phi i32 [ %.pre, %14 ], [ %8, %7 ]
  %.1 = phi ptr [ %15, %14 ], [ %.045, %7 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %7, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %16, %1
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #4
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare ptr @visualize_convolutional_layer(ptr noundef byval(%struct.layer) align 8, ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { nofree 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 #3 = { "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, !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 = !{!10, !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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