; 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__.set_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 @set_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 = icmp slt i32 %10, 0
  br i1 %11, label %33, label %12

12:                                               ; preds = %5
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 0
  br i1 %14, label %33, label %15

15:                                               ; preds = %12
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 0
  br i1 %17, label %33, label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp sge i32 %19, %21
  br i1 %22, label %33, label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !14
  %27 = icmp sge i32 %24, %26
  br i1 %27, label %33, label %28

28:                                               ; preds = %23
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = icmp sge i32 %29, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %28, %23, %18, %15, %12, %5
  br label %71

34:                                               ; preds = %28
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = icmp slt i32 %35, %37
  br i1 %38, label %39, label %50

39:                                               ; preds = %34
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !14
  %43 = icmp slt i32 %40, %42
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !15
  %48 = icmp slt i32 %45, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  br label %51

50:                                               ; preds = %44, %39, %34
  call void @__assert_fail(ptr noundef @.str.37, ptr noundef @.str.18, i32 noundef 1087, ptr noundef @__PRETTY_FUNCTION__.set_pixel) #2
  unreachable

51:                                               ; preds = %49
  %52 = load float, ptr %9, align 4, !tbaa !9
  %53 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !14
  %58 = mul nsw i32 %55, %57
  %59 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = mul nsw i32 %58, %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !11
  %65 = mul nsw i32 %62, %64
  %66 = add nsw i32 %61, %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %66, %67
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds float, ptr %54, i64 %69
  store float %52, ptr %70, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %51, %33
  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 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @set_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 #0 {
  %6 = or i32 %2, %1
  %7 = or i32 %6, %3
  %or.cond3.not = icmp sgt i32 %7, -1
  br i1 %or.cond3.not, label %8, label %24

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.not = icmp sgt i32 %10, %1
  br i1 %.not, label %11, label %24

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

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = mul nsw i32 %12, %3
  %19 = add i32 %18, %2
  %20 = mul i32 %19, %10
  %21 = add nuw nsw i32 %20, %1
  %22 = zext nneg i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %17, i64 %22
  store float %4, ptr %23, align 4, !tbaa !13
  br label %24

24:                                               ; preds = %5, %8, %11, %15
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, 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, !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,IPSCCPPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass