; 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

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

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_bodyPointDotJacobian(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %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 ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = 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 ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._RcsGraph, ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %18, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store ptr null, ptr %14, align 8, !tbaa !5
  %19 = load i32, ptr %13, align 4, !tbaa !12
  %20 = mul nsw i32 3, %19
  %21 = load i32, ptr %13, align 4, !tbaa !12
  %22 = mul nsw i32 %20, %21
  %23 = icmp sgt i32 %22, 1296
  br i1 %23, label %24, label %29

24:                                               ; preds = %6
  %25 = load i32, ptr %13, align 4, !tbaa !12
  %26 = mul nsw i32 3, %25
  %27 = load i32, ptr %13, align 4, !tbaa !12
  %28 = call ptr @MatNd_create(i32 noundef %26, i32 noundef %27)
  store ptr %28, ptr %14, align 8, !tbaa !5
  br label %70

29:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %30 = load i32, ptr %13, align 4, !tbaa !12
  %31 = mul nsw i32 3, %30
  %32 = load i32, ptr %13, align 4, !tbaa !12
  %33 = mul nsw i32 %31, %32
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %29
  br label %41

36:                                               ; preds = %29
  %37 = load i32, ptr %13, align 4, !tbaa !12
  %38 = mul nsw i32 3, %37
  %39 = load i32, ptr %13, align 4, !tbaa !12
  %40 = mul nsw i32 %38, %39
  br label %41

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

70:                                               ; preds = %41, %24
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  call void @RcsGraph_bodyPointHessian(ptr noundef %71, ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %75)
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = load i32, ptr %13, align 4, !tbaa !12
  %78 = mul nsw i32 3, %77
  call void @MatNd_reshape(ptr noundef %76, i32 noundef %78, i32 noundef 1)
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %79, ptr noundef %80, ptr noundef %81)
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = load i32, ptr %13, align 4, !tbaa !12
  call void @MatNd_reshape(ptr noundef %82, i32 noundef 3, i32 noundef %83)
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret void
}

declare ptr @MatNd_create(i32 noundef, i32 noundef) #2

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

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

declare void @MatNd_mul(ptr noundef, ptr noundef, ptr noundef) #2

declare void @MatNd_destroy(ptr noundef) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !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, !6, i64 0}
!14 = !{!"_MatNd", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !15, i64 20}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !11, i64 8}
!17 = !{!14, !11, i64 12}
!18 = !{!14, !11, 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"

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

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

12:                                               ; preds = %6
  %13 = tail call ptr @MatNd_create(i32 noundef %9, i32 noundef %8) #4
  br label %25

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

25:                                               ; preds = %14, %12
  %.0 = phi ptr [ %13, %12 ], [ %19, %14 ]
  call void @RcsGraph_bodyPointHessian(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %.0)
  call void @MatNd_reshape(ptr noundef %5, i32 noundef %9, i32 noundef 1) #4
  call void @MatNd_mul(ptr noundef %5, ptr noundef %.0, ptr noundef %4) #4
  call void @MatNd_reshape(ptr noundef %5, i32 noundef 3, i32 noundef %8) #4
  call void @MatNd_destroy(ptr noundef %.0) #4
  ret void
}

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

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

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

declare void @MatNd_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #3

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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