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

; 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.image = type { i32, 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 nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
declare dso_local float @get_pixel_extend(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @bilinear_interpolate(ptr noundef byval(%struct.image) align 8 %0, float noundef %1, float noundef %2, i32 noundef %3) #2 {
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store float %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !5
  store i32 %3, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %13 = load float, ptr %5, align 4, !tbaa !5
  %14 = call float @llvm.floor.f32(float %13)
  %15 = fptosi float %14 to i32
  store i32 %15, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %16 = load float, ptr %6, align 4, !tbaa !5
  %17 = call float @llvm.floor.f32(float %16)
  %18 = fptosi float %17 to i32
  store i32 %18, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %19 = load float, ptr %5, align 4, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = sitofp i32 %20 to float
  %22 = fsub float %19, %21
  store float %22, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %23 = load float, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = sitofp i32 %24 to float
  %26 = fsub float %23, %25
  store float %26, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %27 = load float, ptr %11, align 4, !tbaa !5
  %28 = fsub float 1.000000e+00, %27
  %29 = load float, ptr %10, align 4, !tbaa !5
  %30 = fsub float 1.000000e+00, %29
  %31 = fmul float %28, %30
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = call float @get_pixel_extend(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %32, i32 noundef %33, i32 noundef %34)
  %36 = load float, ptr %11, align 4, !tbaa !5
  %37 = load float, ptr %10, align 4, !tbaa !5
  %38 = fsub float 1.000000e+00, %37
  %39 = fmul float %36, %38
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = call float @get_pixel_extend(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %40, i32 noundef %42, i32 noundef %43)
  %45 = fmul float %39, %44
  %46 = call float @llvm.fmuladd.f32(float %31, float %35, float %45)
  %47 = load float, ptr %11, align 4, !tbaa !5
  %48 = fsub float 1.000000e+00, %47
  %49 = load float, ptr %10, align 4, !tbaa !5
  %50 = fmul float %48, %49
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = call float @get_pixel_extend(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %52, i32 noundef %53, i32 noundef %54)
  %56 = call float @llvm.fmuladd.f32(float %50, float %55, float %46)
  %57 = load float, ptr %11, align 4, !tbaa !5
  %58 = load float, ptr %10, align 4, !tbaa !5
  %59 = fmul float %57, %58
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = add nsw i32 %60, 1
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr %7, align 4, !tbaa !9
  %65 = call float @get_pixel_extend(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %61, i32 noundef %63, i32 noundef %64)
  %66 = call float @llvm.fmuladd.f32(float %59, float %65, float %56)
  store float %66, ptr %12, align 4, !tbaa !5
  %67 = load float, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  ret float %67
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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}


; 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.image = type { i32, i32, i32, ptr }

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nounwind uwtable
declare dso_local float @get_pixel_extend(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @bilinear_interpolate(ptr noundef byval(%struct.image) align 8 %0, float noundef %1, float noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = insertelement <2 x float> poison, float %1, i64 0
  %6 = insertelement <2 x float> %5, float %2, i64 1
  %7 = tail call <2 x float> @llvm.floor.v2f32(<2 x float> %6)
  %8 = fptosi <2 x float> %7 to <2 x i32>
  %9 = sitofp <2 x i32> %8 to <2 x float>
  %10 = fsub <2 x float> %6, %9
  %11 = fsub <2 x float> <float 1.000000e+00, float 1.000000e+00>, %10
  %12 = extractelement <2 x float> %11, i64 0
  %13 = extractelement <2 x float> %11, i64 1
  %14 = fmul float %12, %13
  %15 = extractelement <2 x i32> %8, i64 0
  %16 = extractelement <2 x i32> %8, i64 1
  %17 = tail call float @get_pixel_extend(ptr noundef nonnull byval(%struct.image) align 8 %0, i32 noundef %15, i32 noundef %16, i32 noundef %3)
  %18 = extractelement <2 x float> %10, i64 1
  %19 = fmul float %18, %12
  %20 = add nsw i32 %16, 1
  %21 = tail call float @get_pixel_extend(ptr noundef nonnull byval(%struct.image) align 8 %0, i32 noundef %15, i32 noundef %20, i32 noundef %3)
  %22 = fmul float %19, %21
  %23 = tail call float @llvm.fmuladd.f32(float %14, float %17, float %22)
  %24 = extractelement <2 x float> %10, i64 0
  %25 = fmul float %24, %13
  %26 = add nsw i32 %15, 1
  %27 = tail call float @get_pixel_extend(ptr noundef nonnull byval(%struct.image) align 8 %0, i32 noundef %26, i32 noundef %16, i32 noundef %3)
  %28 = tail call float @llvm.fmuladd.f32(float %25, float %27, float %23)
  %29 = fmul float %24, %18
  %30 = tail call float @get_pixel_extend(ptr noundef nonnull byval(%struct.image) align 8 %0, i32 noundef %26, i32 noundef %20, i32 noundef %3)
  %31 = tail call float @llvm.fmuladd.f32(float %29, float %30, float %28)
  ret float %31
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.floor.v2f32(<2 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 nosync nounwind speculatable willreturn memory(none) }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass