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

; 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.Lidar = type { double, i32, i32, double, double, double, double, i8, i8, i8, i8 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@__FUNCTION__.wb_lidar_set_frequency = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1

; 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 i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare void @robot_mutex_lock(...) #2

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

declare void @robot_mutex_unlock(...) #2

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

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !11
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str, ptr noundef @__FUNCTION__.wb_lidar_set_frequency) #4
  br label %41

13:                                               ; preds = %2
  %14 = load double, ptr %4, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.Lidar, ptr %15, i32 0, i32 4
  %17 = load double, ptr %16, align 8, !tbaa !13
  %18 = fcmp olt double %14, %17
  br i1 %18, label %25, label %19

19:                                               ; preds = %13
  %20 = load double, ptr %4, align 8, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.Lidar, ptr %21, i32 0, i32 5
  %23 = load double, ptr %22, align 8, !tbaa !16
  %24 = fcmp ogt double %20, %23
  br i1 %24, label %25, label %34

25:                                               ; preds = %19, %13
  %26 = load ptr, ptr @stderr, align 8, !tbaa !11
  %27 = load ptr, ptr %5, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.Lidar, ptr %27, i32 0, i32 4
  %29 = load double, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %5, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.Lidar, ptr %30, i32 0, i32 5
  %32 = load double, ptr %31, align 8, !tbaa !16
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.3, ptr noundef @__FUNCTION__.wb_lidar_set_frequency, double noundef %29, double noundef %32) #4
  br label %40

34:                                               ; preds = %19
  %35 = load double, ptr %4, align 8, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.Lidar, ptr %36, i32 0, i32 3
  store double %35, ptr %37, align 8, !tbaa !17
  %38 = load ptr, ptr %5, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.Lidar, ptr %38, i32 0, i32 8
  store i8 1, ptr %39, align 1, !tbaa !18
  br label %40

40:                                               ; preds = %34, %25
  br label %41

41:                                               ; preds = %40, %10
  call void (...) @robot_mutex_unlock()
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  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 = { "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 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 #4 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"", !10, i64 0, !15, i64 8, !15, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !10, i64 32}
!17 = !{!14, !10, i64 16}
!18 = !{!14, !7, i64 49}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@__FUNCTION__.wb_lidar_set_frequency = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1

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

declare void @robot_mutex_lock(...) local_unnamed_addr #1

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

declare void @robot_mutex_unlock(...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @wb_lidar_set_frequency(i16 noundef zeroext %0, double noundef %1) local_unnamed_addr #2 {
  tail call void (...) @robot_mutex_lock() #3
  %3 = tail call ptr @lidar_get_struct(i16 noundef zeroext %0)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %7

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.wb_lidar_set_frequency) #4
  br label %17

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %3, i64 24
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = fcmp ogt double %9, %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %3, i64 32
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !13
  %11 = fcmp olt double %.pre, %1
  %or.cond = select i1 %10, i1 true, i1 %11
  br i1 %or.cond, label %._crit_edge, label %14

._crit_edge:                                      ; preds = %7
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.3, ptr noundef nonnull @__FUNCTION__.wb_lidar_set_frequency, double noundef %9, double noundef %.pre) #4
  br label %17

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %3, i64 16
  store double %1, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %3, i64 49
  store i8 1, ptr %16, align 1, !tbaa !15
  br label %17

17:                                               ; preds = %._crit_edge, %14, %4
  tail call void (...) @robot_mutex_unlock() #3
  ret void
}

attributes #0 = { 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 #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 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 }
attributes #4 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"", !11, i64 0, !12, i64 8, !12, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !7, i64 49}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass