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

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

; 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
declare double @sqrt(double noundef) #1

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

23:                                               ; preds = %116, %9
  %24 = load i32, ptr %20, align 4, !tbaa !9
  %25 = load i32, ptr %15, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %119

27:                                               ; preds = %23
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %112, %27
  %29 = load i32, ptr %19, align 4, !tbaa !9
  %30 = load i32, ptr %16, align 4, !tbaa !9
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %115

32:                                               ; preds = %28
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %108, %32
  %34 = load i32, ptr %21, align 4, !tbaa !9
  %35 = load i32, ptr %17, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %111

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %38 = load i32, ptr %20, align 4, !tbaa !9
  %39 = load i32, ptr %16, align 4, !tbaa !9
  %40 = mul nsw i32 %38, %39
  %41 = load i32, ptr %17, align 4, !tbaa !9
  %42 = mul nsw i32 %40, %41
  %43 = load i32, ptr %19, align 4, !tbaa !9
  %44 = load i32, ptr %17, align 4, !tbaa !9
  %45 = mul nsw i32 %43, %44
  %46 = add nsw i32 %42, %45
  %47 = load i32, ptr %21, align 4, !tbaa !9
  %48 = add nsw i32 %46, %47
  store i32 %48, ptr %22, align 4, !tbaa !9
  %49 = load ptr, ptr %18, align 8, !tbaa !5
  %50 = load i32, ptr %22, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %49, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !11
  %54 = fpext float %53 to double
  %55 = fmul double %54, 1.000000e+00
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load i32, ptr %19, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %56, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !11
  %61 = fpext float %60 to double
  %62 = call double @sqrt(double noundef %61) #3
  %63 = fadd double %62, 0x3EE4F8B580000000
  %64 = fdiv double %55, %63
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = load i32, ptr %19, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !11
  %70 = fpext float %69 to double
  %71 = fmul double %70, 2.000000e+00
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load i32, ptr %22, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %72, i64 %74
  %76 = load float, ptr %75, align 4, !tbaa !11
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = load i32, ptr %19, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %77, i64 %79
  %81 = load float, ptr %80, align 4, !tbaa !11
  %82 = fsub float %76, %81
  %83 = fpext float %82 to double
  %84 = fmul double %71, %83
  %85 = load i32, ptr %17, align 4, !tbaa !9
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = mul nsw i32 %85, %86
  %88 = sitofp i32 %87 to double
  %89 = fdiv double %84, %88
  %90 = fadd double %64, %89
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = load i32, ptr %19, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds float, ptr %91, i64 %93
  %95 = load float, ptr %94, align 4, !tbaa !11
  %96 = load i32, ptr %17, align 4, !tbaa !9
  %97 = load i32, ptr %15, align 4, !tbaa !9
  %98 = mul nsw i32 %96, %97
  %99 = sitofp i32 %98 to float
  %100 = fdiv float %95, %99
  %101 = fpext float %100 to double
  %102 = fadd double %90, %101
  %103 = fptrunc double %102 to float
  %104 = load ptr, ptr %18, align 8, !tbaa !5
  %105 = load i32, ptr %22, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds float, ptr %104, i64 %106
  store float %103, ptr %107, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %108

108:                                              ; preds = %37
  %109 = load i32, ptr %21, align 4, !tbaa !9
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %21, align 4, !tbaa !9
  br label %33, !llvm.loop !13

111:                                              ; preds = %33
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %19, align 4, !tbaa !9
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %19, align 4, !tbaa !9
  br label %28, !llvm.loop !15

115:                                              ; preds = %28
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %20, align 4, !tbaa !9
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %20, align 4, !tbaa !9
  br label %23, !llvm.loop !16

119:                                              ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local void @normalize_delta_cpu(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, ptr nocapture noundef %8) local_unnamed_addr #1 {
  %10 = icmp sgt i32 %5, 0
  br i1 %10, label %.preheader37.lr.ph, label %._crit_edge

.preheader37.lr.ph:                               ; preds = %9
  %11 = icmp sgt i32 %6, 0
  %12 = mul nsw i32 %7, %5
  %13 = sitofp i32 %12 to double
  %14 = sitofp i32 %12 to float
  %15 = icmp sgt i32 %7, 0
  %or.cond = and i1 %11, %15
  br i1 %or.cond, label %.preheader37.us.us.preheader, label %._crit_edge

.preheader37.us.us.preheader:                     ; preds = %.preheader37.lr.ph
  %16 = zext nneg i32 %6 to i64
  %wide.trip.count57 = zext nneg i32 %5 to i64
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %.preheader37.us.us

.preheader37.us.us:                               ; preds = %.preheader37.us.us.preheader, %._crit_edge40.split.us.us.us
  %indvars.iv54 = phi i64 [ 0, %.preheader37.us.us.preheader ], [ %indvars.iv.next55, %._crit_edge40.split.us.us.us ]
  %17 = mul nuw nsw i64 %indvars.iv54, %16
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader37.us.us
  %indvars.iv49 = phi i64 [ %indvars.iv.next50, %._crit_edge.us.us.us ], [ 0, %.preheader37.us.us ]
  %18 = add nuw nsw i64 %indvars.iv49, %17
  %19 = trunc nuw i64 %18 to i32
  %20 = mul i32 %19, %7
  %21 = getelementptr inbounds float, ptr %2, i64 %indvars.iv49
  %22 = getelementptr inbounds float, ptr %4, i64 %indvars.iv49
  %23 = getelementptr inbounds float, ptr %1, i64 %indvars.iv49
  %24 = getelementptr inbounds float, ptr %3, i64 %indvars.iv49
  %25 = sext i32 %20 to i64
  br label %26

26:                                               ; preds = %26, %.preheader.us.us.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %26 ], [ 0, %.preheader.us.us.us ]
  %27 = add nsw i64 %indvars.iv, %25
  %28 = getelementptr inbounds float, ptr %8, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fpext float %29 to double
  %31 = load float, ptr %21, align 4, !tbaa !5
  %32 = fpext float %31 to double
  %33 = tail call double @sqrt(double noundef %32) #2
  %34 = fadd double %33, 0x3EE4F8B580000000
  %35 = fdiv double %30, %34
  %36 = load float, ptr %22, align 4, !tbaa !5
  %37 = fpext float %36 to double
  %38 = fmul double %37, 2.000000e+00
  %39 = getelementptr inbounds float, ptr %0, i64 %27
  %40 = load float, ptr %39, align 4, !tbaa !5
  %41 = load float, ptr %23, align 4, !tbaa !5
  %42 = fsub float %40, %41
  %43 = fpext float %42 to double
  %44 = fmul double %38, %43
  %45 = fdiv double %44, %13
  %46 = fadd double %35, %45
  %47 = load float, ptr %24, align 4, !tbaa !5
  %48 = fdiv float %47, %14
  %49 = fpext float %48 to double
  %50 = fadd double %46, %49
  %51 = fptrunc double %50 to float
  store float %51, ptr %28, align 4, !tbaa !5
  %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.us.us.us, label %26, !llvm.loop !9

._crit_edge.us.us.us:                             ; preds = %26
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next50, %16
  br i1 %exitcond53.not, label %._crit_edge40.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !11

._crit_edge40.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge, label %.preheader37.us.us, !llvm.loop !12

._crit_edge:                                      ; preds = %._crit_edge40.split.us.us.us, %.preheader37.lr.ph, %9
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nofree nounwind memory(write, argmem: readwrite) 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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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