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

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

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@_ZL18next_property_name = external hidden global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshPropertyC2EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %13, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 2
  store i32 0, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 3
  store ptr null, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %23

18:                                               ; preds = %4
  %19 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 1
  %20 = getelementptr inbounds [1024 x i8], ptr %19, i64 0, i64 0
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call ptr @strncpy(ptr noundef %20, ptr noundef %21, i64 noundef 1024) #7
  br label %29

23:                                               ; preds = %4
  %24 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 1
  %25 = getelementptr inbounds [1024 x i8], ptr %24, i64 0, i64 0
  %26 = load i32, ptr @_ZL18next_property_name, align 4, !tbaa !15
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @_ZL18next_property_name, align 4, !tbaa !15
  %28 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %25, ptr noundef @.str, i32 noundef %26) #7
  br label %29

29:                                               ; preds = %23, %18
  %30 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 1
  %31 = getelementptr inbounds [1024 x i8], ptr %30, i64 0, i64 1023
  store i8 0, ptr %31, align 1, !tbaa !16
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %32)
  %34 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 2
  store i32 %33, ptr %34, align 8, !tbaa !13
  %35 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %37, i64 8)
  %39 = extractvalue { i64, i1 } %38, 1
  %40 = extractvalue { i64, i1 } %38, 0
  %41 = select i1 %39, i64 -1, i64 %40
  %42 = call noalias noundef nonnull ptr @_Znam(i64 noundef %41) #8
  %43 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 3
  store ptr %42, ptr %43, align 8, !tbaa !14
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %68

46:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %47

47:                                               ; preds = %64, %46
  %48 = load i32, ptr %9, align 4, !tbaa !15
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %49)
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %67

53:                                               ; preds = %47
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !15
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds double, ptr %54, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !17
  %59 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = load i32, ptr %9, align 4, !tbaa !15
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %60, i64 %62
  store double %58, ptr %63, align 8, !tbaa !17
  br label %64

64:                                               ; preds = %53
  %65 = load i32, ptr %9, align 4, !tbaa !15
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !15
  br label %47, !llvm.loop !18

67:                                               ; preds = %52
  br label %85

68:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !15
  br label %69

69:                                               ; preds = %81, %68
  %70 = load i32, ptr %10, align 4, !tbaa !15
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %71)
  %73 = icmp slt i32 %70, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %84

75:                                               ; preds = %69
  %76 = getelementptr inbounds %struct.R3MeshProperty, ptr %11, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !14
  %78 = load i32, ptr %10, align 4, !tbaa !15
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %77, i64 %79
  store double 0.000000e+00, ptr %80, align 8, !tbaa !17
  br label %81

81:                                               ; preds = %75
  %82 = load i32, ptr %10, align 4, !tbaa !15
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %10, align 4, !tbaa !15
  br label %69, !llvm.loop !20

84:                                               ; preds = %74
  br label %85

85:                                               ; preds = %84, %67
  call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %11)
  ret void
}

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272)) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) #6 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 = { 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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }

!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, !6, i64 0}
!10 = !{!"_ZTS14R3MeshProperty", !6, i64 0, !7, i64 8, !11, i64 1032, !6, i64 1040, !12, i64 1048, !12, i64 1056, !12, i64 1064, !12, i64 1072, !12, i64 1080, !12, i64 1088}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !11, i64 1032}
!14 = !{!10, !6, i64 1040}
!15 = !{!11, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !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"

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@_ZL18next_property_name = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14R3MeshPropertyC2EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096) %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef readonly %3) unnamed_addr #0 align 2 {
  store ptr %1, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 1032
  store i32 0, ptr %5, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 1040
  store ptr null, ptr %6, align 8, !tbaa !13
  %.not = icmp eq ptr %2, null
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %.not, label %10, label %8

8:                                                ; preds = %4
  %9 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) %2, i64 noundef 1024) #6
  br label %14

10:                                               ; preds = %4
  %11 = load i32, ptr @_ZL18next_property_name, align 4, !tbaa !14
  %12 = add nsw i32 %11, 1
  store i32 %12, ptr @_ZL18next_property_name, align 4, !tbaa !14
  %13 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %11) #6
  br label %14

14:                                               ; preds = %10, %8
  %15 = getelementptr inbounds i8, ptr %0, i64 1031
  store i8 0, ptr %15, align 1, !tbaa !15
  %16 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %1)
  store i32 %16, ptr %5, align 8, !tbaa !12
  %17 = zext nneg i32 %16 to i64
  %18 = icmp slt i32 %16, 0
  %19 = shl nuw nsw i64 %17, 3
  %20 = select i1 %18, i64 -1, i64 %19
  %21 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #7
  store ptr %21, ptr %6, align 8, !tbaa !13
  %.not18 = icmp eq ptr %3, null
  %22 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %1)
  %23 = icmp sgt i32 %22, 0
  br i1 %.not18, label %.preheader, label %.preheader19

.preheader19:                                     ; preds = %14
  br i1 %23, label %.lr.ph, label %.loopexit

.preheader:                                       ; preds = %14
  br i1 %23, label %.lr.ph23, label %.loopexit

.lr.ph:                                           ; preds = %.preheader19, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader19 ]
  %24 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %25 = load double, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %6, align 8, !tbaa !13
  %27 = getelementptr inbounds double, ptr %26, i64 %indvars.iv
  store double %25, ptr %27, align 8, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %1)
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %.lr.ph, label %.loopexit, !llvm.loop !17

.lr.ph23:                                         ; preds = %.preheader, %.lr.ph23
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph23 ], [ 0, %.preheader ]
  %31 = load ptr, ptr %6, align 8, !tbaa !13
  %32 = getelementptr inbounds double, ptr %31, i64 %indvars.iv26
  store double 0.000000e+00, ptr %32, align 8, !tbaa !16
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %33 = tail call noundef i32 @_ZNK6R3Mesh9NVerticesEv(ptr noundef nonnull align 8 dereferenceable(272) %1)
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next27, %34
  br i1 %35, label %.lr.ph23, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph23, %.preheader19, %.preheader
  tail call void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096) %0)
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14R3MeshProperty15ResetStatisticsEv(ptr noundef nonnull align 8 dereferenceable(1096)) local_unnamed_addr #5 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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { 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 #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" }
attributes #4 = { nobuiltin allocsize(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 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }

!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, !7, i64 0}
!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, !10, i64 1032}
!13 = !{!6, !7, i64 1040}
!14 = !{!10, !10, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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