; LLVM IR from cyberbotics/webots_ros2 :: webots_ros2_driver/webots/src/controller/c (radar)

; 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.Radar = type { i8, i32, i32, ptr, double, double, double, double }
%struct.WbRadarTarget = type { double, double, double, double }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@__FUNCTION__.wbr_radar_set_targets = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @wbr_radar_set_targets(i16 noundef zeroext %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i16, align 2
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store i16 %0, ptr %4, align 2, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load i16, ptr %4, align 2, !tbaa !5
  %10 = call ptr @radar_get_struct(i16 noundef zeroext %9)
  store ptr %10, ptr %7, align 8, !tbaa !9
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %91

13:                                               ; preds = %3
  %14 = load i32, ptr %6, align 4, !tbaa !11
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.Radar, ptr %15, i32 0, i32 2
  store i32 %14, ptr %16, align 8, !tbaa !13
  %17 = load ptr, ptr %7, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.Radar, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  call void @free(ptr noundef %19) #4
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.Radar, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = sext i32 %22 to i64
  %24 = mul i64 %23, 32
  %25 = call noalias ptr @malloc(i64 noundef %24) #5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.Radar, ptr %26, i32 0, i32 3
  store ptr %25, ptr %27, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %87, %13
  %29 = load i32, ptr %8, align 4, !tbaa !11
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.Radar, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %90

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct.WbRadarTarget, ptr %35, i64 %37
  %39 = getelementptr inbounds %struct.WbRadarTarget, ptr %38, i32 0, i32 0
  %40 = load double, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.Radar, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.WbRadarTarget, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.WbRadarTarget, ptr %46, i32 0, i32 0
  store double %40, ptr %47, align 8, !tbaa !17
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.WbRadarTarget, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct.WbRadarTarget, ptr %51, i32 0, i32 1
  %53 = load double, ptr %52, align 8, !tbaa !19
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.Radar, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = load i32, ptr %8, align 4, !tbaa !11
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.WbRadarTarget, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.WbRadarTarget, ptr %59, i32 0, i32 1
  store double %53, ptr %60, align 8, !tbaa !19
  %61 = load ptr, ptr %5, align 8, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.WbRadarTarget, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.WbRadarTarget, ptr %64, i32 0, i32 2
  %66 = load double, ptr %65, align 8, !tbaa !20
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.Radar, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load i32, ptr %8, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds %struct.WbRadarTarget, ptr %69, i64 %71
  %73 = getelementptr inbounds %struct.WbRadarTarget, ptr %72, i32 0, i32 2
  store double %66, ptr %73, align 8, !tbaa !20
  %74 = load ptr, ptr %5, align 8, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds %struct.WbRadarTarget, ptr %74, i64 %76
  %78 = getelementptr inbounds %struct.WbRadarTarget, ptr %77, i32 0, i32 3
  %79 = load double, ptr %78, align 8, !tbaa !21
  %80 = load ptr, ptr %7, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.Radar, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %81, align 8, !tbaa !16
  %83 = load i32, ptr %8, align 4, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.WbRadarTarget, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.WbRadarTarget, ptr %85, i32 0, i32 3
  store double %79, ptr %86, align 8, !tbaa !21
  br label %87

87:                                               ; preds = %34
  %88 = load i32, ptr %8, align 4, !tbaa !11
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %8, align 4, !tbaa !11
  br label %28, !llvm.loop !22

90:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %94

91:                                               ; preds = %3
  %92 = load ptr, ptr @stderr, align 8, !tbaa !9
  %93 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %92, ptr noundef @.str, ptr noundef @__FUNCTION__.wbr_radar_set_targets) #4
  br label %94

94:                                               ; preds = %91, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @radar_get_struct(i16 noundef zeroext) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"", !7, i64 0, !12, i64 4, !12, i64 8, !10, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !10, i64 16}
!17 = !{!18, !15, i64 0}
!18 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!19 = !{!18, !15, i64 8}
!20 = !{!18, !15, i64 16}
!21 = !{!18, !15, i64 24}
!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.WbRadarTarget = type { double, double, double, double }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@__FUNCTION__.wbr_radar_set_targets = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @wbr_radar_set_targets(i16 noundef zeroext %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @radar_get_struct(i16 noundef zeroext %0)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %27, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %2, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  tail call void @free(ptr noundef %8) #4
  %9 = load i32, ptr %6, align 8, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = shl nsw i64 %10, 5
  %12 = tail call noalias ptr @malloc(i64 noundef %11) #5
  store ptr %12, ptr %7, align 8, !tbaa !12
  %13 = icmp sgt i32 %9, 0
  br i1 %13, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext nneg i32 %9 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %14 = icmp eq i32 %9, 1
  br i1 %14, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %15 = getelementptr inbounds %struct.WbRadarTarget, ptr %1, i64 %indvars.iv
  %16 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv
  %17 = load <2 x double>, ptr %15, align 8, !tbaa !13
  store <2 x double> %17, ptr %16, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %15, i64 16
  %19 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv, i32 2
  %20 = load <2 x double>, ptr %18, align 8, !tbaa !13
  store <2 x double> %20, ptr %19, align 8, !tbaa !13
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = getelementptr inbounds %struct.WbRadarTarget, ptr %1, i64 %indvars.iv.next
  %22 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv.next
  %23 = load <2 x double>, ptr %21, align 8, !tbaa !13
  store <2 x double> %23, ptr %22, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %21, i64 16
  %25 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv.next, i32 2
  %26 = load <2 x double>, ptr %24, align 8, !tbaa !13
  store <2 x double> %26, ptr %25, align 8, !tbaa !13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !14

27:                                               ; preds = %3
  %28 = load ptr, ptr @stderr, align 8, !tbaa !16
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.wbr_radar_set_targets) #6
  br label %.loopexit

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa
  %30 = getelementptr inbounds %struct.WbRadarTarget, ptr %1, i64 %indvars.iv.unr
  %31 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv.unr
  %32 = load <2 x double>, ptr %30, align 8, !tbaa !13
  store <2 x double> %32, ptr %31, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %30, i64 16
  %34 = getelementptr inbounds %struct.WbRadarTarget, ptr %12, i64 %indvars.iv.unr, i32 2
  %35 = load <2 x double>, ptr %33, align 8, !tbaa !13
  store <2 x double> %35, ptr %34, align 8, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.epil, %.loopexit.loopexit.unr-lcssa, %5, %27
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden ptr @radar_get_struct(i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #3 = { nofree 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { cold 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, !9, i64 8}
!6 = !{!"", !7, i64 0, !9, i64 4, !9, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass