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

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

%class.R3Polyline = type { %class.R3Curve, ptr, ptr, ptr, i32, %class.R3Box }
%class.R3Curve = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Point = type { [3 x 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 uwtable
define dso_local void @_ZN10R3Polyline9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(8) %1) unnamed_addr #1 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) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %20, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 4
  %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) #5
  br label %23

13:                                               ; preds = %7
  %14 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %class.R3Point, ptr %15, i64 %17
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN7R3Point9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 8 dereferenceable(8) %19)
  br label %20

20:                                               ; preds = %13
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !19

23:                                               ; preds = %12
  %24 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %25 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %24, i32 noundef 0)
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %25, i32 noundef 2)
  store double 0x47EFFFFFE0000000, ptr %26, align 8, !tbaa !21
  %27 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %27, i32 noundef 0)
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %28, i32 noundef 1)
  store double 0x47EFFFFFE0000000, ptr %29, align 8, !tbaa !21
  %30 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %31 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %30, i32 noundef 0)
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %31, i32 noundef 0)
  store double 0x47EFFFFFE0000000, ptr %32, align 8, !tbaa !21
  %33 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %34 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %33, i32 noundef 1)
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %34, i32 noundef 2)
  store double 0xC7EFFFFFE0000000, ptr %35, align 8, !tbaa !21
  %36 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %37 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %36, i32 noundef 1)
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %37, i32 noundef 1)
  store double 0xC7EFFFFFE0000000, ptr %38, align 8, !tbaa !21
  %39 = getelementptr inbounds %class.R3Polyline, ptr %6, i32 0, i32 5
  %40 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %39, i32 noundef 1)
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %40, i32 noundef 0)
  store double 0xC7EFFFFFE0000000, ptr %41, align 8, !tbaa !21
  ret void
}

declare void @_ZN7R3Point9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { inlinehint 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTS10R3Polyline", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !15, i64 40}
!13 = !{!"_ZTS7R3Curve", !14, i64 0}
!14 = !{!"_ZTS7R3Shape"}
!15 = !{!"_ZTS5R3Box", !16, i64 0, !17, i64 8, !17, i64 32}
!16 = !{!"_ZTS7R3Solid", !14, i64 0}
!17 = !{!"_ZTS7R3Point", !7, i64 0}
!18 = !{!12, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !22, i64 0}
!22 = !{!"double", !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"

%class.R3Point = type { [3 x double] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10R3Polyline9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(8) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %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 8
  br label %20

._crit_edge:                                      ; preds = %20, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 0)
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %8, i32 noundef 2)
  store double 0x47EFFFFFE0000000, ptr %9, align 8, !tbaa !16
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 0)
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef 1)
  store double 0x47EFFFFFE0000000, ptr %11, align 8, !tbaa !16
  %12 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 0)
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %12, i32 noundef 0)
  store double 0x47EFFFFFE0000000, ptr %13, align 8, !tbaa !16
  %14 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 1)
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %14, i32 noundef 2)
  store double 0xC7EFFFFFE0000000, ptr %15, align 8, !tbaa !16
  %16 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 1)
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %16, i32 noundef 1)
  store double 0xC7EFFFFFE0000000, ptr %17, align 8, !tbaa !16
  %18 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %7, i32 noundef 1)
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %18, i32 noundef 0)
  store double 0xC7EFFFFFE0000000, ptr %19, align 8, !tbaa !16
  ret void

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = load ptr, ptr %6, align 8, !tbaa !18
  %22 = getelementptr inbounds %class.R3Point, ptr %21, i64 %indvars.iv
  tail call void @_ZN7R3Point9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(24) %22, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %3, align 8, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %20, label %._crit_edge, !llvm.loop !19
}

declare void @_ZN7R3Point9TransformERK16R3Transformation(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { "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 = { 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 #3 = { inlinehint 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" }

!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, !12, i64 32}
!6 = !{!"_ZTS10R3Polyline", !7, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !12, i64 32, !13, i64 40}
!7 = !{!"_ZTS7R3Curve", !8, i64 0}
!8 = !{!"_ZTS7R3Shape"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"_ZTS5R3Box", !14, i64 0, !15, i64 8, !15, i64 32}
!14 = !{!"_ZTS7R3Solid", !8, i64 0}
!15 = !{!"_ZTS7R3Point", !10, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !10, i64 0}
!18 = !{!6, !9, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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