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

; 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_3dPosJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_1dPosJacobian(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store ptr null, ptr %13, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._RcsGraph, ptr %15, i32 0, i32 3
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = mul i32 3, %17
  %19 = icmp ugt i32 %18, 1296
  br i1 %19, label %20, label %25

20:                                               ; preds = %6
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._RcsGraph, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = call ptr @MatNd_create(i32 noundef 3, i32 noundef %23)
  store ptr %24, ptr %13, align 8, !tbaa !5
  br label %66

25:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._RcsGraph, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = mul i32 3, %28
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  br label %37

32:                                               ; preds = %25
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._RcsGraph, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = mul i32 3, %35
  br label %37

37:                                               ; preds = %32, %31
  %38 = phi i32 [ 1, %31 ], [ %36, %32 ]
  store i32 %38, ptr %14, align 4, !tbaa !9
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = mul i64 %40, 8
  %42 = add i64 24, %41
  %43 = alloca i8, i64 %42, align 16
  store ptr %43, ptr %13, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._MatNd, ptr %44, i64 1
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._MatNd, ptr %46, i32 0, i32 0
  store ptr %45, ptr %47, align 8, !tbaa !13
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._MatNd, ptr %48, i32 0, i32 1
  store i32 3, ptr %49, align 8, !tbaa !16
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._RcsGraph, ptr %50, i32 0, i32 3
  %52 = load i32, ptr %51, align 4, !tbaa !11
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._MatNd, ptr %53, i32 0, i32 2
  store i32 %52, ptr %54, align 4, !tbaa !17
  %55 = load i32, ptr %14, align 4, !tbaa !9
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._MatNd, ptr %56, i32 0, i32 3
  store i32 %55, ptr %57, align 8, !tbaa !18
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._MatNd, ptr %58, i32 0, i32 4
  store i8 1, ptr %59, align 4, !tbaa !19
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._MatNd, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = load i32, ptr %14, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = mul i64 %64, 8
  call void @llvm.memset.p0.i64(ptr align 8 %62, i8 0, i64 %65, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %66

66:                                               ; preds = %37, %20
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  call void @RcsGraph_3dPosJacobian(ptr noundef %67, ptr noundef %68, ptr noundef %69, ptr noundef %70, ptr noundef %71)
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  call void @MatNd_getRow(ptr noundef %72, i32 noundef %73, ptr noundef %74)
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %75)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret void
}

declare void @MatNd_getRow(ptr noundef, i32 noundef, 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 1852}
!12 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !10, i64 1848, !10, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!13 = !{!14, !6, i64 0}
!14 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !15, i64 20}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !10, i64 12}
!18 = !{!14, !10, i64 16}
!19 = !{!14, !15, 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_3dPosJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_1dPosJacobian(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 1852
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = mul i32 %8, 3
  %10 = icmp ugt i32 %9, 1296
  br i1 %10, label %11, label %13

11:                                               ; preds = %6
  %12 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef %8) #3
  br label %24

13:                                               ; preds = %6
  %14 = icmp eq i32 %8, 0
  %spec.select = select i1 %14, i32 1, i32 %9
  %15 = shl nuw nsw i32 %spec.select, 3
  %16 = zext nneg i32 %15 to i64
  %17 = add nuw nsw i64 %16, 24
  %18 = alloca i8, i64 %17, align 16
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  store ptr %19, ptr %18, align 16, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %18, i64 8
  store i32 3, ptr %20, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %18, i64 12
  store i32 %8, ptr %21, align 4, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %18, i64 16
  store i32 %spec.select, ptr %22, align 16, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %18, i64 20
  store i8 1, ptr %23, align 4, !tbaa !17
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %19, i8 0, i64 %16, i1 false)
  br label %24

24:                                               ; preds = %13, %11
  %.0 = phi ptr [ %12, %11 ], [ %18, %13 ]
  call void @RcsGraph_3dPosJacobian(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %.0)
  call void @MatNd_getRow(ptr noundef %5, i32 noundef %4, ptr noundef %.0) #3
  call void @MatNd_destroy(ptr noundef %.0) #3
  ret void
}

declare void @MatNd_getRow(ptr noundef, i32 noundef, 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, !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, !7, i64 0}
!12 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !13, i64 20}


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