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

; 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.PlyProperty = type { ptr, i32, i32, i32, i32, i32, i32, i32 }
%struct.PlyFile = type { ptr, i32, float, i32, ptr, i32, ptr, i32, ptr, ptr, ptr }
%struct.PlyElement = type { ptr, i32, i32, i32, ptr, ptr, i32, i32 }

@.str.9 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z8my_allociiPc(i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #2

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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @equal_strings(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12add_propertyP7PlyFilePPc(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %7 = call noundef ptr @_Z8my_allociiPc(i32 noundef 40, i32 noundef 2534, ptr noundef @.str.9)
  store ptr %7, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds ptr, ptr %8, i64 1
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = call i32 @equal_strings(ptr noundef %10, ptr noundef @.str.74)
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %34

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %14, i64 2
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = call noundef i32 @_Z13get_prop_typePc(ptr noundef %16)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.PlyProperty, ptr %18, i32 0, i32 5
  store i32 %17, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %20, i64 3
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = call noundef i32 @_Z13get_prop_typePc(ptr noundef %22)
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.PlyProperty, ptr %24, i32 0, i32 1
  store i32 %23, ptr %25, align 8, !tbaa !12
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds ptr, ptr %26, i64 4
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = call noalias ptr @strdup(ptr noundef %28) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.PlyProperty, ptr %30, i32 0, i32 0
  store ptr %29, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.PlyProperty, ptr %32, i32 0, i32 4
  store i32 1, ptr %33, align 4, !tbaa !14
  br label %49

34:                                               ; preds = %2
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %35, i64 1
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = call noundef i32 @_Z13get_prop_typePc(ptr noundef %37)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.PlyProperty, ptr %39, i32 0, i32 1
  store i32 %38, ptr %40, align 8, !tbaa !12
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds ptr, ptr %41, i64 2
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = call noalias ptr @strdup(ptr noundef %43) #5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.PlyProperty, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !13
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.PlyProperty, ptr %47, i32 0, i32 4
  store i32 0, ptr %48, align 4, !tbaa !14
  br label %49

49:                                               ; preds = %34, %13
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.PlyFile, ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.PlyFile, ptr %53, i32 0, i32 3
  %55 = load i32, ptr %54, align 8, !tbaa !18
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %52, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  store ptr %59, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.PlyElement, ptr %60, i32 0, i32 3
  %62 = load i32, ptr %61, align 8, !tbaa !19
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %68

64:                                               ; preds = %49
  %65 = call noundef ptr @_Z8my_allociiPc(i32 noundef 8, i32 noundef 2553, ptr noundef @.str.9)
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.PlyElement, ptr %66, i32 0, i32 4
  store ptr %65, ptr %67, align 8, !tbaa !21
  br label %81

68:                                               ; preds = %49
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.PlyElement, ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %70, align 8, !tbaa !21
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.PlyElement, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 8, !tbaa !19
  %75 = add nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = mul i64 8, %76
  %78 = call ptr @realloc(ptr noundef %71, i64 noundef %77) #6
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.PlyElement, ptr %79, i32 0, i32 4
  store ptr %78, ptr %80, align 8, !tbaa !21
  br label %81

81:                                               ; preds = %68, %64
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.PlyElement, ptr %83, i32 0, i32 4
  %85 = load ptr, ptr %84, align 8, !tbaa !21
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.PlyElement, ptr %86, i32 0, i32 3
  %88 = load i32, ptr %87, align 8, !tbaa !19
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds ptr, ptr %85, i64 %89
  store ptr %82, ptr %90, align 8, !tbaa !5
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.PlyElement, ptr %91, i32 0, i32 3
  %93 = load i32, ptr %92, align 8, !tbaa !19
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %92, align 8, !tbaa !19
  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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13get_prop_typePc(ptr noundef) #1

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 = { nounwind allocsize(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 #4 = { 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 }
attributes #6 = { nounwind allocsize(1) }

!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, !11, i64 24}
!10 = !{!"_ZTS11PlyProperty", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !6, i64 0}
!14 = !{!10, !11, i64 20}
!15 = !{!16, !6, i64 24}
!16 = !{!"_ZTS7PlyFile", !6, i64 0, !11, i64 8, !17, i64 12, !11, i64 16, !6, i64 24, !11, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!17 = !{!"float", !7, i64 0}
!18 = !{!16, !11, i64 16}
!19 = !{!20, !11, i64 16}
!20 = !{!"_ZTS10PlyElement", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44}
!21 = !{!20, !6, i64 24}


; 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.9 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z8my_allociiPc(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @equal_strings(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z12add_propertyP7PlyFilePPc(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call noundef ptr @_Z8my_allociiPc(i32 noundef 40, i32 noundef 2534, ptr noundef nonnull @.str.9)
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call i32 @equal_strings(ptr noundef %5, ptr noundef nonnull @.str.74)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %13, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call noundef i32 @_Z13get_prop_typePc(ptr noundef %9)
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %10, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %1, i64 24
  br label %13

13:                                               ; preds = %2, %7
  %.sink31 = phi ptr [ %12, %7 ], [ %4, %2 ]
  %.sink27 = phi i64 [ 32, %7 ], [ 16, %2 ]
  %.sink = phi i32 [ 1, %7 ], [ 0, %2 ]
  %14 = load ptr, ptr %.sink31, align 8, !tbaa !5
  %15 = tail call noundef i32 @_Z13get_prop_typePc(ptr noundef %14)
  %16 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %15, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %1, i64 %.sink27
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = tail call noalias ptr @strdup(ptr noundef %18) #3
  store ptr %19, ptr %3, align 8
  %20 = getelementptr inbounds i8, ptr %3, i64 20
  store i32 %.sink, ptr %20, align 4
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = sext i32 %24 to i64
  %26 = getelementptr ptr, ptr %22, i64 %25
  %27 = getelementptr i8, ptr %26, i64 -8
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load i32, ptr %29, align 8, !tbaa !17
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %13
  %33 = tail call noundef ptr @_Z8my_allociiPc(i32 noundef 8, i32 noundef 2553, ptr noundef nonnull @.str.9)
  %34 = getelementptr inbounds i8, ptr %28, i64 24
  store ptr %33, ptr %34, align 8, !tbaa !19
  br label %42

35:                                               ; preds = %13
  %36 = getelementptr inbounds i8, ptr %28, i64 24
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = add nsw i32 %30, 1
  %39 = sext i32 %38 to i64
  %40 = shl nsw i64 %39, 3
  %41 = tail call ptr @realloc(ptr noundef %37, i64 noundef %40) #4
  store ptr %41, ptr %36, align 8, !tbaa !19
  br label %42

42:                                               ; preds = %35, %32
  %43 = phi ptr [ %41, %35 ], [ %33, %32 ]
  %44 = load i32, ptr %29, align 8, !tbaa !17
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds ptr, ptr %43, i64 %45
  store ptr %3, ptr %46, align 8, !tbaa !5
  %47 = add nsw i32 %44, 1
  store i32 %47, ptr %29, align 8, !tbaa !17
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13get_prop_typePc(ptr noundef) local_unnamed_addr #0

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(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #4 = { nounwind allocsize(1) }

!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, !11, i64 24}
!10 = !{!"_ZTS11PlyProperty", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !6, i64 24}
!14 = !{!"_ZTS7PlyFile", !6, i64 0, !11, i64 8, !15, i64 12, !11, i64 16, !6, i64 24, !11, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !11, i64 16}
!17 = !{!18, !11, i64 16}
!18 = !{!"_ZTS10PlyElement", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44}
!19 = !{!18, !6, i64 24}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass