; LLVM IR from pmla/polyhedral-template-matching :: ptm_quat.ll (ZN3ptm29rotation_matrix_to_quaternionEPdS0_)

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ptm29rotation_matrix_to_quaternionEPdS0_(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = 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) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 0
  %24 = load double, ptr %23, align 8, !tbaa !9
  store double %24, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 1
  %27 = load double, ptr %26, align 8, !tbaa !9
  store double %27, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds double, ptr %28, i64 2
  %30 = load double, ptr %29, align 8, !tbaa !9
  store double %30, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %31, i64 3
  %33 = load double, ptr %32, align 8, !tbaa !9
  store double %33, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds double, ptr %34, i64 4
  %36 = load double, ptr %35, align 8, !tbaa !9
  store double %36, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %37, i64 5
  %39 = load double, ptr %38, align 8, !tbaa !9
  store double %39, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 6
  %42 = load double, ptr %41, align 8, !tbaa !9
  store double %42, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 7
  %45 = load double, ptr %44, align 8, !tbaa !9
  store double %45, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 8
  %48 = load double, ptr %47, align 8, !tbaa !9
  store double %48, ptr %13, align 8, !tbaa !9
  %49 = load double, ptr %5, align 8, !tbaa !9
  %50 = fadd double 1.000000e+00, %49
  %51 = load double, ptr %9, align 8, !tbaa !9
  %52 = fadd double %50, %51
  %53 = load double, ptr %13, align 8, !tbaa !9
  %54 = fadd double %52, %53
  %55 = fdiv double %54, 4.000000e+00
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %56, i64 0
  store double %55, ptr %57, align 8, !tbaa !9
  %58 = load double, ptr %5, align 8, !tbaa !9
  %59 = fadd double 1.000000e+00, %58
  %60 = load double, ptr %9, align 8, !tbaa !9
  %61 = fsub double %59, %60
  %62 = load double, ptr %13, align 8, !tbaa !9
  %63 = fsub double %61, %62
  %64 = fdiv double %63, 4.000000e+00
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %65, i64 1
  store double %64, ptr %66, align 8, !tbaa !9
  %67 = load double, ptr %5, align 8, !tbaa !9
  %68 = fsub double 1.000000e+00, %67
  %69 = load double, ptr %9, align 8, !tbaa !9
  %70 = fadd double %68, %69
  %71 = load double, ptr %13, align 8, !tbaa !9
  %72 = fsub double %70, %71
  %73 = fdiv double %72, 4.000000e+00
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 2
  store double %73, ptr %75, align 8, !tbaa !9
  %76 = load double, ptr %5, align 8, !tbaa !9
  %77 = fsub double 1.000000e+00, %76
  %78 = load double, ptr %9, align 8, !tbaa !9
  %79 = fsub double %77, %78
  %80 = load double, ptr %13, align 8, !tbaa !9
  %81 = fadd double %79, %80
  %82 = fdiv double %81, 4.000000e+00
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds double, ptr %83, i64 3
  store double %82, ptr %84, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store double 0.000000e+00, ptr %14, align 8, !tbaa !9
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds double, ptr %85, i64 0
  %87 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %86)
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = call double @sqrt(double noundef %88) #5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds double, ptr %90, i64 0
  store double %89, ptr %91, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store double 0.000000e+00, ptr %15, align 8, !tbaa !9
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds double, ptr %92, i64 1
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %93)
  %95 = load double, ptr %94, align 8, !tbaa !9
  %96 = call double @sqrt(double noundef %95) #5
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds double, ptr %97, i64 1
  store double %96, ptr %98, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store double 0.000000e+00, ptr %16, align 8, !tbaa !9
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds double, ptr %99, i64 2
  %101 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %100)
  %102 = load double, ptr %101, align 8, !tbaa !9
  %103 = call double @sqrt(double noundef %102) #5
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds double, ptr %104, i64 2
  store double %103, ptr %105, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store double 0.000000e+00, ptr %17, align 8, !tbaa !9
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds double, ptr %106, i64 3
  %108 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %107)
  %109 = load double, ptr %108, align 8, !tbaa !9
  %110 = call double @sqrt(double noundef %109) #5
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds double, ptr %111, i64 3
  store double %110, ptr %112, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds double, ptr %113, i64 0
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds double, ptr %115, i64 1
  %117 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %114, ptr noundef nonnull align 8 dereferenceable(8) %116)
  %118 = load double, ptr %117, align 8, !tbaa !9
  store double %118, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds double, ptr %119, i64 2
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds double, ptr %121, i64 3
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %120, ptr noundef nonnull align 8 dereferenceable(8) %122)
  %124 = load double, ptr %123, align 8, !tbaa !9
  store double %124, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %126 = load double, ptr %125, align 8, !tbaa !9
  store double %126, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 0, ptr %21, align 4, !tbaa !11
  store i32 0, ptr %21, align 4, !tbaa !11
  br label %127

127:                                              ; preds = %140, %2
  %128 = load i32, ptr %21, align 4, !tbaa !11
  %129 = icmp slt i32 %128, 4
  br i1 %129, label %130, label %143

130:                                              ; preds = %127
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = load i32, ptr %21, align 4, !tbaa !11
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds double, ptr %131, i64 %133
  %135 = load double, ptr %134, align 8, !tbaa !9
  %136 = load double, ptr %20, align 8, !tbaa !9
  %137 = fcmp oeq double %135, %136
  br i1 %137, label %138, label %139

138:                                              ; preds = %130
  br label %143

139:                                              ; preds = %130
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %21, align 4, !tbaa !11
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %21, align 4, !tbaa !11
  br label %127, !llvm.loop !13

143:                                              ; preds = %138, %127
  %144 = load i32, ptr %21, align 4, !tbaa !11
  %145 = icmp eq i32 %144, 0
  br i1 %145, label %146, label %180

146:                                              ; preds = %143
  %147 = load double, ptr %12, align 8, !tbaa !9
  %148 = load double, ptr %10, align 8, !tbaa !9
  %149 = fsub double %147, %148
  %150 = fcmp oge double %149, 0.000000e+00
  %151 = zext i1 %150 to i64
  %152 = select i1 %150, i32 1, i32 -1
  %153 = sitofp i32 %152 to double
  %154 = load ptr, ptr %4, align 8, !tbaa !5
  %155 = getelementptr inbounds double, ptr %154, i64 1
  %156 = load double, ptr %155, align 8, !tbaa !9
  %157 = fmul double %156, %153
  store double %157, ptr %155, align 8, !tbaa !9
  %158 = load double, ptr %7, align 8, !tbaa !9
  %159 = load double, ptr %11, align 8, !tbaa !9
  %160 = fsub double %158, %159
  %161 = fcmp oge double %160, 0.000000e+00
  %162 = zext i1 %161 to i64
  %163 = select i1 %161, i32 1, i32 -1
  %164 = sitofp i32 %163 to double
  %165 = load ptr, ptr %4, align 8, !tbaa !5
  %166 = getelementptr inbounds double, ptr %165, i64 2
  %167 = load double, ptr %166, align 8, !tbaa !9
  %168 = fmul double %167, %164
  store double %168, ptr %166, align 8, !tbaa !9
  %169 = load double, ptr %8, align 8, !tbaa !9
  %170 = load double, ptr %6, align 8, !tbaa !9
  %171 = fsub double %169, %170
  %172 = fcmp oge double %171, 0.000000e+00
  %173 = zext i1 %172 to i64
  %174 = select i1 %172, i32 1, i32 -1
  %175 = sitofp i32 %174 to double
  %176 = load ptr, ptr %4, align 8, !tbaa !5
  %177 = getelementptr inbounds double, ptr %176, i64 3
  %178 = load double, ptr %177, align 8, !tbaa !9
  %179 = fmul double %178, %175
  store double %179, ptr %177, align 8, !tbaa !9
  br label %294

180:                                              ; preds = %143
  %181 = load i32, ptr %21, align 4, !tbaa !11
  %182 = icmp eq i32 %181, 1
  br i1 %182, label %183, label %217

183:                                              ; preds = %180
  %184 = load double, ptr %12, align 8, !tbaa !9
  %185 = load double, ptr %10, align 8, !tbaa !9
  %186 = fsub double %184, %185
  %187 = fcmp oge double %186, 0.000000e+00
  %188 = zext i1 %187 to i64
  %189 = select i1 %187, i32 1, i32 -1
  %190 = sitofp i32 %189 to double
  %191 = load ptr, ptr %4, align 8, !tbaa !5
  %192 = getelementptr inbounds double, ptr %191, i64 0
  %193 = load double, ptr %192, align 8, !tbaa !9
  %194 = fmul double %193, %190
  store double %194, ptr %192, align 8, !tbaa !9
  %195 = load double, ptr %8, align 8, !tbaa !9
  %196 = load double, ptr %6, align 8, !tbaa !9
  %197 = fadd double %195, %196
  %198 = fcmp oge double %197, 0.000000e+00
  %199 = zext i1 %198 to i64
  %200 = select i1 %198, i32 1, i32 -1
  %201 = sitofp i32 %200 to double
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds double, ptr %202, i64 2
  %204 = load double, ptr %203, align 8, !tbaa !9
  %205 = fmul double %204, %201
  store double %205, ptr %203, align 8, !tbaa !9
  %206 = load double, ptr %7, align 8, !tbaa !9
  %207 = load double, ptr %11, align 8, !tbaa !9
  %208 = fadd double %206, %207
  %209 = fcmp oge double %208, 0.000000e+00
  %210 = zext i1 %209 to i64
  %211 = select i1 %209, i32 1, i32 -1
  %212 = sitofp i32 %211 to double
  %213 = load ptr, ptr %4, align 8, !tbaa !5
  %214 = getelementptr inbounds double, ptr %213, i64 3
  %215 = load double, ptr %214, align 8, !tbaa !9
  %216 = fmul double %215, %212
  store double %216, ptr %214, align 8, !tbaa !9
  br label %293

217:                                              ; preds = %180
  %218 = load i32, ptr %21, align 4, !tbaa !11
  %219 = icmp eq i32 %218, 2
  br i1 %219, label %220, label %254

220:                                              ; preds = %217
  %221 = load double, ptr %7, align 8, !tbaa !9
  %222 = load double, ptr %11, align 8, !tbaa !9
  %223 = fsub double %221, %222
  %224 = fcmp oge double %223, 0.000000e+00
  %225 = zext i1 %224 to i64
  %226 = select i1 %224, i32 1, i32 -1
  %227 = sitofp i32 %226 to double
  %228 = load ptr, ptr %4, align 8, !tbaa !5
  %229 = getelementptr inbounds double, ptr %228, i64 0
  %230 = load double, ptr %229, align 8, !tbaa !9
  %231 = fmul double %230, %227
  store double %231, ptr %229, align 8, !tbaa !9
  %232 = load double, ptr %8, align 8, !tbaa !9
  %233 = load double, ptr %6, align 8, !tbaa !9
  %234 = fadd double %232, %233
  %235 = fcmp oge double %234, 0.000000e+00
  %236 = zext i1 %235 to i64
  %237 = select i1 %235, i32 1, i32 -1
  %238 = sitofp i32 %237 to double
  %239 = load ptr, ptr %4, align 8, !tbaa !5
  %240 = getelementptr inbounds double, ptr %239, i64 1
  %241 = load double, ptr %240, align 8, !tbaa !9
  %242 = fmul double %241, %238
  store double %242, ptr %240, align 8, !tbaa !9
  %243 = load double, ptr %12, align 8, !tbaa !9
  %244 = load double, ptr %10, align 8, !tbaa !9
  %245 = fadd double %243, %244
  %246 = fcmp oge double %245, 0.000000e+00
  %247 = zext i1 %246 to i64
  %248 = select i1 %246, i32 1, i32 -1
  %249 = sitofp i32 %248 to double
  %250 = load ptr, ptr %4, align 8, !tbaa !5
  %251 = getelementptr inbounds double, ptr %250, i64 3
  %252 = load double, ptr %251, align 8, !tbaa !9
  %253 = fmul double %252, %249
  store double %253, ptr %251, align 8, !tbaa !9
  br label %292

254:                                              ; preds = %217
  %255 = load i32, ptr %21, align 4, !tbaa !11
  %256 = icmp eq i32 %255, 3
  br i1 %256, label %257, label %291

257:                                              ; preds = %254
  %258 = load double, ptr %8, align 8, !tbaa !9
  %259 = load double, ptr %6, align 8, !tbaa !9
  %260 = fsub double %258, %259
  %261 = fcmp oge double %260, 0.000000e+00
  %262 = zext i1 %261 to i64
  %263 = select i1 %261, i32 1, i32 -1
  %264 = sitofp i32 %263 to double
  %265 = load ptr, ptr %4, align 8, !tbaa !5
  %266 = getelementptr inbounds double, ptr %265, i64 0
  %267 = load double, ptr %266, align 8, !tbaa !9
  %268 = fmul double %267, %264
  store double %268, ptr %266, align 8, !tbaa !9
  %269 = load double, ptr %11, align 8, !tbaa !9
  %270 = load double, ptr %7, align 8, !tbaa !9
  %271 = fadd double %269, %270
  %272 = fcmp oge double %271, 0.000000e+00
  %273 = zext i1 %272 to i64
  %274 = select i1 %272, i32 1, i32 -1
  %275 = sitofp i32 %274 to double
  %276 = load ptr, ptr %4, align 8, !tbaa !5
  %277 = getelementptr inbounds double, ptr %276, i64 1
  %278 = load double, ptr %277, align 8, !tbaa !9
  %279 = fmul double %278, %275
  store double %279, ptr %277, align 8, !tbaa !9
  %280 = load double, ptr %12, align 8, !tbaa !9
  %281 = load double, ptr %10, align 8, !tbaa !9
  %282 = fadd double %280, %281
  %283 = fcmp oge double %282, 0.000000e+00
  %284 = zext i1 %283 to i64
  %285 = select i1 %283, i32 1, i32 -1
  %286 = sitofp i32 %285 to double
  %287 = load ptr, ptr %4, align 8, !tbaa !5
  %288 = getelementptr inbounds double, ptr %287, i64 2
  %289 = load double, ptr %288, align 8, !tbaa !9
  %290 = fmul double %289, %286
  store double %290, ptr %288, align 8, !tbaa !9
  br label %291

291:                                              ; preds = %257, %254
  br label %292

292:                                              ; preds = %291, %220
  br label %293

293:                                              ; preds = %292, %183
  br label %294

294:                                              ; preds = %293, %146
  %295 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3ptm20normalize_quaternionEPd(ptr noundef %295)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  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 %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

attributes #0 = { 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 #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3ptm20normalize_quaternionEPd(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3ptm29rotation_matrix_to_quaternionEPdS0_(ptr nocapture noundef readonly %0, ptr noundef nonnull %1) local_unnamed_addr #1 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = load double, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load <2 x double>, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fadd double %9, 1.000000e+00
  %25 = fadd double %24, %17
  %26 = fadd double %25, %23
  %27 = fmul double %26, 2.500000e-01
  store double %27, ptr %1, align 8, !tbaa !5
  %28 = fsub double %24, %17
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = fsub double 1.000000e+00, %9
  %31 = fadd double %30, %17
  %32 = getelementptr inbounds i8, ptr %1, i64 16
  %33 = insertelement <2 x double> poison, double %28, i64 0
  %34 = insertelement <2 x double> %33, double %31, i64 1
  %35 = insertelement <2 x double> poison, double %23, i64 0
  %36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
  %37 = fsub <2 x double> %34, %36
  %38 = fmul <2 x double> %37, <double 2.500000e-01, double 2.500000e-01>
  store <2 x double> %38, ptr %29, align 8, !tbaa !5
  %39 = fsub double %30, %17
  %40 = fadd double %39, %23
  %41 = fmul double %40, 2.500000e-01
  %42 = getelementptr inbounds i8, ptr %1, i64 24
  store double %41, ptr %42, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store double 0.000000e+00, ptr %3, align 8, !tbaa !5
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = call double @sqrt(double noundef %44) #4
  store double %45, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !5
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %29)
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = call double @sqrt(double noundef %47) #4
  store double %48, ptr %29, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %32)
  %50 = load double, ptr %49, align 8, !tbaa !5
  %51 = call double @sqrt(double noundef %50) #4
  store double %51, ptr %32, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %53 = load double, ptr %52, align 8, !tbaa !5
  %54 = call double @sqrt(double noundef %53) #4
  store double %54, ptr %42, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %29)
  %56 = load double, ptr %55, align 8, !tbaa !5
  store double %56, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %58 = load double, ptr %57, align 8, !tbaa !5
  store double %58, ptr %8, align 8, !tbaa !5
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %60 = load double, ptr %59, align 8, !tbaa !5
  %61 = load double, ptr %1, align 8, !tbaa !5
  %62 = fcmp oeq double %61, %60
  br i1 %62, label %72, label %63

63:                                               ; preds = %2
  %64 = load double, ptr %29, align 8, !tbaa !5
  %65 = fcmp oeq double %64, %60
  br i1 %65, label %81, label %66

66:                                               ; preds = %63
  %67 = load double, ptr %32, align 8, !tbaa !5
  %68 = fcmp oeq double %67, %60
  br i1 %68, label %94, label %69

69:                                               ; preds = %66
  %70 = load double, ptr %42, align 8, !tbaa !5
  %71 = fcmp oeq double %70, %60
  br i1 %71, label %107, label %.thread

72:                                               ; preds = %2
  %73 = insertelement <2 x double> poison, double %21, i64 0
  %74 = insertelement <2 x double> %73, double %13, i64 1
  %75 = fsub <2 x double> %74, %19
  %76 = fcmp oge <2 x double> %75, zeroinitializer
  %77 = load <2 x double>, ptr %29, align 8, !tbaa !5
  %78 = fneg <2 x double> %77
  %79 = select <2 x i1> %76, <2 x double> %77, <2 x double> %78
  store <2 x double> %79, ptr %29, align 8, !tbaa !5
  %80 = fsub double %15, %11
  br label %.thread.sink.split

81:                                               ; preds = %63
  %82 = extractelement <2 x double> %19, i64 0
  %83 = fsub double %21, %82
  %84 = fcmp oge double %83, 0.000000e+00
  %85 = fneg double %61
  %86 = select i1 %84, double %61, double %85
  store double %86, ptr %1, align 8, !tbaa !5
  %87 = fadd double %11, %15
  %88 = fcmp oge double %87, 0.000000e+00
  %89 = load double, ptr %32, align 8, !tbaa !5
  %90 = fneg double %89
  %91 = select i1 %88, double %89, double %90
  store double %91, ptr %32, align 8, !tbaa !5
  %92 = extractelement <2 x double> %19, i64 1
  %93 = fadd double %13, %92
  br label %.thread.sink.split

94:                                               ; preds = %66
  %95 = extractelement <2 x double> %19, i64 1
  %96 = fsub double %13, %95
  %97 = fcmp oge double %96, 0.000000e+00
  %98 = fneg double %61
  %99 = select i1 %97, double %61, double %98
  store double %99, ptr %1, align 8, !tbaa !5
  %100 = fadd double %11, %15
  %101 = fcmp oge double %100, 0.000000e+00
  %102 = load double, ptr %29, align 8, !tbaa !5
  %103 = fneg double %102
  %104 = select i1 %101, double %102, double %103
  store double %104, ptr %29, align 8, !tbaa !5
  %105 = extractelement <2 x double> %19, i64 0
  %106 = fadd double %105, %21
  br label %.thread.sink.split

107:                                              ; preds = %69
  %108 = fsub double %15, %11
  %109 = fcmp oge double %108, 0.000000e+00
  %110 = fneg double %61
  %111 = select i1 %109, double %61, double %110
  store double %111, ptr %1, align 8, !tbaa !5
  %112 = extractelement <2 x double> %19, i64 1
  %113 = fadd double %13, %112
  %114 = fcmp oge double %113, 0.000000e+00
  %115 = load double, ptr %29, align 8, !tbaa !5
  %116 = fneg double %115
  %117 = select i1 %114, double %115, double %116
  store double %117, ptr %29, align 8, !tbaa !5
  %118 = extractelement <2 x double> %19, i64 0
  %119 = fadd double %118, %21
  br label %.thread.sink.split

.thread.sink.split:                               ; preds = %72, %94, %107, %81
  %.sink = phi double [ %93, %81 ], [ %119, %107 ], [ %106, %94 ], [ %80, %72 ]
  %.sink95 = phi ptr [ %42, %81 ], [ %32, %107 ], [ %42, %94 ], [ %42, %72 ]
  %120 = fcmp oge double %.sink, 0.000000e+00
  %121 = load double, ptr %.sink95, align 8, !tbaa !5
  %122 = fneg double %121
  %123 = select i1 %120, double %121, double %122
  store double %123, ptr %.sink95, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %69
  call void @_ZN3ptm20normalize_quaternionEPd(ptr noundef nonnull %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass