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

; 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.R3MeshPropertySet = type { ptr, %class.RNArray }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }

@stderr = external global ptr, align 8
@.str.20 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; 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
declare dso_local void @_ZN17R3MeshPropertySet6InsertEP14R3MeshProperty(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #1 align 2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN17R3MeshPropertySet12ReadPropertyEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [1024 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1024, ptr %6) #7
  %14 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call ptr @strcpy(ptr noundef %14, ptr noundef %15) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %17 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  %18 = call noundef ptr @strrchr(ptr noundef %17, i32 noundef 47) #8
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %2
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i32 1
  store ptr %23, ptr %7, align 8, !tbaa !5
  br label %26

24:                                               ; preds = %2
  %25 = getelementptr inbounds [1024 x i8], ptr %6, i64 0, i64 0
  store ptr %25, ptr %7, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %24, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call noundef ptr @strrchr(ptr noundef %27, i32 noundef 46) #8
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  store i8 0, ptr %32, align 1, !tbaa !9
  br label %33

33:                                               ; preds = %31, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %34 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 1096) #9
  %35 = getelementptr inbounds %struct.R3MeshPropertySet, ptr %13, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !10
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN14R3MeshPropertyC1EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096) %34, ptr noundef %36, ptr noundef %37, ptr noundef null)
          to label %38 unwind label %45

38:                                               ; preds = %33
  store ptr %34, ptr %9, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %49, label %41

41:                                               ; preds = %38
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.20, ptr noundef %43) #7
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %60

45:                                               ; preds = %33
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %10, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %11, align 4
  call void @_ZdlPvm(ptr noundef %34, i64 noundef 1096) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 1024, ptr %6) #7
  br label %62

49:                                               ; preds = %38
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call noundef i32 @_ZN14R3MeshProperty4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(1096) %50, ptr noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %58, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.21, ptr noundef %56) #7
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %60

58:                                               ; preds = %49
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN17R3MeshPropertySet6InsertEP14R3MeshProperty(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef %59)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %60

60:                                               ; preds = %58, %54, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 1024, ptr %6) #7
  %61 = load i32, ptr %3, align 4
  ret i32 %61

62:                                               ; preds = %45
  %63 = load ptr, ptr %10, align 8
  %64 = load i32, ptr %11, align 4
  %65 = insertvalue { ptr, i32 } poison, ptr %63, 0
  %66 = insertvalue { ptr, i32 } %65, i32 %64, 1
  resume { ptr, i32 } %66
}

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

declare void @_ZN14R3MeshPropertyC1EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef, ptr noundef, ptr noundef) unnamed_addr #5

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

declare noundef i32 @_ZN14R3MeshProperty4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef) #5

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 = { 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 = { nounwind willreturn memory(read) "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 = { "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 = { nobuiltin 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"_ZTS17R3MeshPropertySet", !6, i64 0, !12, i64 8}
!12 = !{!"_ZTS7RNArrayIP14R3MeshPropertyE", !13, i64 0}
!13 = !{!"_ZTS8RNVArray", !6, i64 0, !14, i64 8, !14, i64 12}
!14 = !{!"int", !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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.21 = external hidden unnamed_addr constant [31 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17R3MeshPropertySet6InsertEP14R3MeshProperty(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare noundef ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN17R3MeshPropertySet12ReadPropertyEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca [1024 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #8
  %4 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %1) #8
  %5 = call noundef ptr @strrchr(ptr noundef nonnull dereferenceable(1) %3, i32 noundef 47) #9
  %.not = icmp eq ptr %5, null
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  %.016 = select i1 %.not, ptr %3, ptr %6
  %7 = call noundef ptr @strrchr(ptr noundef nonnull dereferenceable(1) %.016, i32 noundef 46) #9
  %.not19 = icmp eq ptr %7, null
  br i1 %.not19, label %9, label %8

8:                                                ; preds = %2
  store i8 0, ptr %7, align 1, !tbaa !5
  br label %9

9:                                                ; preds = %8, %2
  %10 = call noalias noundef nonnull dereferenceable(1096) ptr @_Znwm(i64 noundef 1096) #10
  %11 = load ptr, ptr %0, align 8, !tbaa !8
  invoke void @_ZN14R3MeshPropertyC1EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096) %10, ptr noundef %11, ptr noundef nonnull %.016, ptr noundef null)
          to label %14 unwind label %12

12:                                               ; preds = %9
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %10, i64 noundef 1096) #11
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #8
  resume { ptr, i32 } %13

14:                                               ; preds = %9
  %15 = call noundef i32 @_ZN14R3MeshProperty4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(1096) %10, ptr noundef %1)
  %.not20 = icmp eq i32 %15, 0
  br i1 %.not20, label %16, label %19

16:                                               ; preds = %14
  %17 = load ptr, ptr @stderr, align 8, !tbaa !14
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.21, ptr noundef %1) #12
  br label %20

19:                                               ; preds = %14
  call void @_ZN17R3MeshPropertySet6InsertEP14R3MeshProperty(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %10)
  br label %20

20:                                               ; preds = %19, %16
  %.0 = phi i32 [ 1, %19 ], [ 0, %16 ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #8
  ret i32 %.0
}

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

declare void @_ZN14R3MeshPropertyC1EP6R3MeshPKcPKd(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef, ptr noundef, ptr noundef) unnamed_addr #5

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #6

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

declare noundef i32 @_ZN14R3MeshProperty4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(1096), ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress 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 = { 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { nobuiltin 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }
attributes #12 = { cold 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTS17R3MeshPropertySet", !10, i64 0, !11, i64 8}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"_ZTS7RNArrayIP14R3MeshPropertyE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !10, i64 0, !13, i64 8, !13, i64 12}
!13 = !{!"int", !6, i64 0}
!14 = !{!10, !10, i64 0}


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