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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.RcsGraph_computeCOGHessian_Body_ = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 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 uwtable
declare dso_local void @RcsGraph_bodyPointHessian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) #2

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

declare void @print_trace() #2

; Function Attrs: noreturn nounwind
declare void @abort() #4

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #2

declare ptr @RcsBody_getLastChild(ptr noundef) #2

declare void @MatNd_constMulSelf(ptr noundef, double noundef) #2

declare void @MatNd_setZero(ptr noundef) #2

declare void @MatNd_constMulAndAddSelf(ptr noundef, ptr noundef, double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_computeCOGHessian_Body_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._RcsGraph, ptr %13, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %15, ptr %9, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._MatNd, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = load i32, ptr %9, align 4, !tbaa !12
  %21 = mul nsw i32 3, %20
  %22 = load i32, ptr %9, align 4, !tbaa !12
  %23 = mul nsw i32 %21, %22
  %24 = icmp sge i32 %19, %23
  br i1 %24, label %28, label %25

25:                                               ; preds = %16
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_computeCOGHessian_Body_, i32 noundef 1121, ptr noundef @.str.8) #5
  call void @print_trace()
  call void @abort() #6
  unreachable

28:                                               ; preds = %16
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !12
  %33 = mul nsw i32 3, %32
  %34 = load i32, ptr %9, align 4, !tbaa !12
  call void @MatNd_reshape(ptr noundef %31, i32 noundef %33, i32 noundef %34)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_setZero(ptr noundef %35)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %36, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = call ptr @RcsBody_getLastChild(ptr noundef %37)
  %39 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %38)
  store ptr %39, ptr %12, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %75, %30
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %47

43:                                               ; preds = %40
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = icmp ne ptr %44, %45
  br label %47

47:                                               ; preds = %43, %40
  %48 = phi i1 [ false, %40 ], [ %46, %43 ]
  br i1 %48, label %50, label %49

49:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %78

50:                                               ; preds = %47
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._RcsBody, ptr %51, i32 0, i32 0
  %53 = load double, ptr %52, align 8, !tbaa !18
  %54 = fcmp ogt double %53, 0.000000e+00
  br i1 %54, label %55, label %74

55:                                               ; preds = %50
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._RcsBody, ptr %58, i32 0, i32 11
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  %61 = getelementptr inbounds %struct.HTr, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 0
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  call void @RcsGraph_bodyPointHessian(ptr noundef %56, ptr noundef %57, ptr noundef %62, ptr noundef null, ptr noundef %63)
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._RcsBody, ptr %66, i32 0, i32 0
  %68 = load double, ptr %67, align 8, !tbaa !18
  call void @MatNd_constMulAndAddSelf(ptr noundef %64, ptr noundef %65, double noundef %68)
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._RcsBody, ptr %69, i32 0, i32 0
  %71 = load double, ptr %70, align 8, !tbaa !18
  %72 = load double, ptr %10, align 8, !tbaa !13
  %73 = fadd double %72, %71
  store double %73, ptr %10, align 8, !tbaa !13
  br label %74

74:                                               ; preds = %55, %50
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %76)
  store ptr %77, ptr %11, align 8, !tbaa !5
  br label %40, !llvm.loop !21

78:                                               ; preds = %49
  %79 = load double, ptr %10, align 8, !tbaa !13
  %80 = fcmp ogt double %79, 0.000000e+00
  br i1 %80, label %81, label %85

81:                                               ; preds = %78
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load double, ptr %10, align 8, !tbaa !13
  %84 = fdiv double 1.000000e+00, %83
  call void @MatNd_constMulSelf(ptr noundef %82, double noundef %84)
  br label %85

85:                                               ; preds = %81, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = { noreturn 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 #5 = { nounwind }
attributes #6 = { noreturn 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 1852}
!10 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !11, i64 1848, !11, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !11, i64 16}
!16 = !{!"_MatNd", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !17, i64 20}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!19, !14, i64 0}
!19 = !{!"_RcsBody", !14, i64 0, !17, i64 8, !11, i64 12, !7, i64 16, !7, i64 40, !14, 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}
!20 = !{!19, !6, i64 112}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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 [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.RcsGraph_computeCOGHessian_Body_ = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1

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

declare void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

declare void @print_trace() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #1

declare ptr @RcsBody_getLastChild(ptr noundef) local_unnamed_addr #1

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

declare void @MatNd_setZero(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_computeCOGHessian_Body_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 1852
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = mul nsw i32 %6, 3
  %10 = mul nsw i32 %9, %6
  %.not = icmp slt i32 %8, %10
  br i1 %.not, label %11, label %14

11:                                               ; preds = %4
  %12 = load ptr, ptr @stderr, align 8, !tbaa !14
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_computeCOGHessian_Body_, i32 noundef 1121, ptr noundef nonnull @.str.8) #4
  tail call void @print_trace() #5
  tail call void @abort() #6
  unreachable

14:                                               ; preds = %4
  tail call void @MatNd_reshape(ptr noundef %2, i32 noundef %9, i32 noundef %6) #5
  tail call void @MatNd_setZero(ptr noundef %2) #5
  %15 = tail call ptr @RcsBody_getLastChild(ptr noundef %1) #5
  %16 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %15) #5
  %17 = icmp ne ptr %1, null
  %18 = icmp ne ptr %16, %1
  %19 = select i1 %17, i1 %18, i1 false
  br i1 %19, label %.lr.ph, label %._crit_edge.thread

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

.lr.ph:                                           ; preds = %14, %29
  %.028 = phi double [ %.1, %29 ], [ 0.000000e+00, %14 ]
  %.02627 = phi ptr [ %30, %29 ], [ %1, %14 ]
  %21 = load double, ptr %.02627, align 8, !tbaa !15
  %22 = fcmp ogt double %21, 0.000000e+00
  br i1 %22, label %23, label %29

23:                                               ; preds = %.lr.ph
  %24 = getelementptr inbounds i8, ptr %.02627, i64 112
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  tail call void @RcsGraph_bodyPointHessian(ptr noundef %0, ptr noundef nonnull %.02627, ptr noundef %25, ptr noundef null, ptr noundef %3)
  %26 = load double, ptr %.02627, align 8, !tbaa !15
  tail call void @MatNd_constMulAndAddSelf(ptr noundef %2, ptr noundef %3, double noundef %26) #5
  %27 = load double, ptr %.02627, align 8, !tbaa !15
  %28 = fadd double %.028, %27
  br label %29

29:                                               ; preds = %.lr.ph, %23
  %.1 = phi double [ %28, %23 ], [ %.028, %.lr.ph ]
  %30 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.02627) #5
  %31 = icmp ne ptr %30, null
  %32 = icmp ne ptr %30, %16
  %33 = select i1 %31, i1 %32, i1 false
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !19

34:                                               ; preds = %._crit_edge
  %35 = fdiv double 1.000000e+00, %.1
  tail call void @MatNd_constMulSelf(ptr noundef %2, double noundef %35) #5
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %14, %34, %._crit_edge
  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 = { "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 = { 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 = { noreturn 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 = { cold nounwind }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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, !10, i64 1852}
!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, !10, i64 16}
!12 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"_RcsBody", !17, i64 0, !13, i64 8, !10, i64 12, !8, i64 16, !8, i64 40, !17, 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}
!17 = !{!"double", !8, i64 0}
!18 = !{!16, !7, i64 112}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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