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

; 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.Skin = type { ptr, ptr, i32, ptr, ptr, ptr }
%struct.BoneRequest = type { i32, i32, [4 x double], i8, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [50 x i8], align 1
@__FUNCTION__.wb_skin_set_bone_orientation = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

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

13:                                               ; preds = %27, %4
  %14 = load i32, ptr %9, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %16, label %30

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !11
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds double, ptr %17, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !14
  %22 = call i1 @llvm.is.fpclass.f64(double %21, i32 3)
  br i1 %22, label %23, label %26

23:                                               ; preds = %16
  %24 = load ptr, ptr @stderr, align 8, !tbaa !11
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str, ptr noundef @__FUNCTION__.wb_skin_set_bone_orientation) #6
  store i32 1, ptr %10, align 4
  br label %108

26:                                               ; preds = %16
  br label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %9, align 4, !tbaa !9
  br label %13, !llvm.loop !16

30:                                               ; preds = %13
  %31 = load ptr, ptr %7, align 8, !tbaa !11
  %32 = getelementptr inbounds double, ptr %31, i64 0
  %33 = load double, ptr %32, align 8, !tbaa !14
  %34 = fcmp oeq double %33, 0.000000e+00
  br i1 %34, label %35, label %48

35:                                               ; preds = %30
  %36 = load ptr, ptr %7, align 8, !tbaa !11
  %37 = getelementptr inbounds double, ptr %36, i64 1
  %38 = load double, ptr %37, align 8, !tbaa !14
  %39 = fcmp oeq double %38, 0.000000e+00
  br i1 %39, label %40, label %48

40:                                               ; preds = %35
  %41 = load ptr, ptr %7, align 8, !tbaa !11
  %42 = getelementptr inbounds double, ptr %41, i64 2
  %43 = load double, ptr %42, align 8, !tbaa !14
  %44 = fcmp oeq double %43, 0.000000e+00
  br i1 %44, label %45, label %48

45:                                               ; preds = %40
  %46 = load ptr, ptr @stderr, align 8, !tbaa !11
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.1, ptr noundef @__FUNCTION__.wb_skin_set_bone_orientation) #6
  store i32 1, ptr %10, align 4
  br label %108

48:                                               ; preds = %40, %35, %30
  call void (...) @robot_mutex_lock()
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %49 = load i16, ptr %5, align 2, !tbaa !5
  %50 = call ptr @skin_get_struct(i16 noundef zeroext %49)
  store ptr %50, ptr %11, align 8, !tbaa !11
  %51 = load ptr, ptr %11, align 8, !tbaa !11
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %103

53:                                               ; preds = %48
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = icmp slt i32 %54, 0
  br i1 %55, label %62, label %56

56:                                               ; preds = %53
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = load ptr, ptr %11, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct.Skin, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 8, !tbaa !18
  %61 = icmp sge i32 %57, %60
  br i1 %61, label %62, label %65

62:                                               ; preds = %56, %53
  %63 = load ptr, ptr @stderr, align 8, !tbaa !11
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.2, ptr noundef @__FUNCTION__.wb_skin_set_bone_orientation) #6
  call void (...) @robot_mutex_unlock()
  store i32 1, ptr %10, align 4
  br label %107

65:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %66 = call noalias ptr @malloc(i64 noundef 56) #7
  store ptr %66, ptr %12, align 8, !tbaa !11
  %67 = load ptr, ptr %12, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.BoneRequest, ptr %67, i32 0, i32 0
  store i32 1, ptr %68, align 8, !tbaa !20
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = load ptr, ptr %12, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.BoneRequest, ptr %70, i32 0, i32 1
  store i32 %69, ptr %71, align 4, !tbaa !22
  %72 = load ptr, ptr %7, align 8, !tbaa !11
  %73 = getelementptr inbounds double, ptr %72, i64 0
  %74 = load double, ptr %73, align 8, !tbaa !14
  %75 = load ptr, ptr %12, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct.BoneRequest, ptr %75, i32 0, i32 2
  %77 = getelementptr inbounds [4 x double], ptr %76, i64 0, i64 0
  store double %74, ptr %77, align 8, !tbaa !14
  %78 = load ptr, ptr %7, align 8, !tbaa !11
  %79 = getelementptr inbounds double, ptr %78, i64 1
  %80 = load double, ptr %79, align 8, !tbaa !14
  %81 = load ptr, ptr %12, align 8, !tbaa !11
  %82 = getelementptr inbounds %struct.BoneRequest, ptr %81, i32 0, i32 2
  %83 = getelementptr inbounds [4 x double], ptr %82, i64 0, i64 1
  store double %80, ptr %83, align 8, !tbaa !14
  %84 = load ptr, ptr %7, align 8, !tbaa !11
  %85 = getelementptr inbounds double, ptr %84, i64 2
  %86 = load double, ptr %85, align 8, !tbaa !14
  %87 = load ptr, ptr %12, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.BoneRequest, ptr %87, i32 0, i32 2
  %89 = getelementptr inbounds [4 x double], ptr %88, i64 0, i64 2
  store double %86, ptr %89, align 8, !tbaa !14
  %90 = load ptr, ptr %7, align 8, !tbaa !11
  %91 = getelementptr inbounds double, ptr %90, i64 3
  %92 = load double, ptr %91, align 8, !tbaa !14
  %93 = load ptr, ptr %12, align 8, !tbaa !11
  %94 = getelementptr inbounds %struct.BoneRequest, ptr %93, i32 0, i32 2
  %95 = getelementptr inbounds [4 x double], ptr %94, i64 0, i64 3
  store double %92, ptr %95, align 8, !tbaa !14
  %96 = load i8, ptr %8, align 1, !tbaa !13
  %97 = load ptr, ptr %12, align 8, !tbaa !11
  %98 = getelementptr inbounds %struct.BoneRequest, ptr %97, i32 0, i32 3
  store i8 %96, ptr %98, align 8, !tbaa !23
  %99 = load ptr, ptr %12, align 8, !tbaa !11
  %100 = getelementptr inbounds %struct.BoneRequest, ptr %99, i32 0, i32 4
  store ptr null, ptr %100, align 8, !tbaa !24
  %101 = load ptr, ptr %11, align 8, !tbaa !11
  %102 = load ptr, ptr %12, align 8, !tbaa !11
  call void @add_request(ptr noundef %101, ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %106

103:                                              ; preds = %48
  %104 = load ptr, ptr @stderr, align 8, !tbaa !11
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %104, ptr noundef @.str.3, ptr noundef @__FUNCTION__.wb_skin_set_bone_orientation) #6
  br label %106

106:                                              ; preds = %103, %65
  call void @wb_robot_flush_unlocked(ptr noundef @__FUNCTION__.wb_skin_set_bone_orientation)
  call void (...) @robot_mutex_unlock()
  store i32 0, ptr %10, align 4
  br label %107

107:                                              ; preds = %106, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %108

108:                                              ; preds = %107, %45, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %109 = load i32, ptr %10, align 4
  switch i32 %109, label %111 [
    i32 0, label %110
    i32 1, label %110
  ]

110:                                              ; preds = %108, %108
  ret void

111:                                              ; preds = %108
  unreachable
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f64(double, i32 immarg) #2

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

declare void @robot_mutex_lock(...) #4

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

declare void @robot_mutex_unlock(...) #4

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

; Function Attrs: nounwind uwtable
declare hidden void @add_request(ptr noundef, ptr noundef) #0

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

declare void @wb_robot_flush_unlocked(ptr noundef) #4

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { "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) "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 #6 = { nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !10, i64 16}
!19 = !{!"", !12, i64 0, !12, i64 8, !10, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!20 = !{!21, !10, i64 0}
!21 = !{!"BoneRequest", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 40, !12, i64 48}
!22 = !{!21, !10, i64 4}
!23 = !{!21, !7, i64 40}
!24 = !{!21, !12, i64 48}


; 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 [50 x i8], align 1
@__FUNCTION__.wb_skin_set_bone_orientation = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @wb_skin_set_bone_orientation(i16 noundef zeroext %0, i32 noundef %1, ptr nocapture noundef readonly %2, i8 noundef signext %3) local_unnamed_addr #0 {
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = fcmp uno double %5, 0.000000e+00
  br i1 %6, label %23, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fcmp uno double %9, 0.000000e+00
  br i1 %10, label %23, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fcmp uno double %13, 0.000000e+00
  br i1 %14, label %23, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %2, i64 24
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fcmp uno double %17, 0.000000e+00
  br i1 %18, label %23, label %19

19:                                               ; preds = %15
  %20 = fcmp oeq double %5, 0.000000e+00
  %21 = fcmp oeq double %9, 0.000000e+00
  %or.cond = and i1 %20, %21
  %22 = fcmp oeq double %13, 0.000000e+00
  %or.cond32 = and i1 %or.cond, %22
  br i1 %or.cond32, label %26, label %29

23:                                               ; preds = %15, %11, %7, %4
  %24 = load ptr, ptr @stderr, align 8, !tbaa !9
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__.wb_skin_set_bone_orientation) #4
  br label %52

26:                                               ; preds = %19
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__.wb_skin_set_bone_orientation) #4
  br label %52

29:                                               ; preds = %19
  tail call void (...) @robot_mutex_lock() #5
  %30 = tail call ptr @skin_get_struct(i16 noundef zeroext %0)
  %.not = icmp eq ptr %30, null
  br i1 %.not, label %48, label %31

31:                                               ; preds = %29
  %32 = icmp slt i32 %1, 0
  br i1 %32, label %36, label %33

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %30, i64 16
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %.not29 = icmp sgt i32 %35, %1
  br i1 %.not29, label %39, label %36

36:                                               ; preds = %33, %31
  %37 = load ptr, ptr @stderr, align 8, !tbaa !9
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.wb_skin_set_bone_orientation) #4
  tail call void (...) @robot_mutex_unlock() #5
  br label %52

39:                                               ; preds = %33
  %40 = tail call noalias dereferenceable_or_null(56) ptr @malloc(i64 noundef 56) #6
  store i32 1, ptr %40, align 8, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %40, i64 4
  store i32 %1, ptr %41, align 4, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %40, i64 8
  %43 = load <2 x double>, ptr %2, align 8, !tbaa !5
  store <2 x double> %43, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %40, i64 24
  %45 = load <2 x double>, ptr %12, align 8, !tbaa !5
  store <2 x double> %45, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %40, i64 40
  store i8 %3, ptr %46, align 8, !tbaa !17
  %47 = getelementptr inbounds i8, ptr %40, i64 48
  store ptr null, ptr %47, align 8, !tbaa !18
  tail call void @add_request(ptr noundef nonnull %30, ptr noundef nonnull %40)
  br label %51

48:                                               ; preds = %29
  %49 = load ptr, ptr @stderr, align 8, !tbaa !9
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.3, ptr noundef nonnull @__FUNCTION__.wb_skin_set_bone_orientation) #4
  br label %51

51:                                               ; preds = %48, %39
  tail call void @wb_robot_flush_unlocked(ptr noundef nonnull @__FUNCTION__.wb_skin_set_bone_orientation) #5
  tail call void (...) @robot_mutex_unlock() #5
  br label %52

52:                                               ; preds = %36, %51, %26, %23
  ret void
}

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @add_request(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @wb_robot_flush_unlocked(ptr noundef) local_unnamed_addr #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 = { 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 #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 = { 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 #4 = { cold nounwind }
attributes #5 = { nounwind }
attributes #6 = { 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 = !{!"double", !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, !13, i64 16}
!12 = !{!"", !10, i64 0, !10, i64 8, !13, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"BoneRequest", !13, i64 0, !13, i64 4, !7, i64 8, !7, i64 40, !10, i64 48}
!16 = !{!15, !13, i64 4}
!17 = !{!15, !7, i64 40}
!18 = !{!15, !10, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass