; 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 }
%struct.HTr = type { [3 x double], [3 x [3 x double]] }
%struct._RcsJoint = type { ptr, double, double, double, double, double, double, double, i8, i32, i32, i32, i32, ptr, %struct.HTr, double, double, double, double, i32, ptr, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [76 x i8], align 1
@x_target_qprop = external hidden global [3 x double], align 16
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@__func__.test_qprop_ts3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [55 x i8], align 1
@.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

; 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 @Vec3d_sub(ptr noundef, ptr noundef, ptr 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 double @MatNd_rwPinv(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

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

31:                                               ; preds = %43, %3
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %46

35:                                               ; preds = %31
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._RcsBody, ptr %36, i32 0, i32 18
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %41, ptr %10, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %40, %35
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %44)
  store ptr %45, ptr %11, align 8, !tbaa !5
  br label %31, !llvm.loop !18

46:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store double 1.000000e-03, ptr %13, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = call ptr @MatNd_create(i32 noundef %47, i32 noundef 1)
  store ptr %48, ptr %14, align 8, !tbaa !5
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._MatNd, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %60

54:                                               ; preds = %46
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._RcsBody, ptr %55, i32 0, i32 10
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  %58 = getelementptr inbounds %struct.HTr, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [3 x double], ptr %58, i64 0, i64 0
  br label %62

60:                                               ; preds = %46
  %61 = call ptr (...) @Vec3d_zeroVec()
  br label %62

62:                                               ; preds = %60, %54
  %63 = phi ptr [ %59, %54 ], [ %61, %60 ]
  call void @Vec3d_sub(ptr noundef %51, ptr noundef %63, ptr noundef @x_target_qprop)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = call ptr @MatNd_create(i32 noundef %64, i32 noundef %65)
  store ptr %66, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = call ptr @MatNd_create(i32 noundef %67, i32 noundef %68)
  store ptr %69, ptr %16, align 8, !tbaa !5
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  call void @RcsGraph_bodyPointJacobian(ptr noundef %70, ptr noundef %71, ptr noundef %72, ptr noundef null, ptr noundef %73)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = call double @MatNd_rwPinv(ptr noundef %74, ptr noundef %75, ptr noundef null, ptr noundef null)
  store double %76, ptr %17, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #4
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_fromPtr(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %18, i32 noundef %77, i32 noundef 1, ptr noundef %78)
  %79 = load double, ptr %17, align 8, !tbaa !20
  %80 = fcmp olt double %79, 1.000000e-03
  br i1 %80, label %81, label %123

81:                                               ; preds = %62
  br label %82

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

85:                                               ; preds = %82
  %86 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %87 = load double, ptr %17, align 8, !tbaa !20
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = icmp ne ptr %88, null
  br i1 %89, label %90, label %94

90:                                               ; preds = %85
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._RcsBody, ptr %91, i32 0, i32 6
  %93 = load ptr, ptr %92, align 8, !tbaa !24
  br label %95

94:                                               ; preds = %85
  br label %95

95:                                               ; preds = %94, %90
  %96 = phi ptr [ %93, %90 ], [ @.str.5, %94 ]
  call void (i32, ptr, ptr, i32, ptr, ...) %86(i32 noundef 1, ptr noundef @.str.2, ptr noundef @__func__.test_qprop_ts3, i32 noundef 750, ptr noundef @.str.4, double noundef %87, double noundef 1.000000e-03, ptr noundef %96)
  br label %97

97:                                               ; preds = %95, %82
  %98 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %99 = icmp sle i32 1, %98
  br i1 %99, label %100, label %117

100:                                              ; preds = %97
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.6, ptr noundef @.str.2, ptr noundef @__func__.test_qprop_ts3, i32 noundef 750) #4
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = load double, ptr %17, align 8, !tbaa !20
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %111

107:                                              ; preds = %100
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct._RcsBody, ptr %108, i32 0, i32 6
  %110 = load ptr, ptr %109, align 8, !tbaa !24
  br label %112

111:                                              ; preds = %100
  br label %112

112:                                              ; preds = %111, %107
  %113 = phi ptr [ %110, %107 ], [ @.str.5, %111 ]
  %114 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.4, double noundef %104, double noundef 1.000000e-03, ptr noundef %113) #4
  %115 = load ptr, ptr @stderr, align 8, !tbaa !5
  %116 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %115, ptr noundef @.str.7) #4
  br label %117

117:                                              ; preds = %112, %97
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  call void @MatNd_setZero(ptr noundef %18)
  %120 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %120)
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %121)
  %122 = load ptr, ptr %16, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %122)
  store i32 1, ptr %19, align 4
  br label %180

123:                                              ; preds = %62
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MatNd_mul(ptr noundef %18, ptr noundef %124, ptr noundef %125)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct._RcsGraph, ptr %126, i32 0, i32 0
  %128 = load ptr, ptr %127, align 8, !tbaa !13
  store ptr %128, ptr %20, align 8, !tbaa !5
  br label %129

129:                                              ; preds = %173, %123
  %130 = load ptr, ptr %20, align 8, !tbaa !5
  %131 = icmp ne ptr %130, null
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  store i32 7, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %176

133:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %134 = load ptr, ptr %20, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._RcsBody, ptr %134, i32 0, i32 18
  %136 = load ptr, ptr %135, align 8, !tbaa !14
  store ptr %136, ptr %21, align 8, !tbaa !5
  br label %137

137:                                              ; preds = %168, %133
  %138 = load ptr, ptr %21, align 8, !tbaa !5
  %139 = icmp ne ptr %138, null
  br i1 %139, label %141, label %140

140:                                              ; preds = %137
  store i32 10, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  br label %172

141:                                              ; preds = %137
  %142 = load ptr, ptr %21, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._RcsJoint, ptr %142, i32 0, i32 12
  %144 = load i32, ptr %143, align 8, !tbaa !25
  %145 = icmp ne i32 %144, -1
  br i1 %145, label %146, label %167

146:                                              ; preds = %141
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct._RcsGraph, ptr %147, i32 0, i32 4
  %149 = load ptr, ptr %148, align 8, !tbaa !28
  %150 = getelementptr inbounds %struct._MatNd, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !21
  %152 = load ptr, ptr %21, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct._RcsJoint, ptr %152, i32 0, i32 11
  %154 = load i32, ptr %153, align 4, !tbaa !29
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds double, ptr %151, i64 %155
  %157 = load double, ptr %156, align 8, !tbaa !20
  %158 = getelementptr inbounds %struct._MatNd, ptr %18, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !21
  %160 = load ptr, ptr %21, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct._RcsJoint, ptr %160, i32 0, i32 12
  %162 = load i32, ptr %161, align 8, !tbaa !25
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds double, ptr %159, i64 %163
  %165 = load double, ptr %164, align 8, !tbaa !20
  %166 = fadd double %165, %157
  store double %166, ptr %164, align 8, !tbaa !20
  br label %167

167:                                              ; preds = %146, %141
  br label %168

168:                                              ; preds = %167
  %169 = load ptr, ptr %21, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._RcsJoint, ptr %169, i32 0, i32 23
  %171 = load ptr, ptr %170, align 8, !tbaa !30
  store ptr %171, ptr %21, align 8, !tbaa !5
  br label %137, !llvm.loop !31

172:                                              ; preds = %140
  br label %173

173:                                              ; preds = %172
  %174 = load ptr, ptr %20, align 8, !tbaa !5
  %175 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef %174)
  store ptr %175, ptr %20, align 8, !tbaa !5
  br label %129, !llvm.loop !32

176:                                              ; preds = %132
  %177 = load ptr, ptr %14, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %177)
  %178 = load ptr, ptr %15, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %178)
  %179 = load ptr, ptr %16, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %179)
  store i32 0, ptr %19, align 4
  br label %180

180:                                              ; preds = %176, %119
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %181 = load i32, ptr %19, align 4
  switch i32 %181, label %183 [
    i32 0, label %182
    i32 1, label %182
  ]

182:                                              ; preds = %180, %180
  ret void

183:                                              ; preds = %180
  unreachable
}

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) #3

declare ptr @Vec3d_zeroVec(...) #3

declare void @MatNd_setZero(ptr noundef) #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 = { 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 = !{!12, !6, i64 0}
!14 = !{!15, !6, i64 168}
!15 = !{!"_RcsBody", !16, i64 0, !17, i64 8, !10, i64 12, !7, i64 16, !7, i64 40, !16, 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}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!16, !16, i64 0}
!21 = !{!22, !6, i64 0}
!22 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !17, i64 20}
!23 = !{!15, !6, i64 104}
!24 = !{!15, !6, i64 72}
!25 = !{!26, !10, i64 80}
!26 = !{!"_RcsJoint", !6, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56, !17, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !6, i64 88, !27, i64 96, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !10, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!27 = !{!"", !7, i64 0, !7, i64 24}
!28 = !{!12, !6, i64 1856}
!29 = !{!26, !10, i64 76}
!30 = !{!26, !6, i64 256}
!31 = distinct !{!31, !19}
!32 = distinct !{!32, !19}


; 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
@x_target_qprop = external hidden global [3 x double], align 16
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@__func__.test_qprop_ts3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [55 x i8], align 1
@.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

; 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 @Vec3d_sub(ptr noundef, ptr noundef, ptr 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 double @MatNd_rwPinv(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

; Function Attrs: nounwind uwtable
define dso_local void @test_qprop_ts3(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 = getelementptr inbounds i8, ptr %2, i64 1852
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !11
  %.not61 = icmp eq ptr %7, null
  br i1 %.not61, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %3
  %8 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef 1) #4
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  br label %18

._crit_edge:                                      ; preds = %.lr.ph
  %10 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef 1) #4
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %.not55 = icmp eq ptr %spec.select, null
  br i1 %.not55, label %18, label %15

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

15:                                               ; preds = %._crit_edge
  %16 = getelementptr inbounds i8, ptr %spec.select, i64 104
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  br label %22

18:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %19 = phi ptr [ %9, %._crit_edge.thread ], [ %11, %._crit_edge ]
  %20 = phi ptr [ %8, %._crit_edge.thread ], [ %10, %._crit_edge ]
  %21 = tail call ptr (...) @Vec3d_zeroVec() #4
  br label %22

22:                                               ; preds = %18, %15
  %.not5579 = phi i1 [ false, %15 ], [ true, %18 ]
  %23 = phi ptr [ %11, %15 ], [ %19, %18 ]
  %24 = phi ptr [ %10, %15 ], [ %20, %18 ]
  %.050.lcssa77 = phi ptr [ %spec.select, %15 ], [ null, %18 ]
  %25 = phi ptr [ %17, %15 ], [ %21, %18 ]
  tail call void @Vec3d_sub(ptr noundef %23, ptr noundef %25, ptr noundef nonnull @x_target_qprop) #4
  %26 = tail call ptr @MatNd_create(i32 noundef 3, i32 noundef %6) #4
  %27 = tail call ptr @MatNd_create(i32 noundef %6, i32 noundef 3) #4
  tail call void @RcsGraph_bodyPointJacobian(ptr noundef nonnull %2, ptr noundef %.050.lcssa77, ptr noundef null, ptr noundef null, ptr noundef %26) #4
  %28 = tail call double @MatNd_rwPinv(ptr noundef %27, ptr noundef %26, ptr noundef null, ptr noundef null) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @MatNd_fromPtr(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %4, i32 noundef %6, i32 noundef 1, ptr noundef %0) #4
  %29 = fcmp olt double %28, 1.000000e-03
  br i1 %29, label %30, label %54

30:                                               ; preds = %22
  %31 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !21
  %.not59 = icmp eq ptr %31, null
  br i1 %.not59, label %38, label %32

32:                                               ; preds = %30
  br i1 %.not5579, label %36, label %33

33:                                               ; preds = %32
  %34 = getelementptr inbounds i8, ptr %.050.lcssa77, i64 72
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  br label %36

36:                                               ; preds = %32, %33
  %37 = phi ptr [ %35, %33 ], [ @.str.5, %32 ]
  call void (i32, ptr, ptr, i32, ptr, ...) %31(i32 noundef 1, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_qprop_ts3, i32 noundef 750, ptr noundef nonnull @.str.4, double noundef %28, double noundef 1.000000e-03, ptr noundef %37) #4
  br label %38

38:                                               ; preds = %36, %30
  %39 = load i32, ptr @RcsLogLevel, align 4, !tbaa !23
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %41, label %53

41:                                               ; preds = %38
  %42 = load ptr, ptr @stderr, align 8, !tbaa !21
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.test_qprop_ts3, i32 noundef 750) #5
  %44 = load ptr, ptr @stderr, align 8, !tbaa !21
  br i1 %.not5579, label %48, label %45

45:                                               ; preds = %41
  %46 = getelementptr inbounds i8, ptr %.050.lcssa77, i64 72
  %47 = load ptr, ptr %46, align 8, !tbaa !22
  br label %48

48:                                               ; preds = %41, %45
  %49 = phi ptr [ %47, %45 ], [ @.str.5, %41 ]
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.4, double noundef %28, double noundef 1.000000e-03, ptr noundef %49) #5
  %51 = load ptr, ptr @stderr, align 8, !tbaa !21
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str.7) #5
  br label %53

53:                                               ; preds = %48, %38
  call void @MatNd_setZero(ptr noundef nonnull %4) #4
  br label %._crit_edge74

54:                                               ; preds = %22
  call void @MatNd_mul(ptr noundef nonnull %4, ptr noundef %27, ptr noundef nonnull %24) #4
  %55 = load ptr, ptr %2, align 8, !tbaa !11
  %.not5670 = icmp eq ptr %55, null
  br i1 %.not5670, label %._crit_edge74, label %.lr.ph73

.lr.ph73:                                         ; preds = %54
  %56 = getelementptr inbounds i8, ptr %2, i64 1856
  br label %57

57:                                               ; preds = %.lr.ph73, %._crit_edge69
  %.04971 = phi ptr [ %55, %.lr.ph73 ], [ %60, %._crit_edge69 ]
  %58 = getelementptr inbounds i8, ptr %.04971, i64 168
  %.064 = load ptr, ptr %58, align 8, !tbaa !21
  %.not5765 = icmp eq ptr %.064, null
  br i1 %.not5765, label %._crit_edge69, label %.lr.ph68

.lr.ph68:                                         ; preds = %57
  %59 = load ptr, ptr %4, align 8
  br label %61

._crit_edge69:                                    ; preds = %76, %57
  %60 = call ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef nonnull %.04971) #4
  %.not56 = icmp eq ptr %60, null
  br i1 %.not56, label %._crit_edge74, label %57, !llvm.loop !24

61:                                               ; preds = %.lr.ph68, %76
  %.066 = phi ptr [ %.064, %.lr.ph68 ], [ %.0, %76 ]
  %62 = getelementptr inbounds i8, ptr %.066, i64 80
  %63 = load i32, ptr %62, align 8, !tbaa !25
  %.not58 = icmp eq i32 %63, -1
  br i1 %.not58, label %76, label %64

64:                                               ; preds = %61
  %65 = load ptr, ptr %56, align 8, !tbaa !28
  %66 = load ptr, ptr %65, align 8, !tbaa !12
  %67 = getelementptr inbounds i8, ptr %.066, i64 76
  %68 = load i32, ptr %67, align 4, !tbaa !29
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %66, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !30
  %72 = sext i32 %63 to i64
  %73 = getelementptr inbounds double, ptr %59, i64 %72
  %74 = load double, ptr %73, align 8, !tbaa !30
  %75 = fadd double %71, %74
  store double %75, ptr %73, align 8, !tbaa !30
  br label %76

76:                                               ; preds = %61, %64
  %77 = getelementptr inbounds i8, ptr %.066, i64 256
  %.0 = load ptr, ptr %77, align 8, !tbaa !21
  %.not57 = icmp eq ptr %.0, null
  br i1 %.not57, label %._crit_edge69, label %61, !llvm.loop !31

._crit_edge74:                                    ; preds = %._crit_edge69, %54, %53
  call void @MatNd_destroy(ptr noundef nonnull %24) #4
  call void @MatNd_destroy(ptr noundef %26) #4
  call void @MatNd_destroy(ptr noundef %27) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  ret void
}

declare ptr @RcsBody_depthFirstTraversalGetNext(ptr noundef) local_unnamed_addr #3

declare ptr @Vec3d_zeroVec(...) local_unnamed_addr #3

declare void @MatNd_setZero(ptr noundef) 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 = { nounwind }
attributes #5 = { 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 0}
!13 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 20}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!16, !7, i64 168}
!16 = !{!"_RcsBody", !17, i64 0, !14, i64 8, !10, i64 12, !8, i64 16, !8, i64 40, !17, 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}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!16, !7, i64 104}
!21 = !{!7, !7, i64 0}
!22 = !{!16, !7, i64 72}
!23 = !{!10, !10, i64 0}
!24 = distinct !{!24, !19}
!25 = !{!26, !10, i64 80}
!26 = !{!"_RcsJoint", !7, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !14, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !27, i64 96, !17, i64 192, !17, i64 200, !17, i64 208, !17, i64 216, !10, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264}
!27 = !{!"", !8, i64 0, !8, i64 24}
!28 = !{!6, !7, i64 1856}
!29 = !{!26, !10, i64 76}
!30 = !{!17, !17, i64 0}
!31 = distinct !{!31, !19}


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