; 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._RcsGraph = type { ptr, [10 x %struct._RcsBody], i32, i32, ptr, ptr, ptr, ptr, ptr }
%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
@__func__.RcsGraph_COG = external hidden unnamed_addr constant [13 x i8], align 1
@.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

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

; Function Attrs: nounwind uwtable
define dso_local double @RcsGraph_COG(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
  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
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Vec3d_setZero(ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._RcsGraph, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  store ptr %11, ptr %7, align 8, !tbaa !5
  br label %12

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

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

16:                                               ; preds = %12
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._RcsBody, ptr %17, i32 0, i32 0
  %19 = load double, ptr %18, align 8, !tbaa !14
  %20 = fcmp ogt double %19, 0.000000e+00
  br i1 %20, label %21, label %50

21:                                               ; preds = %16
  %22 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._RcsBody, ptr %23, i32 0, i32 10
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = getelementptr inbounds %struct.HTr, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds [3 x [3 x double]], ptr %26, i64 0, i64 0
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._RcsBody, ptr %28, i32 0, i32 11
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = getelementptr inbounds %struct.HTr, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds [3 x double], ptr %31, i64 0, i64 0
  call void @Vec3d_transRotate(ptr noundef %22, ptr noundef %27, ptr noundef %32)
  %33 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._RcsBody, ptr %34, i32 0, i32 10
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = getelementptr inbounds %struct.HTr, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds [3 x double], ptr %37, i64 0, i64 0
  call void @Vec3d_addSelf(ptr noundef %33, ptr noundef %38)
  %39 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._RcsBody, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !14
  call void @Vec3d_constMulSelf(ptr noundef %39, double noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  call void @Vec3d_addSelf(ptr noundef %43, ptr noundef %44)
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._RcsBody, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !14
  %48 = load double, ptr %6, align 8, !tbaa !9
  %49 = fadd double %48, %47
  store double %49, ptr %6, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %21, %16
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %52)
  store ptr %53, ptr %7, align 8, !tbaa !5
  br label %12, !llvm.loop !19

54:                                               ; preds = %15
  %55 = load double, ptr %6, align 8, !tbaa !9
  %56 = fcmp ogt double %55, 0.000000e+00
  br i1 %56, label %57, label %61

57:                                               ; preds = %54
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load double, ptr %6, align 8, !tbaa !9
  %60 = fdiv double 1.000000e+00, %59
  call void @Vec3d_constMulSelf(ptr noundef %58, double noundef %60)
  br label %80

61:                                               ; preds = %54
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %67

65:                                               ; preds = %62
  %66 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %66(i32 noundef 1, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COG, i32 noundef 929, ptr noundef @.str.3)
  br label %67

67:                                               ; preds = %65, %62
  %68 = load i32, ptr @RcsLogLevel, align 4, !tbaa !21
  %69 = icmp sle i32 1, %68
  br i1 %69, label %70, label %77

70:                                               ; preds = %67
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.4, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COG, i32 noundef 929) #4
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.3) #4
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.5) #4
  br label %77

77:                                               ; preds = %70, %67
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79, %57
  %81 = 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 %81
}

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

declare ptr @RcsBody_depthFirstTraversalGetNext(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, !6, i64 0}
!12 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !13, i64 1848, !13, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"_RcsBody", !10, i64 0, !16, i64 8, !13, 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}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!15, !6, i64 104}
!18 = !{!15, !6, i64 112}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!13, !13, 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
@__func__.RcsGraph_COG = external hidden unnamed_addr constant [13 x i8], align 1
@.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

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

; Function Attrs: nounwind uwtable
define dso_local double @RcsGraph_COG(ptr nocapture noundef readonly %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 = load ptr, ptr %0, align 8, !tbaa !5
  %.not19 = icmp eq ptr %4, null
  br i1 %.not19, label %._crit_edge.thread, label %.lr.ph

._crit_edge:                                      ; preds = %18
  %5 = fcmp ogt double %.1, 0.000000e+00
  br i1 %5, label %20, label %._crit_edge.thread

.lr.ph:                                           ; preds = %2, %18
  %.021 = phi ptr [ %19, %18 ], [ %4, %2 ]
  %.01620 = phi double [ %.1, %18 ], [ 0.000000e+00, %2 ]
  %6 = load double, ptr %.021, align 8, !tbaa !11
  %7 = fcmp ogt double %6, 0.000000e+00
  br i1 %7, label %8, label %18

8:                                                ; preds = %.lr.ph
  %9 = getelementptr inbounds i8, ptr %.021, i64 104
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  %12 = getelementptr inbounds i8, ptr %.021, i64 112
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  call void @Vec3d_transRotate(ptr noundef nonnull %3, ptr noundef nonnull %11, ptr noundef %13) #4
  %14 = load ptr, ptr %9, align 8, !tbaa !15
  call void @Vec3d_addSelf(ptr noundef nonnull %3, ptr noundef %14) #4
  %15 = load double, ptr %.021, align 8, !tbaa !11
  call void @Vec3d_constMulSelf(ptr noundef nonnull %3, double noundef %15) #4
  call void @Vec3d_addSelf(ptr noundef %1, ptr noundef nonnull %3) #4
  %16 = load double, ptr %.021, align 8, !tbaa !11
  %17 = fadd double %.01620, %16
  br label %18

18:                                               ; preds = %.lr.ph, %8
  %.1 = phi double [ %17, %8 ], [ %.01620, %.lr.ph ]
  %19 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.021) #4
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

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

._crit_edge.thread:                               ; preds = %2, %._crit_edge
  %.016.lcssa24 = phi double [ %.1, %._crit_edge ], [ 0.000000e+00, %2 ]
  %22 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !19
  %.not18 = icmp eq ptr %22, null
  br i1 %.not18, label %24, label %23

23:                                               ; preds = %._crit_edge.thread
  call void (i32, ptr, ptr, i32, ptr, ...) %22(i32 noundef 1, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COG, i32 noundef 929, ptr noundef nonnull @.str.3) #4
  br label %24

24:                                               ; preds = %23, %._crit_edge.thread
  %25 = load i32, ptr @RcsLogLevel, align 4, !tbaa !20
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = load ptr, ptr @stderr, align 8, !tbaa !19
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COG, i32 noundef 929) #5
  %30 = load ptr, ptr @stderr, align 8, !tbaa !19
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.3) #5
  %32 = load ptr, ptr @stderr, align 8, !tbaa !19
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.5) #5
  br label %34

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

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

declare ptr @RcsBody_depthFirstTraversalGetNext(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 = !{!"_RcsGraph", !7, i64 0, !8, i64 8, !10, i64 1848, !10, i64 1852, !7, i64 1856, !7, i64 1864, !7, i64 1872, !7, i64 1880, !7, i64 1888}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_RcsBody", !13, i64 0, !14, i64 8, !10, i64 12, !8, i64 16, !8, i64 40, !13, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176}
!13 = !{!"double", !8, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!12, !7, i64 104}
!16 = !{!12, !7, i64 112}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!7, !7, i64 0}
!20 = !{!10, !10, i64 0}


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