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

; 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.box = type { float, float, float, float }

; Function Attrs: nounwind uwtable
define dso_local void @draw_bounding_box(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, i32 noundef %7) #0 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca float, align 4
  %20 = alloca %struct.box, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !5
  store float %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !11
  store ptr %5, ptr %14, align 8, !tbaa !11
  store ptr %6, ptr %15, align 8, !tbaa !11
  store i32 %7, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %113, %8
  %26 = load i32, ptr %17, align 4, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %116

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %30 = load ptr, ptr %14, align 8, !tbaa !11
  %31 = load i32, ptr %17, 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 !11
  %35 = load i32, ptr %16, align 4, !tbaa !5
  %36 = call i32 @max_index(ptr noundef %34, i32 noundef %35)
  store i32 %36, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %37 = load ptr, ptr %14, align 8, !tbaa !11
  %38 = load i32, ptr %17, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds ptr, ptr %37, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = load i32, ptr %18, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !9
  store float %45, ptr %19, align 4, !tbaa !9
  %46 = load float, ptr %19, align 4, !tbaa !9
  %47 = load float, ptr %12, align 4, !tbaa !9
  %48 = fcmp ogt float %46, %47
  br i1 %48, label %49, label %112

49:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #4
  %50 = load ptr, ptr %13, align 8, !tbaa !11
  %51 = load i32, ptr %17, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.box, ptr %50, i64 %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %53, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %54 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 0
  %55 = load float, ptr %54, align 4, !tbaa !14
  %56 = fpext float %55 to double
  %57 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 2
  %58 = load float, ptr %57, align 4, !tbaa !16
  %59 = fpext float %58 to double
  %60 = fdiv double %59, 2.000000e+00
  %61 = fsub double %56, %60
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = sitofp i32 %62 to double
  %64 = fmul double %61, %63
  %65 = fptosi double %64 to i32
  store i32 %65, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %66 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 1
  %67 = load float, ptr %66, align 4, !tbaa !17
  %68 = fpext float %67 to double
  %69 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 3
  %70 = load float, ptr %69, align 4, !tbaa !18
  %71 = fpext float %70 to double
  %72 = fdiv double %71, 2.000000e+00
  %73 = fsub double %68, %72
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = sitofp i32 %74 to double
  %76 = fmul double %73, %75
  %77 = fptosi double %76 to i32
  store i32 %77, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %78 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 0
  %79 = load float, ptr %78, align 4, !tbaa !14
  %80 = fpext float %79 to double
  %81 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 2
  %82 = load float, ptr %81, align 4, !tbaa !16
  %83 = fpext float %82 to double
  %84 = fdiv double %83, 2.000000e+00
  %85 = fadd double %80, %84
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = sitofp i32 %86 to double
  %88 = fmul double %85, %87
  %89 = fptosi double %88 to i32
  store i32 %89, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %90 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 1
  %91 = load float, ptr %90, align 4, !tbaa !17
  %92 = fpext float %91 to double
  %93 = getelementptr inbounds %struct.box, ptr %20, i32 0, i32 3
  %94 = load float, ptr %93, align 4, !tbaa !18
  %95 = fpext float %94 to double
  %96 = fdiv double %95, 2.000000e+00
  %97 = fadd double %92, %96
  %98 = load i32, ptr %10, align 4, !tbaa !5
  %99 = sitofp i32 %98 to double
  %100 = fmul double %97, %99
  %101 = fptosi double %100 to i32
  store i32 %101, ptr %24, align 4, !tbaa !5
  %102 = load i32, ptr %21, align 4, !tbaa !5
  %103 = load i32, ptr %22, align 4, !tbaa !5
  %104 = load i32, ptr %23, align 4, !tbaa !5
  %105 = load i32, ptr %24, align 4, !tbaa !5
  %106 = load ptr, ptr %15, align 8, !tbaa !11
  %107 = load i32, ptr %18, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds ptr, ptr %106, i64 %108
  %110 = load ptr, ptr %109, align 8, !tbaa !11
  %111 = load float, ptr %19, align 4, !tbaa !9
  call void @label_func(i32 noundef %102, i32 noundef %103, i32 noundef %104, i32 noundef %105, ptr noundef %110, float noundef %111)
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #4
  br label %112

112:                                              ; preds = %49, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %17, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %17, align 4, !tbaa !5
  br label %25, !llvm.loop !19

116:                                              ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  ret void
}

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

declare i32 @max_index(ptr noundef, i32 noundef) #2

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

declare void @label_func(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, float noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!15, !10, i64 8}
!17 = !{!15, !10, i64 4}
!18 = !{!15, !10, i64 12}
!19 = distinct !{!19, !20}
!20 = !{!"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.box = type { float, float, float, float }

; Function Attrs: nounwind uwtable
define dso_local void @draw_bounding_box(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readonly %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %8
  %10 = sitofp i32 %0 to double
  %11 = sitofp i32 %1 to double
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %12

12:                                               ; preds = %.lr.ph, %43
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %43 ]
  %13 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = tail call i32 @max_index(ptr noundef %14, i32 noundef %7) #2
  %16 = load ptr, ptr %13, align 8, !tbaa !5
  %17 = sext i32 %15 to i64
  %18 = getelementptr inbounds float, ptr %16, i64 %17
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fcmp ogt float %19, %3
  br i1 %20, label %21, label %43

21:                                               ; preds = %12
  %22 = getelementptr inbounds %struct.box, ptr %4, i64 %indvars.iv
  %.sroa.0.0.copyload = load float, ptr %22, align 4, !tbaa !9
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 4
  %.sroa.5.0.copyload = load float, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !9
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 8
  %.sroa.7.0.copyload = load float, ptr %.sroa.7.0..sroa_idx, align 4, !tbaa !9
  %.sroa.9.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 12
  %.sroa.9.0.copyload = load float, ptr %.sroa.9.0..sroa_idx, align 4, !tbaa !9
  %23 = fpext float %.sroa.0.0.copyload to double
  %24 = fpext float %.sroa.7.0.copyload to double
  %25 = fmul double %24, 5.000000e-01
  %26 = fsub double %23, %25
  %27 = fmul double %26, %10
  %28 = fptosi double %27 to i32
  %29 = fpext float %.sroa.5.0.copyload to double
  %30 = fpext float %.sroa.9.0.copyload to double
  %31 = fmul double %30, 5.000000e-01
  %32 = fsub double %29, %31
  %33 = fmul double %32, %11
  %34 = fptosi double %33 to i32
  %35 = fadd double %25, %23
  %36 = fmul double %35, %10
  %37 = fptosi double %36 to i32
  %38 = fadd double %31, %29
  %39 = fmul double %38, %11
  %40 = fptosi double %39 to i32
  %41 = getelementptr inbounds ptr, ptr %6, i64 %17
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  tail call void @label_func(i32 noundef %28, i32 noundef %34, i32 noundef %37, i32 noundef %40, ptr noundef %42, float noundef %19) #2
  br label %43

43:                                               ; preds = %21, %12
  %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 %12, !llvm.loop !11

._crit_edge:                                      ; preds = %43, %8
  ret void
}

declare i32 @max_index(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @label_func(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, float noundef) local_unnamed_addr #1

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 = { "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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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