; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_dynamics)

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

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

declare void @MatNd_destroy(ptr noundef) #1

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

18:                                               ; preds = %2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._RcsGraph, ptr %19, i32 0, i32 3
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = call ptr @MatNd_create(i32 noundef 3, i32 noundef %21)
  store ptr %22, ptr %5, align 8, !tbaa !5
  br label %64

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

29:                                               ; preds = %23
  br label %35

30:                                               ; preds = %23
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._RcsGraph, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = mul i32 3, %33
  br label %35

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

64:                                               ; preds = %35, %18
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  call void @RcsGraph_COGJacobian(ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  call void @MatNd_transposeSelf(ptr noundef %67)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 3, ptr %8, align 4, !tbaa !12
  %68 = load i32, ptr %8, align 4, !tbaa !12
  %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 %7, align 8, !tbaa !5
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._MatNd, ptr %73, i64 1
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MatNd, ptr %75, i32 0, i32 0
  store ptr %74, ptr %76, align 8, !tbaa !13
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._MatNd, ptr %77, i32 0, i32 1
  store i32 3, ptr %78, align 8, !tbaa !16
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._MatNd, ptr %79, i32 0, i32 2
  store i32 1, ptr %80, align 4, !tbaa !17
  %81 = load i32, ptr %8, align 4, !tbaa !12
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._MatNd, ptr %82, i32 0, i32 3
  store i32 %81, ptr %83, align 8, !tbaa !18
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._MatNd, ptr %84, i32 0, i32 4
  store i8 1, ptr %85, align 4, !tbaa !19
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._MatNd, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !13
  %89 = load i32, ptr %8, align 4, !tbaa !12
  %90 = zext i32 %89 to i64
  %91 = mul i64 %90, 8
  call void @llvm.memset.p0.i64(ptr align 8 %88, i8 0, i64 %91, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = call double @RcsGraph_mass(ptr noundef %93)
  %95 = fneg double %94
  %96 = fmul double %95, 9.810000e+00
  call void @MatNd_set(ptr noundef %92, i32 noundef 2, i32 noundef 0, double noundef %96)
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %97, ptr noundef %98, ptr noundef %99)
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %100)
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %101)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

declare void @MatNd_transposeSelf(ptr noundef) #1

declare void @MatNd_set(ptr noundef, i32 noundef, i32 noundef, double noundef) #1

declare double @RcsGraph_mass(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, !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"

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_reshape(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @RcsGraph_computeGravityTorque(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_reshape(ptr noundef %1, i32 noundef %4, i32 noundef 1) #3
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = mul i32 %5, 3
  %7 = icmp ugt i32 %6, 1296
  br i1 %7, label %8, label %10

8:                                                ; preds = %2
  %9 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef %5) #3
  br label %21

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

21:                                               ; preds = %10, %8
  %.0 = phi ptr [ %9, %8 ], [ %15, %10 ]
  call void @RcsGraph_COGJacobian(ptr noundef nonnull %0, ptr noundef %.0) #3
  call void @MatNd_transposeSelf(ptr noundef %.0) #3
  %22 = alloca [48 x i8], align 16
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  store ptr %23, ptr %22, align 16, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %22, i64 8
  store i32 3, ptr %24, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %22, i64 12
  store i32 1, ptr %25, align 4, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %22, i64 16
  store i32 3, ptr %26, align 16, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %22, i64 20
  store i8 1, ptr %27, align 4, !tbaa !17
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %23, i8 0, i64 24, i1 false)
  %28 = call double @RcsGraph_mass(ptr noundef nonnull %0) #3
  %29 = fmul double %28, -9.810000e+00
  call void @MatNd_set(ptr noundef nonnull %22, i32 noundef 2, i32 noundef 0, double noundef %29) #3
  call void @MatNd_mul(ptr noundef %1, ptr noundef %.0, ptr noundef nonnull %22) #3
  call void @MatNd_destroy(ptr noundef %.0) #3
  call void @MatNd_destroy(ptr noundef nonnull %22) #3
  ret void
}

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

declare void @MatNd_transposeSelf(ptr noundef) local_unnamed_addr #0

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

declare double @RcsGraph_mass(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