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

; 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 }
%struct.matrix = type { 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: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind
declare i32 @rand() #2

declare void @free_image(ptr noundef byval(%struct.image) align 8) #3

declare void @load_image_color(ptr dead_on_unwind writable sret(%struct.image) align 8, ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local { i64, ptr } @load_image_augment_paths(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, float noundef %5, float noundef %6, float noundef %7, float noundef %8, float noundef %9) #4 {
  %11 = alloca %struct.matrix, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca i32, align 4
  %23 = alloca %struct.image, align 8
  %24 = alloca %struct.image, align 8
  %25 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store i32 %1, ptr %13, align 4, !tbaa !9
  store i32 %2, ptr %14, align 4, !tbaa !9
  store i32 %3, ptr %15, align 4, !tbaa !9
  store i32 %4, ptr %16, align 4, !tbaa !9
  store float %5, ptr %17, align 4, !tbaa !11
  store float %6, ptr %18, align 4, !tbaa !11
  store float %7, ptr %19, align 4, !tbaa !11
  store float %8, ptr %20, align 4, !tbaa !11
  store float %9, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %26 = load i32, ptr %13, align 4, !tbaa !9
  %27 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 0
  store i32 %26, ptr %27, align 8, !tbaa !13
  %28 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !13
  %30 = sext i32 %29 to i64
  %31 = call noalias ptr @calloc(i64 noundef %30, i64 noundef 8) #6
  %32 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 2
  store ptr %31, ptr %32, align 8, !tbaa !15
  %33 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 1
  store i32 0, ptr %33, align 4, !tbaa !16
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %74, %10
  %35 = load i32, ptr %22, align 4, !tbaa !9
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %77

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 24, ptr %23) #5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = load i32, ptr %22, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds ptr, ptr %39, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  call void @load_image_color(ptr dead_on_unwind writable sret(%struct.image) align 8 %23, ptr noundef %43, i32 noundef 0, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 24, ptr %24) #5
  %44 = load float, ptr %17, align 4, !tbaa !11
  %45 = load float, ptr %18, align 4, !tbaa !11
  %46 = load i32, ptr %14, align 4, !tbaa !9
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = load i32, ptr %16, align 4, !tbaa !9
  call void @random_augment_image(ptr dead_on_unwind writable sret(%struct.image) align 8 %24, ptr noundef byval(%struct.image) align 8 %23, float noundef %44, float noundef %45, i32 noundef %46, i32 noundef %47, i32 noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  %49 = call i32 @rand() #5
  %50 = srem i32 %49, 2
  store i32 %50, ptr %25, align 4, !tbaa !9
  %51 = load i32, ptr %25, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %38
  call void @flip_image(ptr noundef byval(%struct.image) align 8 %24)
  br label %54

54:                                               ; preds = %53, %38
  %55 = load float, ptr %19, align 4, !tbaa !11
  %56 = load float, ptr %20, align 4, !tbaa !11
  %57 = load float, ptr %21, align 4, !tbaa !11
  call void @random_distort_image(ptr noundef byval(%struct.image) align 8 %24, float noundef %55, float noundef %56, float noundef %57)
  call void @free_image(ptr noundef byval(%struct.image) align 8 %23)
  %58 = getelementptr inbounds %struct.image, ptr %24, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %22, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  store ptr %59, ptr %64, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.image, ptr %24, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !19
  %67 = getelementptr inbounds %struct.image, ptr %24, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !20
  %69 = mul nsw i32 %66, %68
  %70 = getelementptr inbounds %struct.image, ptr %24, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !21
  %72 = mul nsw i32 %69, %71
  %73 = getelementptr inbounds %struct.matrix, ptr %11, i32 0, i32 1
  store i32 %72, ptr %73, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %23) #5
  br label %74

74:                                               ; preds = %54
  %75 = load i32, ptr %22, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %22, align 4, !tbaa !9
  br label %34, !llvm.loop !22

77:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  %78 = load { i64, ptr }, ptr %11, align 8
  ret { i64, ptr } %78
}

declare void @random_augment_image(ptr dead_on_unwind writable sret(%struct.image) align 8, ptr noundef byval(%struct.image) align 8, float noundef, float noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @flip_image(ptr noundef byval(%struct.image) align 8) #3

declare void @random_distort_image(ptr noundef byval(%struct.image) align 8, float noundef, float noundef, float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,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 "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 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"matrix", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !10, i64 4}
!17 = !{!18, !6, i64 16}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!19 = !{!18, !10, i64 0}
!20 = !{!18, !10, i64 4}
!21 = !{!18, !10, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"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.image = type { i32, i32, i32, ptr }

; 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

declare void @free_image(ptr noundef byval(%struct.image) align 8) local_unnamed_addr #3

declare void @load_image_color(ptr dead_on_unwind writable sret(%struct.image) align 8, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local { i64, ptr } @load_image_augment_paths(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, float noundef %5, float noundef %6, float noundef %7, float noundef %8, float noundef %9) local_unnamed_addr #4 {
  %11 = alloca %struct.image, align 8
  %12 = alloca %struct.image, align 8
  %13 = sext i32 %1 to i64
  %14 = tail call noalias ptr @calloc(i64 noundef %13, i64 noundef 8) #5
  %15 = icmp sgt i32 %1, 0
  br i1 %15, label %.lr.ph, label %._crit_edge23

._crit_edge23:                                    ; preds = %10
  %.pre = zext i32 %1 to i64
  br label %35

.lr.ph:                                           ; preds = %10
  %16 = getelementptr inbounds i8, ptr %12, i64 16
  %17 = getelementptr inbounds i8, ptr %12, i64 4
  %18 = getelementptr inbounds i8, ptr %12, i64 8
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %25 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #6
  %20 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  call void @load_image_color(ptr dead_on_unwind nonnull writable sret(%struct.image) align 8 %11, ptr noundef %21, i32 noundef 0, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %12) #6
  call void @random_augment_image(ptr dead_on_unwind nonnull writable sret(%struct.image) align 8 %12, ptr noundef nonnull byval(%struct.image) align 8 %11, float noundef %5, float noundef %6, i32 noundef %2, i32 noundef %3, i32 noundef %4) #6
  %22 = call i32 @rand() #6
  %23 = and i32 %22, 1
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %25, label %24

24:                                               ; preds = %19
  call void @flip_image(ptr noundef nonnull byval(%struct.image) align 8 %12) #6
  br label %25

25:                                               ; preds = %24, %19
  call void @random_distort_image(ptr noundef nonnull byval(%struct.image) align 8 %12, float noundef %7, float noundef %8, float noundef %9) #6
  call void @free_image(ptr noundef nonnull byval(%struct.image) align 8 %11) #6
  %26 = load ptr, ptr %16, align 8, !tbaa !9
  %27 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  store ptr %26, ptr %27, align 8, !tbaa !5
  %28 = load i32, ptr %12, align 8, !tbaa !12
  %29 = load i32, ptr %17, align 4, !tbaa !13
  %30 = load i32, ptr %18, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %12) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #6
  %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 %19, !llvm.loop !15

._crit_edge:                                      ; preds = %25
  %31 = mul nsw i32 %29, %28
  %32 = mul nsw i32 %31, %30
  %33 = zext i32 %32 to i64
  %34 = shl nuw i64 %33, 32
  br label %35

35:                                               ; preds = %._crit_edge23, %._crit_edge
  %.sroa.0.0.insert.ext.pre-phi = phi i64 [ %.pre, %._crit_edge23 ], [ %wide.trip.count, %._crit_edge ]
  %.sroa.3.0.lcssa = phi i64 [ 0, %._crit_edge23 ], [ %34, %._crit_edge ]
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.3.0.lcssa, %.sroa.0.0.insert.ext.pre-phi
  %.fca.0.insert = insertvalue { i64, ptr } poison, i64 %.sroa.0.0.insert.insert, 0
  %.fca.1.insert = insertvalue { i64, ptr } %.fca.0.insert, ptr %14, 1
  ret { i64, ptr } %.fca.1.insert
}

declare void @random_augment_image(ptr dead_on_unwind writable sret(%struct.image) align 8, ptr noundef byval(%struct.image) align 8, float noundef, float noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare void @flip_image(ptr noundef byval(%struct.image) align 8) local_unnamed_addr #3

declare void @random_distort_image(ptr noundef byval(%struct.image) align 8, float noundef, float noundef, float noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 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 #5 = { nounwind allocsize(0,1) }
attributes #6 = { 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, !6, i64 16}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass