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

; 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.PlyElement = type { ptr, i32, i32, i32, ptr, ptr, i32, i32 }

@.str.9 = external hidden unnamed_addr constant [85 x i8], align 1
@stderr = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [48 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: 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 noundef ptr @_Z12find_elementP7PlyFilePc(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @ply_describe_property(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call noundef ptr @_Z12find_elementP7PlyFilePc(ptr noundef %10, ptr noundef %11)
  store ptr %12, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %19

15:                                               ; preds = %3
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.13, ptr noundef %17) #5
  store i32 1, ptr %9, align 4
  br label %83

19:                                               ; preds = %3
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PlyElement, ptr %20, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %33

24:                                               ; preds = %19
  %25 = call noundef ptr @_Z8my_allociiPc(i32 noundef 8, i32 noundef 331, ptr noundef @.str.9)
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.PlyElement, ptr %26, i32 0, i32 4
  store ptr %25, ptr %27, align 8, !tbaa !12
  %28 = call noundef ptr @_Z8my_allociiPc(i32 noundef 1, i32 noundef 332, ptr noundef @.str.9)
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.PlyElement, ptr %29, i32 0, i32 5
  store ptr %28, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.PlyElement, ptr %31, i32 0, i32 3
  store i32 1, ptr %32, align 8, !tbaa !9
  br label %60

33:                                               ; preds = %19
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.PlyElement, ptr %34, i32 0, i32 3
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 8, !tbaa !9
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.PlyElement, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.PlyElement, ptr %41, i32 0, i32 3
  %43 = load i32, ptr %42, align 8, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = mul i64 8, %44
  %46 = call ptr @realloc(ptr noundef %40, i64 noundef %45) #6
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.PlyElement, ptr %47, i32 0, i32 4
  store ptr %46, ptr %48, align 8, !tbaa !12
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.PlyElement, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.PlyElement, ptr %52, i32 0, i32 3
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = mul i64 1, %55
  %57 = call ptr @realloc(ptr noundef %51, i64 noundef %56) #6
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.PlyElement, ptr %58, i32 0, i32 5
  store ptr %57, ptr %59, align 8, !tbaa !13
  br label %60

60:                                               ; preds = %33, %24
  %61 = call noundef ptr @_Z8my_allociiPc(i32 noundef 40, i32 noundef 345, ptr noundef @.str.9)
  store ptr %61, ptr %8, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.PlyElement, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !12
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.PlyElement, ptr %66, i32 0, i32 3
  %68 = load i32, ptr %67, align 8, !tbaa !9
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds ptr, ptr %65, i64 %70
  store ptr %62, ptr %71, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.PlyElement, ptr %72, i32 0, i32 5
  %74 = load ptr, ptr %73, align 8, !tbaa !13
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.PlyElement, ptr %75, i32 0, i32 3
  %77 = load i32, ptr %76, align 8, !tbaa !9
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %74, i64 %79
  store i8 1, ptr %80, align 1, !tbaa !14
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_Z13copy_propertyP11PlyPropertyS0_(ptr noundef %81, ptr noundef %82)
  store i32 0, ptr %9, align 4
  br label %83

83:                                               ; preds = %60, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %84 = load i32, ptr %9, align 4
  switch i32 %84, label %86 [
    i32 0, label %85
    i32 1, label %85
  ]

85:                                               ; preds = %83, %83
  ret void

86:                                               ; preds = %83
  unreachable
}

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

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 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 #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 16}
!10 = !{!"_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}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!7, !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"

@.str.9 = external hidden unnamed_addr constant [85 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [48 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 nounwind uwtable
declare dso_local noundef ptr @_Z12find_elementP7PlyFilePc(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @ply_describe_property(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call noundef ptr @_Z12find_elementP7PlyFilePc(ptr noundef %0, ptr noundef %1)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %9

6:                                                ; preds = %3
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.13, ptr noundef %1) #3
  br label %42

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %18

13:                                               ; preds = %9
  %14 = tail call noundef ptr @_Z8my_allociiPc(i32 noundef 8, i32 noundef 331, ptr noundef nonnull @.str.9)
  %15 = getelementptr inbounds i8, ptr %4, i64 24
  store ptr %14, ptr %15, align 8, !tbaa !12
  %16 = tail call noundef ptr @_Z8my_allociiPc(i32 noundef 1, i32 noundef 332, ptr noundef nonnull @.str.9)
  %17 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr %16, ptr %17, align 8, !tbaa !13
  store i32 1, ptr %10, align 8, !tbaa !9
  br label %30

18:                                               ; preds = %9
  %19 = add nsw i32 %11, 1
  store i32 %19, ptr %10, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %4, i64 24
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = sext i32 %19 to i64
  %23 = shl nsw i64 %22, 3
  %24 = tail call ptr @realloc(ptr noundef %21, i64 noundef %23) #4
  store ptr %24, ptr %20, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %4, i64 32
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load i32, ptr %10, align 8, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = tail call ptr @realloc(ptr noundef %26, i64 noundef %28) #4
  store ptr %29, ptr %25, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %18, %13
  %31 = tail call noundef ptr @_Z8my_allociiPc(i32 noundef 40, i32 noundef 345, ptr noundef nonnull @.str.9)
  %32 = getelementptr inbounds i8, ptr %4, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = load i32, ptr %10, align 8, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr ptr, ptr %33, i64 %35
  %37 = getelementptr i8, ptr %36, i64 -8
  store ptr %31, ptr %37, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %4, i64 32
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = getelementptr i8, ptr %39, i64 %35
  %41 = getelementptr i8, ptr %40, i64 -1
  store i8 1, ptr %41, align 1, !tbaa !14
  tail call void @_Z13copy_propertyP11PlyPropertyS0_(ptr noundef %31, ptr noundef %2)
  br label %42

42:                                               ; preds = %30, %6
  ret void
}

; 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

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 = { 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 #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 = { cold 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 16}
!10 = !{!"_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}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!7, !7, i64 0}


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