; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R3Brdf.ll (ZN6R3BrdfC2ERKS_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.R3Brdf = type <{ ptr, ptr, i32, [4 x i8], ptr, %class.RNRgb, %class.RNRgb, %class.RNRgb, %class.RNRgb, %class.RNRgb, double, double, %class.RNFlags, i32, [4 x i8] }>
%class.RNRgb = type { [3 x double] }
%class.RNFlags = type { i64 }

@_ZTV6R3Brdf = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3BrdfC2ERKS_PKc(ptr noundef nonnull align 8 dereferenceable(180) %0, ptr noundef nonnull align 8 dereferenceable(180) %1, ptr noundef %2) unnamed_addr #1 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
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV6R3Brdf, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 1
  store ptr null, ptr %8, align 8, !tbaa !11
  %9 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 2
  store i32 -1, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 4
  store ptr null, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.R3Brdf, ptr %12, i32 0, i32 5
  call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %14 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 6
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.R3Brdf, ptr %15, i32 0, i32 6
  call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(24) %16)
  %17 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 7
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.R3Brdf, ptr %18, i32 0, i32 7
  call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef nonnull align 8 dereferenceable(24) %19)
  %20 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 8
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %class.R3Brdf, ptr %21, i32 0, i32 8
  call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 8 dereferenceable(24) %22)
  %23 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.R3Brdf, ptr %24, i32 0, i32 9
  call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 8 dereferenceable(24) %25)
  %26 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 10
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.R3Brdf, ptr %27, i32 0, i32 10
  %29 = load double, ptr %28, align 8, !tbaa !20
  store double %29, ptr %26, align 8, !tbaa !20
  %30 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 11
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.R3Brdf, ptr %31, i32 0, i32 11
  %33 = load double, ptr %32, align 8, !tbaa !21
  store double %33, ptr %30, align 8, !tbaa !21
  %34 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 12
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.R3Brdf, ptr %35, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 8 %36, i64 8, i1 false), !tbaa.struct !22
  %37 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 13
  store i32 -1, ptr %37, align 8, !tbaa !24
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %44

40:                                               ; preds = %3
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call noalias ptr @strdup(ptr noundef %41) #4
  %43 = getelementptr inbounds %class.R3Brdf, ptr %7, i32 0, i32 4
  store ptr %42, ptr %43, align 8, !tbaa !19
  br label %44

44:                                               ; preds = %40, %3
  ret void
}

declare void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; 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) #3

attributes #0 = { 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 #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 = { "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 nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS6R3Brdf", !6, i64 8, !13, i64 16, !6, i64 24, !14, i64 32, !14, i64 56, !14, i64 80, !14, i64 104, !14, i64 128, !15, i64 152, !15, i64 160, !16, i64 168, !13, i64 176}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS5RNRgb", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTS7RNFlags", !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!12, !13, i64 16}
!19 = !{!12, !6, i64 24}
!20 = !{!12, !15, i64 152}
!21 = !{!12, !15, i64 160}
!22 = !{i64 0, i64 8, !23}
!23 = !{!17, !17, i64 0}
!24 = !{!12, !13, i64 176}


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

@_ZTV6R3Brdf = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3BrdfC2ERKS_PKc(ptr noundef nonnull align 8 dereferenceable(180) %0, ptr noundef nonnull align 8 dereferenceable(180) %1, ptr noundef readonly %2) unnamed_addr #1 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV6R3Brdf, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %4, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 -1, ptr %5, align 8, !tbaa !17
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %6, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %1, i64 32
  tail call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = getelementptr inbounds i8, ptr %1, i64 56
  tail call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = getelementptr inbounds i8, ptr %1, i64 80
  tail call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 8 dereferenceable(24) %12)
  %13 = getelementptr inbounds i8, ptr %0, i64 104
  %14 = getelementptr inbounds i8, ptr %1, i64 104
  tail call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(24) %14)
  %15 = getelementptr inbounds i8, ptr %0, i64 128
  %16 = getelementptr inbounds i8, ptr %1, i64 128
  tail call void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef nonnull align 8 dereferenceable(24) %16)
  %17 = getelementptr inbounds i8, ptr %0, i64 152
  %18 = getelementptr inbounds i8, ptr %1, i64 152
  %19 = load <2 x double>, ptr %18, align 8, !tbaa !19
  store <2 x double> %19, ptr %17, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %0, i64 168
  %21 = getelementptr inbounds i8, ptr %1, i64 168
  %22 = load i64, ptr %21, align 8, !tbaa !20
  store i64 %22, ptr %20, align 8, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %0, i64 176
  store i32 -1, ptr %23, align 8, !tbaa !21
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %26, label %24

24:                                               ; preds = %3
  %25 = tail call noalias ptr @strdup(ptr noundef nonnull %2) #3
  store ptr %25, ptr %6, align 8, !tbaa !18
  br label %26

26:                                               ; preds = %24, %3
  ret void
}

declare void @_ZN5RNRgbC1ERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

attributes #0 = { 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 #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 = { "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 }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTS6R3Brdf", !10, i64 8, !12, i64 16, !10, i64 24, !13, i64 32, !13, i64 56, !13, i64 80, !13, i64 104, !13, i64 128, !14, i64 152, !14, i64 160, !15, i64 168, !12, i64 176}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"_ZTS5RNRgb", !11, i64 0}
!14 = !{!"double", !11, i64 0}
!15 = !{!"_ZTS7RNFlags", !16, i64 0}
!16 = !{!"long", !11, i64 0}
!17 = !{!9, !12, i64 16}
!18 = !{!9, !10, i64 24}
!19 = !{!14, !14, i64 0}
!20 = !{!16, !16, i64 0}
!21 = !{!9, !12, i64 176}


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