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

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

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [53 x i8], align 1
@RcsLogLevel = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.RcsGraph_COG_Body = external hidden unnamed_addr constant [18 x i8], align 1

declare void @Vec3d_setZero(ptr noundef) #0

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

declare void @Vec3d_transRotate(ptr noundef, ptr noundef, ptr noundef) #0

declare void @Vec3d_addSelf(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

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

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local double @RcsGraph_COG_Body(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [3 x double], align 16
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Vec3d_setZero(ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = call ptr @RcsBody_getLastChild(ptr noundef %11)
  %13 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %12)
  store ptr %13, ptr %8, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %59, %2
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %18, %19
  br label %21

21:                                               ; preds = %17, %14
  %22 = phi i1 [ false, %14 ], [ %20, %17 ]
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %62

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._RcsBody, ptr %25, i32 0, i32 0
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = fcmp ogt double %27, 0.000000e+00
  br i1 %28, label %29, label %58

29:                                               ; preds = %24
  %30 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._RcsBody, ptr %31, i32 0, i32 10
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = getelementptr inbounds %struct.HTr, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds [3 x [3 x double]], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._RcsBody, ptr %36, i32 0, i32 11
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = getelementptr inbounds %struct.HTr, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds [3 x double], ptr %39, i64 0, i64 0
  call void @Vec3d_transRotate(ptr noundef %30, ptr noundef %35, ptr noundef %40)
  %41 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._RcsBody, ptr %42, i32 0, i32 10
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = getelementptr inbounds %struct.HTr, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds [3 x double], ptr %45, i64 0, i64 0
  call void @Vec3d_addSelf(ptr noundef %41, ptr noundef %46)
  %47 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._RcsBody, ptr %48, i32 0, i32 0
  %50 = load double, ptr %49, align 8, !tbaa !11
  call void @Vec3d_constMulSelf(ptr noundef %47, double noundef %50)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  call void @Vec3d_addSelf(ptr noundef %51, ptr noundef %52)
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._RcsBody, ptr %53, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = load double, ptr %6, align 8, !tbaa !9
  %57 = fadd double %56, %55
  store double %57, ptr %6, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %29, %24
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %60)
  store ptr %61, ptr %7, align 8, !tbaa !5
  br label %14, !llvm.loop !17

62:                                               ; preds = %23
  %63 = load double, ptr %6, align 8, !tbaa !9
  %64 = fcmp ogt double %63, 0.000000e+00
  br i1 %64, label %65, label %69

65:                                               ; preds = %62
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load double, ptr %6, align 8, !tbaa !9
  %68 = fdiv double 1.000000e+00, %67
  call void @Vec3d_constMulSelf(ptr noundef %66, double noundef %68)
  br label %88

69:                                               ; preds = %62
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %75

73:                                               ; preds = %70
  %74 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %74(i32 noundef 1, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COG_Body, i32 noundef 963, ptr noundef @.str.3)
  br label %75

75:                                               ; preds = %73, %70
  %76 = load i32, ptr @RcsLogLevel, align 4, !tbaa !19
  %77 = icmp sle i32 1, %76
  br i1 %77, label %78, label %85

78:                                               ; preds = %75
  %79 = load ptr, ptr @stderr, align 8, !tbaa !5
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef @.str.4, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COG_Body, i32 noundef 963) #4
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.3) #4
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.5) #4
  br label %85

85:                                               ; preds = %78, %75
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87, %65
  %89 = load double, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  ret double %89
}

declare ptr @RcsBody_getLastChild(ptr noundef) #0

attributes #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 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 = !{!"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, !10, i64 0}
!12 = !{!"_RcsBody", !10, i64 0, !13, i64 8, !14, i64 12, !7, i64 16, !7, i64 40, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 104}
!16 = !{!12, !6, i64 112}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!14, !14, i64 0}


; 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.1 = external hidden unnamed_addr constant [73 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [53 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.RcsGraph_COG_Body = external hidden unnamed_addr constant [18 x i8], align 1

declare void @Vec3d_setZero(ptr noundef) local_unnamed_addr #0

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

declare void @Vec3d_transRotate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @Vec3d_addSelf(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @RcsGraph_COG_Body(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  tail call void @Vec3d_setZero(ptr noundef %1) #4
  %4 = tail call ptr @RcsBody_getLastChild(ptr noundef %0) #4
  %5 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %4) #4
  %6 = icmp ne ptr %0, null
  %7 = icmp ne ptr %5, %0
  %8 = select i1 %6, i1 %7, i1 false
  br i1 %8, label %.lr.ph, label %._crit_edge.thread

._crit_edge:                                      ; preds = %22
  %9 = fcmp ogt double %.1, 0.000000e+00
  br i1 %9, label %27, label %._crit_edge.thread

.lr.ph:                                           ; preds = %2, %22
  %.022 = phi double [ %.1, %22 ], [ 0.000000e+00, %2 ]
  %.01921 = phi ptr [ %23, %22 ], [ %0, %2 ]
  %10 = load double, ptr %.01921, align 8, !tbaa !5
  %11 = fcmp ogt double %10, 0.000000e+00
  br i1 %11, label %12, label %22

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %.01921, i64 104
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = getelementptr inbounds i8, ptr %.01921, i64 112
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  call void @Vec3d_transRotate(ptr noundef nonnull %3, ptr noundef nonnull %15, ptr noundef %17) #4
  %18 = load ptr, ptr %13, align 8, !tbaa !13
  call void @Vec3d_addSelf(ptr noundef nonnull %3, ptr noundef %18) #4
  %19 = load double, ptr %.01921, align 8, !tbaa !5
  call void @Vec3d_constMulSelf(ptr noundef nonnull %3, double noundef %19) #4
  call void @Vec3d_addSelf(ptr noundef %1, ptr noundef nonnull %3) #4
  %20 = load double, ptr %.01921, align 8, !tbaa !5
  %21 = fadd double %.022, %20
  br label %22

22:                                               ; preds = %.lr.ph, %12
  %.1 = phi double [ %21, %12 ], [ %.022, %.lr.ph ]
  %23 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.01921) #4
  %24 = icmp ne ptr %23, null
  %25 = icmp ne ptr %23, %5
  %26 = select i1 %24, i1 %25, i1 false
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !15

27:                                               ; preds = %._crit_edge
  %28 = fdiv double 1.000000e+00, %.1
  call void @Vec3d_constMulSelf(ptr noundef %1, double noundef %28) #4
  br label %41

._crit_edge.thread:                               ; preds = %2, %._crit_edge
  %.0.lcssa25 = phi double [ %.1, %._crit_edge ], [ 0.000000e+00, %2 ]
  %29 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !17
  %.not = icmp eq ptr %29, null
  br i1 %.not, label %31, label %30

30:                                               ; preds = %._crit_edge.thread
  call void (i32, ptr, ptr, i32, ptr, ...) %29(i32 noundef 1, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COG_Body, i32 noundef 963, ptr noundef nonnull @.str.3) #4
  br label %31

31:                                               ; preds = %30, %._crit_edge.thread
  %32 = load i32, ptr @RcsLogLevel, align 4, !tbaa !18
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %41

34:                                               ; preds = %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !17
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COG_Body, i32 noundef 963) #5
  %37 = load ptr, ptr @stderr, align 8, !tbaa !17
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.3) #5
  %39 = load ptr, ptr @stderr, align 8, !tbaa !17
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.5) #5
  br label %41

41:                                               ; preds = %31, %34, %27
  %.0.lcssa24 = phi double [ %.0.lcssa25, %31 ], [ %.0.lcssa25, %34 ], [ %.1, %27 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  ret double %.0.lcssa24
}

declare ptr @RcsBody_getLastChild(ptr noundef) local_unnamed_addr #0

attributes #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"_RcsBody", !7, i64 0, !10, i64 8, !11, i64 12, !8, i64 16, !8, i64 40, !7, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !12, i64 104}
!14 = !{!6, !12, i64 112}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !12, i64 0}
!18 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass