; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3MeshProperty.ll (ZN14R3MeshProperty3PowERKS_)

; 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.R3MeshProperty = type { ptr, [1024 x i8], i32, ptr, double, double, double, double, double, double }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshProperty3PowERKS_(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr noundef nonnull align 8 dereferenceable(1096) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %62, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = getelementptr inbounds %struct.R3MeshProperty, ptr %6, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp slt i32 %8, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %65

13:                                               ; preds = %7
  %14 = getelementptr inbounds %struct.R3MeshProperty, ptr %6, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !15
  %20 = fcmp oeq double %19, -1.000000e+00
  br i1 %20, label %21, label %22

21:                                               ; preds = %13
  br label %62

22:                                               ; preds = %13
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.R3MeshProperty, ptr %23, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = fcmp oeq double %29, -1.000000e+00
  br i1 %30, label %31, label %32

31:                                               ; preds = %22
  br label %62

32:                                               ; preds = %22
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.R3MeshProperty, ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = fcmp oeq double %39, 0.000000e+00
  br i1 %40, label %41, label %42

41:                                               ; preds = %32
  br label %62

42:                                               ; preds = %32
  %43 = getelementptr inbounds %struct.R3MeshProperty, ptr %6, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %44, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.R3MeshProperty, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !15
  %56 = call double @pow(double noundef %48, double noundef %55) #4
  %57 = getelementptr inbounds %struct.R3MeshProperty, ptr %6, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %58, i64 %60
  store double %56, ptr %61, align 8, !tbaa !15
  br label %62

62:                                               ; preds = %42, %41, %31, %21
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !16

65:                                               ; preds = %12
  call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %6)
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 1032}
!12 = !{!"_ZTS14R3MeshProperty", !6, i64 0, !7, i64 8, !10, i64 1032, !6, i64 1040, !13, i64 1048, !13, i64 1056, !13, i64 1064, !13, i64 1072, !13, i64 1080, !13, i64 1088}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 1040}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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 nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN14R3MeshProperty3PowERKS_(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(1096) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1032
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 1040
  %7 = getelementptr inbounds i8, ptr %1, i64 1040
  %.pre = load ptr, ptr %6, align 8, !tbaa !12
  br label %8

._crit_edge:                                      ; preds = %24, %2
  tail call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %0)
  ret void

8:                                                ; preds = %.lr.ph, %24
  %9 = phi i32 [ %4, %.lr.ph ], [ %25, %24 ]
  %10 = phi ptr [ %.pre, %.lr.ph ], [ %26, %24 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %11 = getelementptr inbounds double, ptr %10, i64 %indvars.iv
  %12 = load double, ptr %11, align 8, !tbaa !13
  %13 = fcmp oeq double %12, -1.000000e+00
  br i1 %13, label %24, label %14

14:                                               ; preds = %8
  %15 = load ptr, ptr %7, align 8, !tbaa !12
  %16 = getelementptr inbounds double, ptr %15, i64 %indvars.iv
  %17 = load double, ptr %16, align 8, !tbaa !13
  %18 = fcmp oeq double %17, -1.000000e+00
  %19 = fcmp oeq double %17, 0.000000e+00
  %or.cond = or i1 %18, %19
  br i1 %or.cond, label %24, label %20

20:                                               ; preds = %14
  %21 = tail call double @pow(double noundef %12, double noundef %17) #2
  %22 = load ptr, ptr %6, align 8, !tbaa !12
  %23 = getelementptr inbounds double, ptr %22, i64 %indvars.iv
  store double %21, ptr %23, align 8, !tbaa !13
  %.pre15 = load i32, ptr %3, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %14, %8, %20
  %25 = phi i32 [ %9, %14 ], [ %9, %8 ], [ %.pre15, %20 ]
  %26 = phi ptr [ %10, %14 ], [ %10, %8 ], [ %22, %20 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = sext i32 %25 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %8, label %._crit_edge, !llvm.loop !14
}

attributes #0 = { 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 #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 = { 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 1032}
!6 = !{!"_ZTS14R3MeshProperty", !7, i64 0, !8, i64 8, !10, i64 1032, !7, i64 1040, !11, i64 1048, !11, i64 1056, !11, i64 1064, !11, i64 1072, !11, i64 1080, !11, i64 1088}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 1040}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass