; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_joint)

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @RcsJoint_isTranslation(ptr noundef) #0

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare void @Vec3d_constMulSelf(ptr noundef, double noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @RcsJoint_scale(ptr noundef %0, double noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._RcsJoint, ptr %7, i32 0, i32 13
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %18

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._RcsJoint, ptr %12, i32 0, i32 13
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds %struct.HTr, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  %17 = load double, ptr %4, align 8, !tbaa !9
  call void @Vec3d_constMulSelf(ptr noundef %16, double noundef %17)
  br label %18

18:                                               ; preds = %11, %2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call zeroext i1 @RcsJoint_isTranslation(ptr noundef %19)
  %21 = zext i1 %20 to i32
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %65

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._RcsJoint, ptr %24, i32 0, i32 4
  %26 = load double, ptr %25, align 8, !tbaa !16
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._RcsJoint, ptr %27, i32 0, i32 1
  %29 = load double, ptr %28, align 8, !tbaa !17
  %30 = fsub double %26, %29
  store double %30, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._RcsJoint, ptr %31, i32 0, i32 1
  %33 = load double, ptr %32, align 8, !tbaa !17
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._RcsJoint, ptr %34, i32 0, i32 3
  %36 = load double, ptr %35, align 8, !tbaa !18
  %37 = fsub double %33, %36
  store double %37, ptr %6, align 8, !tbaa !9
  %38 = load double, ptr %4, align 8, !tbaa !9
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._RcsJoint, ptr %39, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !17
  %42 = fmul double %41, %38
  store double %42, ptr %40, align 8, !tbaa !17
  %43 = load double, ptr %4, align 8, !tbaa !9
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._RcsJoint, ptr %44, i32 0, i32 2
  %46 = load double, ptr %45, align 8, !tbaa !19
  %47 = fmul double %46, %43
  store double %47, ptr %45, align 8, !tbaa !19
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._RcsJoint, ptr %48, i32 0, i32 1
  %50 = load double, ptr %49, align 8, !tbaa !17
  %51 = load double, ptr %4, align 8, !tbaa !9
  %52 = load double, ptr %6, align 8, !tbaa !9
  %53 = fneg double %51
  %54 = call double @llvm.fmuladd.f64(double %53, double %52, double %50)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._RcsJoint, ptr %55, i32 0, i32 3
  store double %54, ptr %56, align 8, !tbaa !18
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._RcsJoint, ptr %57, i32 0, i32 1
  %59 = load double, ptr %58, align 8, !tbaa !17
  %60 = load double, ptr %4, align 8, !tbaa !9
  %61 = load double, ptr %5, align 8, !tbaa !9
  %62 = call double @llvm.fmuladd.f64(double %60, double %61, double %59)
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._RcsJoint, ptr %63, i32 0, i32 4
  store double %62, ptr %64, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %65

65:                                               ; preds = %23, %18
  ret void
}

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 = { "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 = !{!"any pointer", !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, !6, i64 88}
!12 = !{!"_RcsJoint", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !13, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !14, i64 80, !6, i64 88, !15, i64 96, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !14, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 24}
!19 = !{!12, !10, i64 16}


; 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: nounwind uwtable
declare dso_local zeroext i1 @RcsJoint_isTranslation(ptr noundef) local_unnamed_addr #0

declare void @Vec3d_constMulSelf(ptr noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @RcsJoint_scale(ptr noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %6, label %5

5:                                                ; preds = %2
  tail call void @Vec3d_constMulSelf(ptr noundef nonnull %4, double noundef %1) #3
  br label %6

6:                                                ; preds = %5, %2
  %7 = tail call zeroext i1 @RcsJoint_isTranslation(ptr noundef nonnull %0)
  br i1 %7, label %8, label %27

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load double, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load double, ptr %12, align 8, !tbaa !15
  %14 = load <2 x double>, ptr %11, align 8, !tbaa !16
  %15 = insertelement <2 x double> poison, double %1, i64 0
  %16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
  %17 = fmul <2 x double> %14, %16
  store <2 x double> %17, ptr %11, align 8, !tbaa !16
  %18 = fneg double %1
  %19 = insertelement <2 x double> %14, double %10, i64 1
  %20 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %21 = insertelement <2 x double> %20, double %13, i64 0
  %22 = fsub <2 x double> %19, %21
  %23 = insertelement <2 x double> poison, double %18, i64 0
  %24 = insertelement <2 x double> %23, double %1, i64 1
  %25 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
  %26 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %22, <2 x double> %25)
  store <2 x double> %26, ptr %12, align 8, !tbaa !16
  br label %27

27:                                               ; preds = %8, %6
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 88}
!6 = !{!"_RcsJoint", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !11, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !7, i64 88, !13, i64 96, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !12, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !8, i64 0, !8, i64 24}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 24}
!16 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass