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

; 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._MatNd = type { ptr, i32, i32, i32, i8 }
%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 }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [76 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@RcsLogLevel = external global i32, align 4
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GRADIENTTESTS_BODYPT1 = external dso_local global [3 x double], align 16
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [52 x i8], align 1
@__func__.test_hessianPinv2 = external hidden unnamed_addr constant [18 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

declare void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, ptr noundef) #3

declare void @RcsGraph_bodyPointJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare void @MatNd_destroy(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @RcsGraph_bodyPointHessian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #3

declare void @MatNd_transpose(ptr noundef, ptr noundef) #3

declare double @MatNd_choleskyInverse(ptr noundef, ptr noundef) #3

declare double @Timer_getTime(...) #3

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

; Function Attrs: nounwind uwtable
define dso_local void @test_hessianPinv2(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca %struct._MatNd, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %24, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @Rcs_setIKState(ptr noundef %25, ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %27 = call double (...) @Timer_getTime()
  store double %27, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._RcsGraph, ptr %28, i32 0, i32 3
  %30 = load i32, ptr %29, align 4, !tbaa !13
  store i32 %30, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._RcsGraph, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  store ptr %33, ptr %12, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %46, %3
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %49

38:                                               ; preds = %34
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._RcsBody, ptr %39, i32 0, i32 18
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %45

43:                                               ; preds = %38
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %44, ptr %11, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %43, %38
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %47)
  store ptr %48, ptr %12, align 8, !tbaa !5
  br label %34, !llvm.loop !19

49:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr @RCS_GRADIENTTESTS_BODYPT1, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store double 1.000000e-03, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %50 = load i32, ptr %9, align 4, !tbaa !11
  %51 = load i32, ptr %10, align 4, !tbaa !11
  %52 = call ptr @MatNd_create(i32 noundef %50, i32 noundef %51)
  store ptr %52, ptr %15, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  call void @RcsGraph_bodyPointJacobian(ptr noundef %53, ptr noundef %54, ptr noundef %55, ptr noundef null, ptr noundef %56)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %57 = load i32, ptr %10, align 4, !tbaa !11
  %58 = load i32, ptr %9, align 4, !tbaa !11
  %59 = call ptr @MatNd_create(i32 noundef %57, i32 noundef %58)
  store ptr %59, ptr %17, align 8, !tbaa !5
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_transpose(ptr noundef %60, ptr noundef %61)
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %67

64:                                               ; preds = %49
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = load ptr, ptr %16, align 8, !tbaa !5
  call void @MatNd_postMulDiagSelf(ptr noundef %65, ptr noundef %66)
  br label %67

67:                                               ; preds = %64, %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %68 = load i32, ptr %10, align 4, !tbaa !11
  %69 = load i32, ptr %10, align 4, !tbaa !11
  %70 = call ptr @MatNd_create(i32 noundef %68, i32 noundef %69)
  store ptr %70, ptr %18, align 8, !tbaa !5
  %71 = load ptr, ptr %18, align 8, !tbaa !5
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %71, ptr noundef %72, ptr noundef %73)
  %74 = load ptr, ptr %18, align 8, !tbaa !5
  call void @MatNd_addConstToDiag(ptr noundef %74, double noundef 1.000000e-03)
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %75 = load ptr, ptr %18, align 8, !tbaa !5
  %76 = load ptr, ptr %18, align 8, !tbaa !5
  %77 = call double @MatNd_choleskyInverse(ptr noundef %75, ptr noundef %76)
  store double %77, ptr %19, align 8, !tbaa !9
  %78 = load double, ptr %19, align 8, !tbaa !9
  %79 = fcmp oeq double %78, 0.000000e+00
  br i1 %79, label %80, label %128

80:                                               ; preds = %67
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %95

84:                                               ; preds = %81
  %85 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %92

88:                                               ; preds = %84
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._RcsBody, ptr %89, i32 0, i32 6
  %91 = load ptr, ptr %90, align 8, !tbaa !21
  br label %93

92:                                               ; preds = %84
  br label %93

93:                                               ; preds = %92, %88
  %94 = phi ptr [ %91, %88 ], [ @.str.5, %92 ]
  call void (i32, ptr, ptr, i32, ptr, ...) %85(i32 noundef 1, ptr noundef @.str.2, ptr noundef @__func__.test_hessianPinv2, i32 noundef 1160, ptr noundef @.str.9, ptr noundef %94)
  br label %95

95:                                               ; preds = %93, %81
  %96 = load i32, ptr @RcsLogLevel, align 4, !tbaa !11
  %97 = icmp sle i32 1, %96
  br i1 %97, label %98, label %114

98:                                               ; preds = %95
  %99 = load ptr, ptr @stderr, align 8, !tbaa !5
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %99, ptr noundef @.str.6, ptr noundef @.str.2, ptr noundef @__func__.test_hessianPinv2, i32 noundef 1160) #5
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = load ptr, ptr %11, align 8, !tbaa !5
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %108

104:                                              ; preds = %98
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._RcsBody, ptr %105, i32 0, i32 6
  %107 = load ptr, ptr %106, align 8, !tbaa !21
  br label %109

108:                                              ; preds = %98
  br label %109

109:                                              ; preds = %108, %104
  %110 = phi ptr [ %107, %104 ], [ @.str.5, %108 ]
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.9, ptr noundef %110) #5
  %112 = load ptr, ptr @stderr, align 8, !tbaa !5
  %113 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %112, ptr noundef @.str.7) #5
  br label %114

114:                                              ; preds = %109, %95
  br label %115

115:                                              ; preds = %114
  br label %116

116:                                              ; preds = %115
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = load i32, ptr %9, align 4, !tbaa !11
  %119 = load i32, ptr %10, align 4, !tbaa !11
  %120 = mul nsw i32 %118, %119
  %121 = load i32, ptr %10, align 4, !tbaa !11
  %122 = mul nsw i32 %120, %121
  %123 = sext i32 %122 to i64
  %124 = mul i64 %123, 8
  call void @llvm.memset.p0.i64(ptr align 8 %117, i8 0, i64 %124, i1 false)
  %125 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %125)
  %126 = load ptr, ptr %17, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %126)
  %127 = load ptr, ptr %18, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %127)
  store i32 1, ptr %20, align 4
  br label %184

128:                                              ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %129 = load i32, ptr %10, align 4, !tbaa !11
  %130 = load i32, ptr %9, align 4, !tbaa !11
  %131 = call ptr @MatNd_create(i32 noundef %129, i32 noundef %130)
  store ptr %131, ptr %21, align 8, !tbaa !5
  %132 = load ptr, ptr %21, align 8, !tbaa !5
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = load ptr, ptr %17, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %132, ptr noundef %133, ptr noundef %134)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %135 = load i32, ptr %9, align 4, !tbaa !11
  %136 = load i32, ptr %10, align 4, !tbaa !11
  %137 = mul nsw i32 %135, %136
  %138 = load i32, ptr %10, align 4, !tbaa !11
  %139 = call ptr @MatNd_create(i32 noundef %137, i32 noundef %138)
  store ptr %139, ptr %22, align 8, !tbaa !5
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = load ptr, ptr %11, align 8, !tbaa !5
  %142 = load ptr, ptr %13, align 8, !tbaa !5
  %143 = load ptr, ptr %22, align 8, !tbaa !5
  call void @RcsGraph_bodyPointHessian(ptr noundef %140, ptr noundef %141, ptr noundef %142, ptr noundef null, ptr noundef %143)
  call void @llvm.lifetime.start.p0(i64 24, ptr %23) #5
  %144 = load i32, ptr %10, align 4, !tbaa !11
  %145 = load i32, ptr %10, align 4, !tbaa !11
  %146 = mul nsw i32 %144, %145
  %147 = load i32, ptr %9, align 4, !tbaa !11
  %148 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %23, i32 noundef %146, i32 noundef %147, ptr noundef %148)
  %149 = load ptr, ptr %15, align 8, !tbaa !5
  %150 = load ptr, ptr %22, align 8, !tbaa !5
  %151 = load ptr, ptr %16, align 8, !tbaa !5
  %152 = load ptr, ptr %18, align 8, !tbaa !5
  %153 = load ptr, ptr %21, align 8, !tbaa !5
  call void @MatNd_PinvHessian2(ptr noundef %23, ptr noundef %149, ptr noundef %150, ptr noundef %151, ptr noundef %152, ptr noundef %153, i1 noundef zeroext false)
  %154 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %154)
  %155 = load ptr, ptr %17, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %155)
  %156 = load ptr, ptr %18, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %156)
  %157 = load ptr, ptr %21, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %157)
  %158 = load ptr, ptr %22, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %158)
  %159 = call double (...) @Timer_getTime()
  %160 = load double, ptr %8, align 8, !tbaa !9
  %161 = fsub double %159, %160
  store double %161, ptr %8, align 8, !tbaa !9
  br label %162

162:                                              ; preds = %128
  %163 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %169

165:                                              ; preds = %162
  %166 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %167 = load double, ptr %8, align 8, !tbaa !9
  %168 = fmul double 1.000000e+03, %167
  call void (i32, ptr, ptr, i32, ptr, ...) %166(i32 noundef 5, ptr noundef @.str.2, ptr noundef @__func__.test_hessianPinv2, i32 noundef 1187, ptr noundef @.str.8, double noundef %168)
  br label %169

169:                                              ; preds = %165, %162
  %170 = load i32, ptr @RcsLogLevel, align 4, !tbaa !11
  %171 = icmp sle i32 5, %170
  br i1 %171, label %172, label %181

172:                                              ; preds = %169
  %173 = load ptr, ptr @stderr, align 8, !tbaa !5
  %174 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %173, ptr noundef @.str.6, ptr noundef @.str.2, ptr noundef @__func__.test_hessianPinv2, i32 noundef 1187) #5
  %175 = load ptr, ptr @stderr, align 8, !tbaa !5
  %176 = load double, ptr %8, align 8, !tbaa !9
  %177 = fmul double 1.000000e+03, %176
  %178 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %175, ptr noundef @.str.8, double noundef %177) #5
  %179 = load ptr, ptr @stderr, align 8, !tbaa !5
  %180 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %179, ptr noundef @.str.7) #5
  br label %181

181:                                              ; preds = %172, %169
  br label %182

182:                                              ; preds = %181
  br label %183

183:                                              ; preds = %182
  call void @llvm.lifetime.end.p0(i64 24, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  store i32 0, ptr %20, align 4
  br label %184

184:                                              ; preds = %183, %116
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %185 = load i32, ptr %20, align 4
  switch i32 %185, label %187 [
    i32 0, label %186
    i32 1, label %186
  ]

186:                                              ; preds = %184, %184
  ret void

187:                                              ; preds = %184
  unreachable
}

declare void @MatNd_postMulDiagSelf(ptr noundef, ptr noundef) #3

declare void @MatNd_addConstToDiag(ptr noundef, double noundef) #3

declare void @MatNd_PinvHessian2(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 1852}
!14 = !{!"_RcsGraph", !6, i64 0, !7, i64 8, !12, i64 1848, !12, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!15 = !{!14, !6, i64 0}
!16 = !{!17, !6, i64 168}
!17 = !{!"_RcsBody", !10, i64 0, !18, i64 8, !12, 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}
!18 = !{!"_Bool", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !6, i64 72}


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

%struct._MatNd = type { ptr, i32, i32, i32, i8 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [76 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GRADIENTTESTS_BODYPT1 = external dso_local global [3 x double], align 16
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [52 x i8], align 1
@__func__.test_hessianPinv2 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

declare void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare void @RcsGraph_bodyPointJacobian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare void @MatNd_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @RcsGraph_bodyPointHessian(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #3

declare void @MatNd_transpose(ptr noundef, ptr noundef) local_unnamed_addr #3

declare double @MatNd_choleskyInverse(ptr noundef, ptr noundef) local_unnamed_addr #3

declare double @Timer_getTime(...) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @test_hessianPinv2(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct._MatNd, align 8
  tail call void @Rcs_setIKState(ptr noundef %2, ptr noundef %1)
  %5 = tail call double (...) @Timer_getTime() #5
  %6 = getelementptr inbounds i8, ptr %2, i64 1852
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !11
  %.not78 = icmp eq ptr %8, null
  br i1 %.not78, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.0.lcssa = phi ptr [ null, %3 ], [ %spec.select, %.lr.ph ]
  %9 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef %7) #5
  tail call void @RcsGraph_bodyPointJacobian(ptr noundef nonnull %2, ptr noundef %.0.lcssa, ptr noundef nonnull @RCS_GRADIENTTESTS_BODYPT1, ptr noundef null, ptr noundef %9) #5
  %10 = tail call ptr @MatNd_create(i32 noundef %7, i32 noundef 3) #5
  tail call void @MatNd_transpose(ptr noundef %10, ptr noundef %9) #5
  %11 = tail call ptr @MatNd_create(i32 noundef %7, i32 noundef %7) #5
  tail call void @MatNd_mul(ptr noundef %11, ptr noundef %10, ptr noundef %9) #5
  tail call void @MatNd_addConstToDiag(ptr noundef %11, double noundef 1.000000e-03) #5
  %12 = tail call double @MatNd_choleskyInverse(ptr noundef %11, ptr noundef %11) #5
  %13 = fcmp oeq double %12, 0.000000e+00
  br i1 %13, label %17, label %45

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.080 = phi ptr [ %spec.select, %.lr.ph ], [ null, %3 ]
  %.07079 = phi ptr [ %16, %.lr.ph ], [ %8, %3 ]
  %14 = getelementptr inbounds i8, ptr %.07079, i64 168
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %.not77 = icmp eq ptr %15, null
  %spec.select = select i1 %.not77, ptr %.080, ptr %.07079
  %16 = tail call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.07079) #5
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

17:                                               ; preds = %._crit_edge
  %18 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !18
  %.not74 = icmp eq ptr %18, null
  br i1 %.not74, label %25, label %19

19:                                               ; preds = %17
  %.not75 = icmp eq ptr %.0.lcssa, null
  br i1 %.not75, label %23, label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds i8, ptr %.0.lcssa, i64 72
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  br label %23

23:                                               ; preds = %19, %20
  %24 = phi ptr [ %22, %20 ], [ @.str.5, %19 ]
  tail call void (i32, ptr, ptr, i32, ptr, ...) %18(i32 noundef 1, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_hessianPinv2, i32 noundef 1160, ptr noundef nonnull @.str.9, ptr noundef %24) #5
  br label %25

25:                                               ; preds = %23, %17
  %26 = load i32, ptr @RcsLogLevel, align 4, !tbaa !20
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %28, label %40

28:                                               ; preds = %25
  %29 = load ptr, ptr @stderr, align 8, !tbaa !18
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_hessianPinv2, i32 noundef 1160) #6
  %31 = load ptr, ptr @stderr, align 8, !tbaa !18
  %.not76 = icmp eq ptr %.0.lcssa, null
  br i1 %.not76, label %35, label %32

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %.0.lcssa, i64 72
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  br label %35

35:                                               ; preds = %28, %32
  %36 = phi ptr [ %34, %32 ], [ @.str.5, %28 ]
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.9, ptr noundef %36) #6
  %38 = load ptr, ptr @stderr, align 8, !tbaa !18
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str.7) #6
  br label %40

40:                                               ; preds = %35, %25
  %41 = mul nsw i32 %7, 3
  %42 = mul nsw i32 %41, %7
  %43 = sext i32 %42 to i64
  %44 = shl nsw i64 %43, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 %44, i1 false)
  tail call void @MatNd_destroy(ptr noundef %9) #5
  tail call void @MatNd_destroy(ptr noundef %10) #5
  tail call void @MatNd_destroy(ptr noundef %11) #5
  br label %67

45:                                               ; preds = %._crit_edge
  %46 = tail call ptr @MatNd_create(i32 noundef %7, i32 noundef 3) #5
  tail call void @MatNd_mul(ptr noundef %46, ptr noundef %11, ptr noundef %10) #5
  %47 = mul nsw i32 %7, 3
  %48 = tail call ptr @MatNd_create(i32 noundef %47, i32 noundef %7) #5
  tail call void @RcsGraph_bodyPointHessian(ptr noundef nonnull %2, ptr noundef %.0.lcssa, ptr noundef nonnull @RCS_GRADIENTTESTS_BODYPT1, ptr noundef null, ptr noundef %48) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  %49 = mul nsw i32 %7, %7
  call void @MatNd_fromPtr(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %4, i32 noundef %49, i32 noundef 3, ptr noundef %0) #5
  call void @MatNd_PinvHessian2(ptr noundef nonnull %4, ptr noundef %9, ptr noundef %48, ptr noundef null, ptr noundef %11, ptr noundef %46, i1 noundef zeroext false) #5
  call void @MatNd_destroy(ptr noundef %9) #5
  call void @MatNd_destroy(ptr noundef %10) #5
  call void @MatNd_destroy(ptr noundef %11) #5
  call void @MatNd_destroy(ptr noundef %46) #5
  call void @MatNd_destroy(ptr noundef %48) #5
  %50 = call double (...) @Timer_getTime() #5
  %51 = fsub double %50, %5
  %52 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !18
  %.not73 = icmp eq ptr %52, null
  br i1 %.not73, label %55, label %53

53:                                               ; preds = %45
  %54 = fmul double %51, 1.000000e+03
  call void (i32, ptr, ptr, i32, ptr, ...) %52(i32 noundef 5, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_hessianPinv2, i32 noundef 1187, ptr noundef nonnull @.str.8, double noundef %54) #5
  br label %55

55:                                               ; preds = %53, %45
  %56 = load i32, ptr @RcsLogLevel, align 4, !tbaa !20
  %57 = icmp sgt i32 %56, 4
  br i1 %57, label %58, label %66

58:                                               ; preds = %55
  %59 = load ptr, ptr @stderr, align 8, !tbaa !18
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_hessianPinv2, i32 noundef 1187) #6
  %61 = load ptr, ptr @stderr, align 8, !tbaa !18
  %62 = fmul double %51, 1.000000e+03
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef nonnull @.str.8, double noundef %62) #6
  %64 = load ptr, ptr @stderr, align 8, !tbaa !18
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %64, ptr noundef nonnull @.str.7) #6
  br label %66

66:                                               ; preds = %58, %55
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  br label %67

67:                                               ; preds = %66, %40
  ret void
}

declare void @MatNd_addConstToDiag(ptr noundef, double noundef) local_unnamed_addr #3

declare void @MatNd_PinvHessian2(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { 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, !7, i64 168}
!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 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}
!19 = !{!13, !7, i64 72}
!20 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass