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

; 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

declare void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24), double noundef, double noundef, double noundef) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3BrdfC2EPKc(ptr noundef nonnull align 8 dereferenceable(180) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV6R3Brdf, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 1
  store ptr null, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 2
  store i32 -1, ptr %7, align 8, !tbaa !18
  %8 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 4
  store ptr null, ptr %8, align 8, !tbaa !19
  %9 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 5
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %9, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %10 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 6
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %10, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %11 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 7
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %11, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %12 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 8
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %12, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %13 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 9
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %13, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %14 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 10
  store double 0.000000e+00, ptr %14, align 8, !tbaa !20
  %15 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 11
  store double 0.000000e+00, ptr %15, align 8, !tbaa !21
  %16 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 12
  call void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8) %16, i64 noundef 0)
  %17 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 13
  store i32 0, ptr %17, align 8, !tbaa !22
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %24

20:                                               ; preds = %2
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call noalias ptr @strdup(ptr noundef %21) #4
  %23 = getelementptr inbounds %class.R3Brdf, ptr %5, i32 0, i32 4
  store ptr %22, ptr %23, align 8, !tbaa !19
  br label %24

24:                                               ; preds = %20, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #2 align 2

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

attributes #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 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 = { inlinehint 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 #3 = { 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 #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 = !{!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

declare void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24), double noundef, double noundef, double noundef) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R3BrdfC2EPKc(ptr noundef nonnull align 8 dereferenceable(180) %0, ptr noundef readonly %1) unnamed_addr #1 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV6R3Brdf, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %3, align 8, !tbaa !8
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 -1, ptr %4, align 8, !tbaa !17
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %5, align 8, !tbaa !18
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %6, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %7, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %8, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %9, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %10, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %11 = getelementptr inbounds i8, ptr %0, i64 152
  %12 = getelementptr inbounds i8, ptr %0, i64 168
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  tail call void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8) %12, i64 noundef 0)
  %13 = getelementptr inbounds i8, ptr %0, i64 176
  store i32 0, ptr %13, align 8, !tbaa !19
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %16, label %14

14:                                               ; preds = %2
  %15 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #5
  store ptr %15, ptr %5, align 8, !tbaa !18
  br label %16

16:                                               ; preds = %14, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN7RNFlagsC2Em(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #2 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #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 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 = { inlinehint 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!9, !12, i64 176}


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