; 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
@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_COGJacobian = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [61 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

declare void @MatNd_reshapeAndSetZero(ptr noundef, i32 noundef, i32 noundef) #1

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #1

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

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

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %44

18:                                               ; preds = %14
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._RcsBody, ptr %19, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !15
  %22 = fcmp ogt double %21, 0.000000e+00
  br i1 %22, label %23, label %40

23:                                               ; preds = %18
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._RcsBody, ptr %26, i32 0, i32 11
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds %struct.HTr, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds [3 x double], ptr %29, i64 0, i64 0
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._RcsBody, ptr %31, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  call void @RcsGraph_constMulAndAddBodyPointJacobian(ptr noundef %24, ptr noundef %25, ptr noundef %30, ptr noundef null, double noundef %33, ptr noundef %34)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._RcsBody, ptr %35, i32 0, i32 0
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = fadd double %38, %37
  store double %39, ptr %5, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %23, %18
  br label %41

41:                                               ; preds = %40
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %42)
  store ptr %43, ptr %6, align 8, !tbaa !5
  br label %14, !llvm.loop !19

44:                                               ; preds = %17
  %45 = load double, ptr %5, align 8, !tbaa !9
  %46 = fcmp ogt double %45, 0.000000e+00
  br i1 %46, label %47, label %51

47:                                               ; preds = %44
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load double, ptr %5, align 8, !tbaa !9
  %50 = fdiv double 1.000000e+00, %49
  call void @MatNd_constMulSelf(ptr noundef %48, double noundef %50)
  br label %70

51:                                               ; preds = %44
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %57

55:                                               ; preds = %52
  %56 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %56(i32 noundef 1, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COGJacobian, i32 noundef 996, ptr noundef @.str.6)
  br label %57

57:                                               ; preds = %55, %52
  %58 = load i32, ptr @RcsLogLevel, align 4, !tbaa !21
  %59 = icmp sle i32 1, %58
  br i1 %59, label %60, label %67

60:                                               ; preds = %57
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.4, ptr noundef @.str.1, ptr noundef @__func__.RcsGraph_COGJacobian, i32 noundef 996) #4
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.6) #4
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.5) #4
  br label %67

67:                                               ; preds = %60, %57
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @RcsGraph_constMulAndAddBodyPointJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !13, i64 1852}
!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 = !{!12, !6, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"_RcsBody", !10, i64 0, !17, 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}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!16, !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
@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_COGJacobian = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [61 x i8], align 1

declare void @MatNd_reshapeAndSetZero(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_COGJacobian(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1852
  %4 = load i32, ptr %3, align 4, !tbaa !5
  tail call void @MatNd_reshapeAndSetZero(ptr noundef %1, i32 noundef 3, i32 noundef %4) #3
  %5 = load ptr, ptr %0, align 8, !tbaa !11
  %.not20 = icmp eq ptr %5, null
  br i1 %.not20, label %._crit_edge.thread, label %.lr.ph

._crit_edge:                                      ; preds = %14
  %6 = fcmp ogt double %.1, 0.000000e+00
  br i1 %6, label %16, label %._crit_edge.thread

.lr.ph:                                           ; preds = %2, %14
  %.022 = phi ptr [ %15, %14 ], [ %5, %2 ]
  %.01621 = phi double [ %.1, %14 ], [ 0.000000e+00, %2 ]
  %7 = load double, ptr %.022, align 8, !tbaa !12
  %8 = fcmp ogt double %7, 0.000000e+00
  br i1 %8, label %9, label %14

9:                                                ; preds = %.lr.ph
  %10 = getelementptr inbounds i8, ptr %.022, i64 112
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  tail call void @RcsGraph_constMulAndAddBodyPointJacobian(ptr noundef nonnull %0, ptr noundef nonnull %.022, ptr noundef %11, ptr noundef null, double noundef %7, ptr noundef %1)
  %12 = load double, ptr %.022, align 8, !tbaa !12
  %13 = fadd double %.01621, %12
  br label %14

14:                                               ; preds = %.lr.ph, %9
  %.1 = phi double [ %13, %9 ], [ %.01621, %.lr.ph ]
  %15 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.022) #3
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

16:                                               ; preds = %._crit_edge
  %17 = fdiv double 1.000000e+00, %.1
  tail call void @MatNd_constMulSelf(ptr noundef %1, double noundef %17) #3
  br label %30

._crit_edge.thread:                               ; preds = %2, %._crit_edge
  %18 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !19
  %.not19 = icmp eq ptr %18, null
  br i1 %.not19, label %20, label %19

19:                                               ; preds = %._crit_edge.thread
  tail call void (i32, ptr, ptr, i32, ptr, ...) %18(i32 noundef 1, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COGJacobian, i32 noundef 996, ptr noundef nonnull @.str.6) #3
  br label %20

20:                                               ; preds = %19, %._crit_edge.thread
  %21 = load i32, ptr @RcsLogLevel, align 4, !tbaa !20
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %30

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !19
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.RcsGraph_COGJacobian, i32 noundef 996) #4
  %26 = load ptr, ptr @stderr, align 8, !tbaa !19
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.6) #4
  %28 = load ptr, ptr @stderr, align 8, !tbaa !19
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.5) #4
  br label %30

30:                                               ; preds = %20, %23, %16
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @RcsGraph_constMulAndAddBodyPointJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #2

declare void @MatNd_constMulSelf(ptr noundef, double 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 = { 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 = { 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 #3 = { nounwind }
attributes #4 = { 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, !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 = !{!6, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_RcsBody", !14, i64 0, !15, i64 8, !10, i64 12, !8, i64 16, !8, i64 40, !14, 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}
!14 = !{!"double", !8, i64 0}
!15 = !{!"_Bool", !8, i64 0}
!16 = !{!13, !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,SROAPass,SimplifyCFGPass,TailCallElimPass