; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R2Texture.ll (ZN9R2TextureC2ERKS_PKc)

; 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.R2Texture = type <{ ptr, i32, [4 x i8], ptr, ptr, ptr, i32, i32, i32, i32, i32, [4 x i8], %class.RNFlags, i32, [4 x i8] }>
%class.RNFlags = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9R2TextureC2ERKS_PKc(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr noundef nonnull align 8 dereferenceable(76) %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  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
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 0
  store ptr null, ptr %8, align 8, !tbaa !9
  %9 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 1
  store i32 -1, ptr %9, align 8, !tbaa !17
  %10 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 3
  store ptr null, ptr %10, align 8, !tbaa !18
  %11 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.R2Texture, ptr %12, i32 0, i32 4
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %21

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.R2Texture, ptr %17, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = call noalias ptr @strdup(ptr noundef %19) #3
  br label %22

21:                                               ; preds = %3
  br label %22

22:                                               ; preds = %21, %16
  %23 = phi ptr [ %20, %16 ], [ null, %21 ]
  store ptr %23, ptr %11, align 8, !tbaa !19
  %24 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.R2Texture, ptr %25, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  store ptr %27, ptr %24, align 8, !tbaa !20
  %28 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 6
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.R2Texture, ptr %29, i32 0, i32 6
  %31 = load i32, ptr %30, align 8, !tbaa !21
  store i32 %31, ptr %28, align 8, !tbaa !21
  %32 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 7
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %class.R2Texture, ptr %33, i32 0, i32 7
  %35 = load i32, ptr %34, align 4, !tbaa !22
  store i32 %35, ptr %32, align 4, !tbaa !22
  %36 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 8
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.R2Texture, ptr %37, i32 0, i32 8
  %39 = load i32, ptr %38, align 8, !tbaa !23
  store i32 %39, ptr %36, align 8, !tbaa !23
  %40 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.R2Texture, ptr %41, i32 0, i32 9
  %43 = load i32, ptr %42, align 4, !tbaa !24
  store i32 %43, ptr %40, align 4, !tbaa !24
  %44 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 10
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.R2Texture, ptr %45, i32 0, i32 10
  %47 = load i32, ptr %46, align 8, !tbaa !25
  store i32 %47, ptr %44, align 8, !tbaa !25
  %48 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 12
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %class.R2Texture, ptr %49, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %48, ptr align 8 %50, i64 8, i1 false), !tbaa.struct !26
  %51 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 13
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %class.R2Texture, ptr %52, i32 0, i32 5
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = icmp ne ptr %54, null
  %56 = zext i1 %55 to i64
  %57 = select i1 %55, i32 -1, i32 0
  store i32 %57, ptr %51, align 8, !tbaa !28
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %64

60:                                               ; preds = %22
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = call noalias ptr @strdup(ptr noundef %61) #3
  %63 = getelementptr inbounds %class.R2Texture, ptr %7, i32 0, i32 3
  store ptr %62, ptr %63, align 8, !tbaa !18
  br label %64

64:                                               ; preds = %60, %22
  call void @_ZN9R2Texture6UpdateEv(ptr noundef nonnull align 8 dereferenceable(76) %7)
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9R2Texture6UpdateEv(ptr noundef nonnull align 8 dereferenceable(76)) #0 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !6, i64 0}
!10 = !{!"_ZTS9R2Texture", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !13, i64 48, !13, i64 52, !14, i64 56, !15, i64 64, !11, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS13R2TextureWrap", !7, i64 0}
!13 = !{!"_ZTS15R2TextureFilter", !7, i64 0}
!14 = !{!"_ZTS14R2TextureBlend", !7, i64 0}
!15 = !{!"_ZTS7RNFlags", !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !6, i64 16}
!19 = !{!10, !6, i64 24}
!20 = !{!10, !6, i64 32}
!21 = !{!10, !12, i64 40}
!22 = !{!10, !12, i64 44}
!23 = !{!10, !13, i64 48}
!24 = !{!10, !13, i64 52}
!25 = !{!10, !14, i64 56}
!26 = !{i64 0, i64 8, !27}
!27 = !{!16, !16, i64 0}
!28 = !{!10, !11, i64 72}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9R2TextureC2ERKS_PKc(ptr noundef nonnull align 8 dereferenceable(76) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(76) %1, ptr noundef readonly %2) unnamed_addr #0 align 2 {
  store ptr null, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 -1, ptr %4, align 8, !tbaa !16
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %5, align 8, !tbaa !17
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !18
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %11, label %9

9:                                                ; preds = %3
  %10 = tail call noalias ptr @strdup(ptr noundef nonnull %8) #2
  br label %11

11:                                               ; preds = %3, %9
  %12 = phi ptr [ %10, %9 ], [ null, %3 ]
  store ptr %12, ptr %6, align 8, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = getelementptr inbounds i8, ptr %1, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  store ptr %15, ptr %13, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  %17 = getelementptr inbounds i8, ptr %1, i64 40
  %18 = load <4 x i32>, ptr %17, align 8, !tbaa !20
  store <4 x i32> %18, ptr %16, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  %20 = getelementptr inbounds i8, ptr %1, i64 56
  %21 = load i32, ptr %20, align 8, !tbaa !21
  store i32 %21, ptr %19, align 8, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = getelementptr inbounds i8, ptr %1, i64 64
  %24 = load i64, ptr %23, align 8, !tbaa !22
  store i64 %24, ptr %22, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %0, i64 72
  %.not14 = icmp ne ptr %15, null
  %26 = sext i1 %.not14 to i32
  store i32 %26, ptr %25, align 8, !tbaa !23
  %.not15 = icmp eq ptr %2, null
  br i1 %.not15, label %29, label %27

27:                                               ; preds = %11
  %28 = tail call noalias ptr @strdup(ptr noundef nonnull %2) #2
  store ptr %28, ptr %5, align 8, !tbaa !17
  br label %29

29:                                               ; preds = %27, %11
  tail call void @_ZN9R2Texture6UpdateEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  ret void
}

; 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 uwtable
declare dso_local void @_ZN9R2Texture6UpdateEv(ptr noundef nonnull align 8 dereferenceable(76)) local_unnamed_addr #0 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, 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 = { 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, !7, i64 0}
!6 = !{!"_ZTS9R2Texture", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 52, !13, i64 56, !14, i64 64, !10, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS13R2TextureWrap", !8, i64 0}
!12 = !{!"_ZTS15R2TextureFilter", !8, i64 0}
!13 = !{!"_ZTS14R2TextureBlend", !8, i64 0}
!14 = !{!"_ZTS7RNFlags", !15, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 24}
!19 = !{!6, !7, i64 32}
!20 = !{!8, !8, i64 0}
!21 = !{!6, !13, i64 56}
!22 = !{!15, !15, i64 0}
!23 = !{!6, !10, i64 72}


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