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

@.str.18 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.add_pixel = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @add_pixel(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  store float %4, ptr %9, align 4, !tbaa !9
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp slt i32 %10, %12
  br i1 %13, label %14, label %25

14:                                               ; preds = %5
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %25

19:                                               ; preds = %14
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = icmp slt i32 %20, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  br label %26

25:                                               ; preds = %19, %14, %5
  call void @__assert_fail(ptr noundef @.str.37, ptr noundef @.str.18, i32 noundef 1092, ptr noundef @__PRETTY_FUNCTION__.add_pixel) #2
  unreachable

26:                                               ; preds = %24
  %27 = load float, ptr %9, align 4, !tbaa !9
  %28 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %33 = mul nsw i32 %30, %32
  %34 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = mul nsw i32 %33, %35
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = mul nsw i32 %37, %39
  %41 = add nsw i32 %36, %40
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = add nsw i32 %41, %42
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds float, ptr %29, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = fadd float %46, %27
  store float %47, ptr %45, align 4, !tbaa !9
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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, !6, i64 4}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !13, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !13, i64 16}


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

@.str.18 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.add_pixel = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @add_pixel(ptr nocapture noundef readonly byval(%struct.image) align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, %1
  br i1 %8, label %9, label %15

9:                                                ; preds = %5
  %10 = load i32, ptr %0, align 8, !tbaa !11
  %11 = icmp sgt i32 %10, %2
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %12, align 8
  %14 = icmp sgt i32 %13, %3
  %or.cond = select i1 %11, i1 %14, i1 false
  br i1 %or.cond, label %16, label %15

15:                                               ; preds = %9, %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.18, i32 noundef 1092, ptr noundef nonnull @__PRETTY_FUNCTION__.add_pixel) #2
  unreachable

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = mul nsw i32 %10, %3
  %20 = add i32 %19, %2
  %21 = mul i32 %20, %7
  %22 = add nsw i32 %21, %1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds float, ptr %18, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !13
  %26 = fadd float %25, %4
  store float %26, ptr %24, align 4, !tbaa !13
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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, !7, i64 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass