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

; 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 ptr @MatNd_create(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @MatNd_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @RcsGraph_rotationJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare void @MatNd_subSelf(ptr noundef, ptr noundef) #1

declare void @MatNd_rotateSelf(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_3dOmegaJacobian(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %22

15:                                               ; preds = %5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  call void @RcsGraph_rotationJacobian(ptr noundef %19, ptr noundef %20, ptr noundef null, ptr noundef %21)
  br label %116

22:                                               ; preds = %15, %5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %43

25:                                               ; preds = %22
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %43

29:                                               ; preds = %25
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call zeroext i1 @RcsBody_isArticulated(ptr noundef %30)
  %32 = zext i1 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %43

34:                                               ; preds = %29
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._RcsBody, ptr %37, i32 0, i32 10
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.HTr, ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds [3 x [3 x double]], ptr %40, i64 0, i64 0
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  call void @RcsGraph_rotationJacobian(ptr noundef %35, ptr noundef %36, ptr noundef %41, ptr noundef %42)
  br label %115

43:                                               ; preds = %29, %25, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store ptr null, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._RcsGraph, ptr %44, i32 0, i32 3
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %47 = mul i32 3, %46
  %48 = icmp ugt i32 %47, 1296
  br i1 %48, label %49, label %54

49:                                               ; preds = %43
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._RcsGraph, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = call ptr @MatNd_create(i32 noundef 3, i32 noundef %52)
  store ptr %53, ptr %11, align 8, !tbaa !5
  br label %95

54:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._RcsGraph, ptr %55, i32 0, i32 3
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = mul i32 3, %57
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  br label %66

61:                                               ; preds = %54
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._RcsGraph, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = mul i32 3, %64
  br label %66

66:                                               ; preds = %61, %60
  %67 = phi i32 [ 1, %60 ], [ %65, %61 ]
  store i32 %67, ptr %12, align 4, !tbaa !16
  %68 = load i32, ptr %12, align 4, !tbaa !16
  %69 = zext i32 %68 to i64
  %70 = mul i64 %69, 8
  %71 = add i64 24, %70
  %72 = alloca i8, i64 %71, align 16
  store ptr %72, ptr %11, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._MatNd, ptr %73, i64 1
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MatNd, ptr %75, i32 0, i32 0
  store ptr %74, ptr %76, align 8, !tbaa !17
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._MatNd, ptr %77, i32 0, i32 1
  store i32 3, ptr %78, align 8, !tbaa !19
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._RcsGraph, ptr %79, i32 0, i32 3
  %81 = load i32, ptr %80, align 4, !tbaa !14
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._MatNd, ptr %82, i32 0, i32 2
  store i32 %81, ptr %83, align 4, !tbaa !20
  %84 = load i32, ptr %12, align 4, !tbaa !16
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._MatNd, ptr %85, i32 0, i32 3
  store i32 %84, ptr %86, align 8, !tbaa !21
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._MatNd, ptr %87, i32 0, i32 4
  store i8 1, ptr %88, align 4, !tbaa !22
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._MatNd, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !17
  %92 = load i32, ptr %12, align 4, !tbaa !16
  %93 = zext i32 %92 to i64
  %94 = mul i64 %93, 8
  call void @llvm.memset.p0.i64(ptr align 8 %91, i8 0, i64 %94, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %95

95:                                               ; preds = %66, %49
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  call void @RcsGraph_rotationJacobian(ptr noundef %96, ptr noundef %97, ptr noundef null, ptr noundef %98)
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  call void @RcsGraph_rotationJacobian(ptr noundef %99, ptr noundef %100, ptr noundef null, ptr noundef %101)
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_subSelf(ptr noundef %102, ptr noundef %103)
  %104 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %104)
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %114

107:                                              ; preds = %95
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._RcsBody, ptr %109, i32 0, i32 10
  %111 = load ptr, ptr %110, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.HTr, ptr %111, i32 0, i32 1
  %113 = getelementptr inbounds [3 x [3 x double]], ptr %112, i64 0, i64 0
  call void @MatNd_rotateSelf(ptr noundef %108, ptr noundef %113)
  br label %114

114:                                              ; preds = %107, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %115

115:                                              ; preds = %114, %34
  br label %116

116:                                              ; preds = %115, %18
  ret void
}

declare zeroext i1 @RcsBody_isArticulated(ptr 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 104}
!10 = !{!"_RcsBody", !11, i64 0, !12, i64 8, !13, i64 12, !7, i64 16, !7, i64 40, !11, 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}
!11 = !{!"double", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 1852}
!15 = !{!"_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}
!16 = !{!13, !13, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"_MatNd", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !12, i64 20}
!19 = !{!18, !13, i64 8}
!20 = !{!18, !13, i64 12}
!21 = !{!18, !13, i64 16}
!22 = !{!18, !12, i64 20}


; 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"

declare ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_3dOmegaJacobian(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef readonly %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = icmp eq ptr %2, null
  %7 = icmp eq ptr %3, null
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %5
  tail call void @RcsGraph_rotationJacobian(ptr noundef %0, ptr noundef %1, ptr noundef null, ptr noundef %4)
  br label %40

9:                                                ; preds = %5
  %.not = icmp ne ptr %2, null
  %10 = icmp eq ptr %3, %2
  %or.cond44 = and i1 %.not, %10
  br i1 %or.cond44, label %11, label %17

11:                                               ; preds = %9
  %12 = tail call zeroext i1 @RcsBody_isArticulated(ptr noundef nonnull %2) #3
  br i1 %12, label %17, label %13

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %2, i64 104
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  tail call void @RcsGraph_rotationJacobian(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %16, ptr noundef %4)
  br label %40

17:                                               ; preds = %11, %9
  %18 = getelementptr inbounds i8, ptr %0, i64 1852
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = mul i32 %19, 3
  %21 = icmp ugt i32 %20, 1296
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef %19) #3
  br label %35

24:                                               ; preds = %17
  %25 = icmp eq i32 %19, 0
  %spec.select = select i1 %25, i32 1, i32 %20
  %26 = shl nuw nsw i32 %spec.select, 3
  %27 = zext nneg i32 %26 to i64
  %28 = add nuw nsw i64 %27, 24
  %29 = alloca i8, i64 %28, align 16
  %30 = getelementptr inbounds i8, ptr %29, i64 24
  store ptr %30, ptr %29, align 16, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %29, i64 8
  store i32 3, ptr %31, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %29, i64 12
  store i32 %19, ptr %32, align 4, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %29, i64 16
  store i32 %spec.select, ptr %33, align 16, !tbaa !19
  %34 = getelementptr inbounds i8, ptr %29, i64 20
  store i8 1, ptr %34, align 4, !tbaa !20
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %30, i8 0, i64 %27, i1 false)
  br label %35

35:                                               ; preds = %24, %22
  %.0 = phi ptr [ %23, %22 ], [ %29, %24 ]
  call void @RcsGraph_rotationJacobian(ptr noundef nonnull %0, ptr noundef %1, ptr noundef null, ptr noundef %4)
  call void @RcsGraph_rotationJacobian(ptr noundef nonnull %0, ptr noundef %2, ptr noundef null, ptr noundef %.0)
  call void @MatNd_subSelf(ptr noundef %4, ptr noundef %.0) #3
  call void @MatNd_destroy(ptr noundef %.0) #3
  br i1 %7, label %40, label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds i8, ptr %3, i64 104
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i64 24
  call void @MatNd_rotateSelf(ptr noundef %4, ptr noundef nonnull %39) #3
  br label %40

40:                                               ; preds = %35, %36, %13, %8
  ret void
}

declare zeroext i1 @RcsBody_isArticulated(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 nounwind willreturn memory(argmem: write) }
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 }

!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, !12, i64 104}
!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 = !{!14, !11, i64 1852}
!14 = !{!"_RcsGraph", !12, i64 0, !8, i64 8, !11, i64 1848, !11, i64 1852, !12, i64 1856, !12, i64 1864, !12, i64 1872, !12, i64 1880, !12, i64 1888}
!15 = !{!16, !12, i64 0}
!16 = !{!"_MatNd", !12, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !10, i64 20}
!17 = !{!16, !11, i64 8}
!18 = !{!16, !11, i64 12}
!19 = !{!16, !11, i64 16}
!20 = !{!16, !10, i64 20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass