; LLVM IR from MRPT/mrpt :: 3rdparty/xspublic/xstypes (xsquaternion)

; 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.XsQuaternion = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { double, double, double, double }

@XsMath_one = external constant double, align 8
@XsMath_tinyValue = external constant double, align 8
@XsMath_two = external constant double, align 8
@XsMath_pt25 = external constant double, align 8

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

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @XsQuaternion_fromRotationMatrix(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call i32 @XsMatrix_dimensionsMatch(ptr noundef %8, i64 noundef 3, i64 noundef 3)
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %13, label %11

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  call void @XsQuaternion_destruct(ptr noundef %12)
  store i32 1, ptr %7, align 4
  br label %258

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call double @XsMatrix_value(ptr noundef %14, i64 noundef 0, i64 noundef 0)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call double @XsMatrix_value(ptr noundef %16, i64 noundef 1, i64 noundef 1)
  %18 = fadd double %15, %17
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call double @XsMatrix_value(ptr noundef %19, i64 noundef 2, i64 noundef 2)
  %21 = fadd double %18, %20
  %22 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %23 = fadd double %21, %22
  store double %23, ptr %5, align 8, !tbaa !9
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = fmul double %24, %25
  %27 = load double, ptr @XsMath_tinyValue, align 8, !tbaa !9
  %28 = fcmp oge double %26, %27
  br i1 %28, label %29, label %73

29:                                               ; preds = %13
  %30 = load double, ptr @XsMath_two, align 8, !tbaa !9
  %31 = load double, ptr %5, align 8, !tbaa !9
  %32 = call double @sqrt(double noundef %31) #4
  %33 = fmul double %30, %32
  store double %33, ptr %6, align 8, !tbaa !9
  %34 = load double, ptr @XsMath_pt25, align 8, !tbaa !9
  %35 = load double, ptr %6, align 8, !tbaa !9
  %36 = fmul double %34, %35
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.XsQuaternion, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.anon, ptr %38, i32 0, i32 0
  store double %36, ptr %39, align 8, !tbaa !11
  %40 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %41 = load double, ptr %6, align 8, !tbaa !9
  %42 = fdiv double %40, %41
  store double %42, ptr %6, align 8, !tbaa !9
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call double @XsMatrix_value(ptr noundef %43, i64 noundef 1, i64 noundef 2)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call double @XsMatrix_value(ptr noundef %45, i64 noundef 2, i64 noundef 1)
  %47 = fsub double %44, %46
  %48 = load double, ptr %6, align 8, !tbaa !9
  %49 = fmul double %47, %48
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.XsQuaternion, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 1
  store double %49, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call double @XsMatrix_value(ptr noundef %53, i64 noundef 2, i64 noundef 0)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = call double @XsMatrix_value(ptr noundef %55, i64 noundef 0, i64 noundef 2)
  %57 = fsub double %54, %56
  %58 = load double, ptr %6, align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.XsQuaternion, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.anon, ptr %61, i32 0, i32 2
  store double %59, ptr %62, align 8, !tbaa !11
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = call double @XsMatrix_value(ptr noundef %63, i64 noundef 0, i64 noundef 1)
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = call double @XsMatrix_value(ptr noundef %65, i64 noundef 1, i64 noundef 0)
  %67 = fsub double %64, %66
  %68 = load double, ptr %6, align 8, !tbaa !9
  %69 = fmul double %67, %68
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.XsQuaternion, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %struct.anon, ptr %71, i32 0, i32 3
  store double %69, ptr %72, align 8, !tbaa !11
  br label %255

73:                                               ; preds = %13
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call double @XsMatrix_value(ptr noundef %74, i64 noundef 0, i64 noundef 0)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call double @XsMatrix_value(ptr noundef %76, i64 noundef 1, i64 noundef 1)
  %78 = fcmp ogt double %75, %77
  br i1 %78, label %79, label %139

79:                                               ; preds = %73
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = call double @XsMatrix_value(ptr noundef %80, i64 noundef 0, i64 noundef 0)
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = call double @XsMatrix_value(ptr noundef %82, i64 noundef 2, i64 noundef 2)
  %84 = fcmp ogt double %81, %83
  br i1 %84, label %85, label %139

85:                                               ; preds = %79
  %86 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = call double @XsMatrix_value(ptr noundef %87, i64 noundef 0, i64 noundef 0)
  %89 = fadd double %86, %88
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = call double @XsMatrix_value(ptr noundef %90, i64 noundef 1, i64 noundef 1)
  %92 = fsub double %89, %91
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = call double @XsMatrix_value(ptr noundef %93, i64 noundef 2, i64 noundef 2)
  %95 = fsub double %92, %94
  store double %95, ptr %5, align 8, !tbaa !9
  %96 = load double, ptr @XsMath_two, align 8, !tbaa !9
  %97 = load double, ptr %5, align 8, !tbaa !9
  %98 = call double @sqrt(double noundef %97) #4
  %99 = fmul double %96, %98
  store double %99, ptr %6, align 8, !tbaa !9
  %100 = load double, ptr @XsMath_pt25, align 8, !tbaa !9
  %101 = load double, ptr %6, align 8, !tbaa !9
  %102 = fmul double %100, %101
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.XsQuaternion, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds %struct.anon, ptr %104, i32 0, i32 1
  store double %102, ptr %105, align 8, !tbaa !11
  %106 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %107 = load double, ptr %6, align 8, !tbaa !9
  %108 = fdiv double %106, %107
  store double %108, ptr %6, align 8, !tbaa !9
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = call double @XsMatrix_value(ptr noundef %109, i64 noundef 1, i64 noundef 2)
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = call double @XsMatrix_value(ptr noundef %111, i64 noundef 2, i64 noundef 1)
  %113 = fsub double %110, %112
  %114 = load double, ptr %6, align 8, !tbaa !9
  %115 = fmul double %113, %114
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.XsQuaternion, ptr %116, i32 0, i32 0
  %118 = getelementptr inbounds %struct.anon, ptr %117, i32 0, i32 0
  store double %115, ptr %118, align 8, !tbaa !11
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = call double @XsMatrix_value(ptr noundef %119, i64 noundef 0, i64 noundef 1)
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = call double @XsMatrix_value(ptr noundef %121, i64 noundef 1, i64 noundef 0)
  %123 = fadd double %120, %122
  %124 = load double, ptr %6, align 8, !tbaa !9
  %125 = fmul double %123, %124
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.XsQuaternion, ptr %126, i32 0, i32 0
  %128 = getelementptr inbounds %struct.anon, ptr %127, i32 0, i32 2
  store double %125, ptr %128, align 8, !tbaa !11
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  %130 = call double @XsMatrix_value(ptr noundef %129, i64 noundef 2, i64 noundef 0)
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = call double @XsMatrix_value(ptr noundef %131, i64 noundef 0, i64 noundef 2)
  %133 = fadd double %130, %132
  %134 = load double, ptr %6, align 8, !tbaa !9
  %135 = fmul double %133, %134
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.XsQuaternion, ptr %136, i32 0, i32 0
  %138 = getelementptr inbounds %struct.anon, ptr %137, i32 0, i32 3
  store double %135, ptr %138, align 8, !tbaa !11
  br label %254

139:                                              ; preds = %79, %73
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = call double @XsMatrix_value(ptr noundef %140, i64 noundef 1, i64 noundef 1)
  %142 = load ptr, ptr %4, align 8, !tbaa !5
  %143 = call double @XsMatrix_value(ptr noundef %142, i64 noundef 2, i64 noundef 2)
  %144 = fcmp ogt double %141, %143
  br i1 %144, label %145, label %199

145:                                              ; preds = %139
  %146 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %147 = load ptr, ptr %4, align 8, !tbaa !5
  %148 = call double @XsMatrix_value(ptr noundef %147, i64 noundef 1, i64 noundef 1)
  %149 = fadd double %146, %148
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  %151 = call double @XsMatrix_value(ptr noundef %150, i64 noundef 0, i64 noundef 0)
  %152 = fsub double %149, %151
  %153 = load ptr, ptr %4, align 8, !tbaa !5
  %154 = call double @XsMatrix_value(ptr noundef %153, i64 noundef 2, i64 noundef 2)
  %155 = fsub double %152, %154
  store double %155, ptr %5, align 8, !tbaa !9
  %156 = load double, ptr @XsMath_two, align 8, !tbaa !9
  %157 = load double, ptr %5, align 8, !tbaa !9
  %158 = call double @sqrt(double noundef %157) #4
  %159 = fmul double %156, %158
  store double %159, ptr %6, align 8, !tbaa !9
  %160 = load double, ptr @XsMath_pt25, align 8, !tbaa !9
  %161 = load double, ptr %6, align 8, !tbaa !9
  %162 = fmul double %160, %161
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.XsQuaternion, ptr %163, i32 0, i32 0
  %165 = getelementptr inbounds %struct.anon, ptr %164, i32 0, i32 2
  store double %162, ptr %165, align 8, !tbaa !11
  %166 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %167 = load double, ptr %6, align 8, !tbaa !9
  %168 = fdiv double %166, %167
  store double %168, ptr %6, align 8, !tbaa !9
  %169 = load ptr, ptr %4, align 8, !tbaa !5
  %170 = call double @XsMatrix_value(ptr noundef %169, i64 noundef 2, i64 noundef 0)
  %171 = load ptr, ptr %4, align 8, !tbaa !5
  %172 = call double @XsMatrix_value(ptr noundef %171, i64 noundef 0, i64 noundef 2)
  %173 = fsub double %170, %172
  %174 = load double, ptr %6, align 8, !tbaa !9
  %175 = fmul double %173, %174
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.XsQuaternion, ptr %176, i32 0, i32 0
  %178 = getelementptr inbounds %struct.anon, ptr %177, i32 0, i32 0
  store double %175, ptr %178, align 8, !tbaa !11
  %179 = load ptr, ptr %4, align 8, !tbaa !5
  %180 = call double @XsMatrix_value(ptr noundef %179, i64 noundef 0, i64 noundef 1)
  %181 = load ptr, ptr %4, align 8, !tbaa !5
  %182 = call double @XsMatrix_value(ptr noundef %181, i64 noundef 1, i64 noundef 0)
  %183 = fadd double %180, %182
  %184 = load double, ptr %6, align 8, !tbaa !9
  %185 = fmul double %183, %184
  %186 = load ptr, ptr %3, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.XsQuaternion, ptr %186, i32 0, i32 0
  %188 = getelementptr inbounds %struct.anon, ptr %187, i32 0, i32 1
  store double %185, ptr %188, align 8, !tbaa !11
  %189 = load ptr, ptr %4, align 8, !tbaa !5
  %190 = call double @XsMatrix_value(ptr noundef %189, i64 noundef 1, i64 noundef 2)
  %191 = load ptr, ptr %4, align 8, !tbaa !5
  %192 = call double @XsMatrix_value(ptr noundef %191, i64 noundef 2, i64 noundef 1)
  %193 = fadd double %190, %192
  %194 = load double, ptr %6, align 8, !tbaa !9
  %195 = fmul double %193, %194
  %196 = load ptr, ptr %3, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.XsQuaternion, ptr %196, i32 0, i32 0
  %198 = getelementptr inbounds %struct.anon, ptr %197, i32 0, i32 3
  store double %195, ptr %198, align 8, !tbaa !11
  br label %253

199:                                              ; preds = %139
  %200 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %201 = load ptr, ptr %4, align 8, !tbaa !5
  %202 = call double @XsMatrix_value(ptr noundef %201, i64 noundef 2, i64 noundef 2)
  %203 = fadd double %200, %202
  %204 = load ptr, ptr %4, align 8, !tbaa !5
  %205 = call double @XsMatrix_value(ptr noundef %204, i64 noundef 0, i64 noundef 0)
  %206 = fsub double %203, %205
  %207 = load ptr, ptr %4, align 8, !tbaa !5
  %208 = call double @XsMatrix_value(ptr noundef %207, i64 noundef 1, i64 noundef 1)
  %209 = fsub double %206, %208
  store double %209, ptr %5, align 8, !tbaa !9
  %210 = load double, ptr @XsMath_two, align 8, !tbaa !9
  %211 = load double, ptr %5, align 8, !tbaa !9
  %212 = call double @sqrt(double noundef %211) #4
  %213 = fmul double %210, %212
  store double %213, ptr %6, align 8, !tbaa !9
  %214 = load double, ptr @XsMath_pt25, align 8, !tbaa !9
  %215 = load double, ptr %6, align 8, !tbaa !9
  %216 = fmul double %214, %215
  %217 = load ptr, ptr %3, align 8, !tbaa !5
  %218 = getelementptr inbounds %struct.XsQuaternion, ptr %217, i32 0, i32 0
  %219 = getelementptr inbounds %struct.anon, ptr %218, i32 0, i32 3
  store double %216, ptr %219, align 8, !tbaa !11
  %220 = load double, ptr @XsMath_one, align 8, !tbaa !9
  %221 = load double, ptr %6, align 8, !tbaa !9
  %222 = fdiv double %220, %221
  store double %222, ptr %6, align 8, !tbaa !9
  %223 = load ptr, ptr %4, align 8, !tbaa !5
  %224 = call double @XsMatrix_value(ptr noundef %223, i64 noundef 0, i64 noundef 1)
  %225 = load ptr, ptr %4, align 8, !tbaa !5
  %226 = call double @XsMatrix_value(ptr noundef %225, i64 noundef 1, i64 noundef 0)
  %227 = fsub double %224, %226
  %228 = load double, ptr %6, align 8, !tbaa !9
  %229 = fmul double %227, %228
  %230 = load ptr, ptr %3, align 8, !tbaa !5
  %231 = getelementptr inbounds %struct.XsQuaternion, ptr %230, i32 0, i32 0
  %232 = getelementptr inbounds %struct.anon, ptr %231, i32 0, i32 0
  store double %229, ptr %232, align 8, !tbaa !11
  %233 = load ptr, ptr %4, align 8, !tbaa !5
  %234 = call double @XsMatrix_value(ptr noundef %233, i64 noundef 2, i64 noundef 0)
  %235 = load ptr, ptr %4, align 8, !tbaa !5
  %236 = call double @XsMatrix_value(ptr noundef %235, i64 noundef 0, i64 noundef 2)
  %237 = fadd double %234, %236
  %238 = load double, ptr %6, align 8, !tbaa !9
  %239 = fmul double %237, %238
  %240 = load ptr, ptr %3, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.XsQuaternion, ptr %240, i32 0, i32 0
  %242 = getelementptr inbounds %struct.anon, ptr %241, i32 0, i32 1
  store double %239, ptr %242, align 8, !tbaa !11
  %243 = load ptr, ptr %4, align 8, !tbaa !5
  %244 = call double @XsMatrix_value(ptr noundef %243, i64 noundef 1, i64 noundef 2)
  %245 = load ptr, ptr %4, align 8, !tbaa !5
  %246 = call double @XsMatrix_value(ptr noundef %245, i64 noundef 2, i64 noundef 1)
  %247 = fadd double %244, %246
  %248 = load double, ptr %6, align 8, !tbaa !9
  %249 = fmul double %247, %248
  %250 = load ptr, ptr %3, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.XsQuaternion, ptr %250, i32 0, i32 0
  %252 = getelementptr inbounds %struct.anon, ptr %251, i32 0, i32 2
  store double %249, ptr %252, align 8, !tbaa !11
  br label %253

253:                                              ; preds = %199, %145
  br label %254

254:                                              ; preds = %253, %85
  br label %255

255:                                              ; preds = %254, %29
  %256 = load ptr, ptr %3, align 8, !tbaa !5
  %257 = load ptr, ptr %3, align 8, !tbaa !5
  call void @XsQuaternion_inverse(ptr noundef %256, ptr noundef %257)
  store i32 0, ptr %7, align 4
  br label %258

258:                                              ; preds = %255, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %259 = load i32, ptr %7, align 4
  switch i32 %259, label %261 [
    i32 0, label %260
    i32 1, label %260
  ]

260:                                              ; preds = %258, %258
  ret void

261:                                              ; preds = %258
  unreachable
}

declare i32 @XsMatrix_dimensionsMatch(ptr noundef, i64 noundef, i64 noundef) #3

declare double @XsMatrix_value(ptr noundef, i64 noundef, i64 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!7, !7, i64 0}


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

@XsMath_one = external local_unnamed_addr constant double, align 8
@XsMath_tinyValue = external local_unnamed_addr constant double, align 8
@XsMath_two = external local_unnamed_addr constant double, align 8
@XsMath_pt25 = external local_unnamed_addr constant double, align 8

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @XsQuaternion_fromRotationMatrix(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @XsMatrix_dimensionsMatch(ptr noundef %1, i64 noundef 3, i64 noundef 3) #3
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %5

4:                                                ; preds = %2
  tail call void @XsQuaternion_destruct(ptr noundef %0)
  br label %132

5:                                                ; preds = %2
  %6 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %7 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %8 = fadd double %6, %7
  %9 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %10 = fadd double %8, %9
  %11 = load double, ptr @XsMath_one, align 8, !tbaa !5
  %12 = fadd double %10, %11
  %13 = fmul double %12, %12
  %14 = load double, ptr @XsMath_tinyValue, align 8, !tbaa !5
  %15 = fcmp ult double %13, %14
  br i1 %15, label %37, label %16

16:                                               ; preds = %5
  %17 = load double, ptr @XsMath_two, align 8, !tbaa !5
  %18 = tail call double @sqrt(double noundef %12) #3
  %19 = fmul double %17, %18
  %20 = load double, ptr @XsMath_pt25, align 8, !tbaa !5
  %21 = fmul double %20, %19
  store double %21, ptr %0, align 8, !tbaa !9
  %22 = fdiv double %11, %19
  %23 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 2) #3
  %24 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 1) #3
  %25 = fsub double %23, %24
  %26 = fmul double %22, %25
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  store double %26, ptr %27, align 8, !tbaa !9
  %28 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 0) #3
  %29 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 2) #3
  %30 = fsub double %28, %29
  %31 = fmul double %22, %30
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  store double %31, ptr %32, align 8, !tbaa !9
  %33 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 1) #3
  %34 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 0) #3
  %35 = fsub double %33, %34
  %36 = fmul double %22, %35
  br label %130

37:                                               ; preds = %5
  %38 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %39 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %40 = fcmp ogt double %38, %39
  br i1 %40, label %41, label %72

41:                                               ; preds = %37
  %42 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %43 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %44 = fcmp ogt double %42, %43
  br i1 %44, label %45, label %72

45:                                               ; preds = %41
  %46 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %47 = fadd double %11, %46
  %48 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %49 = fsub double %47, %48
  %50 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %51 = fsub double %49, %50
  %52 = load double, ptr @XsMath_two, align 8, !tbaa !5
  %53 = tail call double @sqrt(double noundef %51) #3
  %54 = fmul double %52, %53
  %55 = load double, ptr @XsMath_pt25, align 8, !tbaa !5
  %56 = fmul double %55, %54
  %57 = getelementptr inbounds i8, ptr %0, i64 8
  store double %56, ptr %57, align 8, !tbaa !9
  %58 = fdiv double %11, %54
  %59 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 2) #3
  %60 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 1) #3
  %61 = fsub double %59, %60
  %62 = fmul double %58, %61
  store double %62, ptr %0, align 8, !tbaa !9
  %63 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 1) #3
  %64 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 0) #3
  %65 = fadd double %63, %64
  %66 = fmul double %58, %65
  %67 = getelementptr inbounds i8, ptr %0, i64 16
  store double %66, ptr %67, align 8, !tbaa !9
  %68 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 0) #3
  %69 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 2) #3
  %70 = fadd double %68, %69
  %71 = fmul double %58, %70
  br label %130

72:                                               ; preds = %41, %37
  %73 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %74 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %75 = fcmp ogt double %73, %74
  br i1 %75, label %76, label %103

76:                                               ; preds = %72
  %77 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %78 = fadd double %11, %77
  %79 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %80 = fsub double %78, %79
  %81 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %82 = fsub double %80, %81
  %83 = load double, ptr @XsMath_two, align 8, !tbaa !5
  %84 = tail call double @sqrt(double noundef %82) #3
  %85 = fmul double %83, %84
  %86 = load double, ptr @XsMath_pt25, align 8, !tbaa !5
  %87 = fmul double %86, %85
  %88 = getelementptr inbounds i8, ptr %0, i64 16
  store double %87, ptr %88, align 8, !tbaa !9
  %89 = fdiv double %11, %85
  %90 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 0) #3
  %91 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 2) #3
  %92 = fsub double %90, %91
  %93 = fmul double %89, %92
  store double %93, ptr %0, align 8, !tbaa !9
  %94 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 1) #3
  %95 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 0) #3
  %96 = fadd double %94, %95
  %97 = fmul double %89, %96
  %98 = getelementptr inbounds i8, ptr %0, i64 8
  store double %97, ptr %98, align 8, !tbaa !9
  %99 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 2) #3
  %100 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 1) #3
  %101 = fadd double %99, %100
  %102 = fmul double %89, %101
  br label %130

103:                                              ; preds = %72
  %104 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 2) #3
  %105 = fadd double %11, %104
  %106 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 0) #3
  %107 = fsub double %105, %106
  %108 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 1) #3
  %109 = fsub double %107, %108
  %110 = load double, ptr @XsMath_two, align 8, !tbaa !5
  %111 = tail call double @sqrt(double noundef %109) #3
  %112 = fmul double %110, %111
  %113 = load double, ptr @XsMath_pt25, align 8, !tbaa !5
  %114 = fmul double %113, %112
  %115 = getelementptr inbounds i8, ptr %0, i64 24
  store double %114, ptr %115, align 8, !tbaa !9
  %116 = fdiv double %11, %112
  %117 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 1) #3
  %118 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 0) #3
  %119 = fsub double %117, %118
  %120 = fmul double %116, %119
  store double %120, ptr %0, align 8, !tbaa !9
  %121 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 0) #3
  %122 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 0, i64 noundef 2) #3
  %123 = fadd double %121, %122
  %124 = fmul double %116, %123
  %125 = getelementptr inbounds i8, ptr %0, i64 8
  store double %124, ptr %125, align 8, !tbaa !9
  %126 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 1, i64 noundef 2) #3
  %127 = tail call double @XsMatrix_value(ptr noundef %1, i64 noundef 2, i64 noundef 1) #3
  %128 = fadd double %126, %127
  %129 = fmul double %116, %128
  br label %130

130:                                              ; preds = %45, %103, %76, %16
  %.sink89 = phi i64 [ 24, %45 ], [ 16, %103 ], [ 24, %76 ], [ 24, %16 ]
  %.sink = phi double [ %71, %45 ], [ %129, %103 ], [ %102, %76 ], [ %36, %16 ]
  %131 = getelementptr inbounds i8, ptr %0, i64 %.sink89
  store double %.sink, ptr %131, align 8, !tbaa !9
  tail call void @XsQuaternion_inverse(ptr noundef nonnull %0, ptr noundef nonnull %0)
  br label %132

132:                                              ; preds = %130, %4
  ret void
}

declare i32 @XsMatrix_dimensionsMatch(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

declare double @XsMatrix_value(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


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