; LLVM IR from aap/librw :: src/geometry.ll (ZN2rw8Material5cloneEv)

; 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.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::Material" = type { ptr, %"struct.rw::RGBA", %"struct.rw::SurfaceProperties", ptr, i32 }
%"struct.rw::RGBA" = type { i8, i8, i8, i8 }
%"struct.rw::SurfaceProperties" = type { float, float, float }

@_ZN2rw8Material9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(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: 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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw8Material6createEv() #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw8Material5cloneEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.rw::Error", align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %8 = call noundef ptr @_ZN2rw8Material6createEv()
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %23

11:                                               ; preds = %1
  br label %12

12:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %13 = getelementptr inbounds %"struct.rw::Error", ptr %5, i32 0, i32 0
  store i32 7, ptr %13, align 4, !tbaa !9
  %14 = getelementptr inbounds %"struct.rw::Error", ptr %5, i32 0, i32 1
  store i32 -2147483646, ptr %14, align 4, !tbaa !12
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 880) #5
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = load i32, ptr @_ZN2rw8Material9s_plglistE, align 8, !tbaa !13
  %19 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %18)
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.4, ptr noundef %19) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %21

21:                                               ; preds = %12
  br label %22

22:                                               ; preds = %21
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %44

23:                                               ; preds = %1
  %24 = getelementptr inbounds %"struct.rw::Material", ptr %7, i32 0, i32 1
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.rw::Material", ptr %25, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 8 %24, i64 4, i1 false), !tbaa.struct !17
  %27 = getelementptr inbounds %"struct.rw::Material", ptr %7, i32 0, i32 2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.rw::Material", ptr %28, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 4 %27, i64 12, i1 false), !tbaa.struct !19
  %30 = getelementptr inbounds %"struct.rw::Material", ptr %7, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !22
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %37

33:                                               ; preds = %23
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.rw::Material", ptr %7, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  call void @_ZN2rw8Material10setTextureEPNS_7TextureE(ptr noundef nonnull align 8 dereferenceable(40) %34, ptr noundef %36)
  br label %37

37:                                               ; preds = %33, %23
  %38 = getelementptr inbounds %"struct.rw::Material", ptr %7, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.rw::Material", ptr %40, i32 0, i32 3
  store ptr %39, ptr %41, align 8, !tbaa !26
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw8Material9s_plglistE, ptr noundef %42, ptr noundef %7)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %43, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %44

44:                                               ; preds = %37, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %45 = load ptr, ptr %2, align 8
  ret ptr %45
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw8Material10setTextureEPNS_7TextureE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #4 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 }

!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 0}
!10 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !11, i64 0}
!14 = !{!"_ZTSN2rw10PluginListE", !11, i64 0, !11, i64 4, !15, i64 8}
!15 = !{!"_ZTSN2rw8LinkListE", !16, i64 0}
!16 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!17 = !{i64 0, i64 1, !18, i64 1, i64 1, !18, i64 2, i64 1, !18, i64 3, i64 1, !18}
!18 = !{!7, !7, i64 0}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20, i64 8, i64 4, !20}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!23, !6, i64 0}
!23 = !{!"_ZTSN2rw8MaterialE", !6, i64 0, !24, i64 8, !25, i64 12, !6, i64 24, !11, i64 32}
!24 = !{!"_ZTSN2rw4RGBAE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!25 = !{!"_ZTSN2rw17SurfacePropertiesE", !21, i64 0, !21, i64 4, !21, i64 8}
!26 = !{!23, !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"

%"struct.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }

@_ZN2rw8Material9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) local_unnamed_addr #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress 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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw8Material6createEv() local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw8Material5cloneEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #4 align 2 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = tail call noundef ptr @_ZN2rw8Material6createEv()
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %13

5:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  store i32 7, ptr %2, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 -2147483646, ptr %6, align 4, !tbaa !10
  %7 = load ptr, ptr @stderr, align 8, !tbaa !11
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 880) #6
  %9 = load ptr, ptr @stderr, align 8, !tbaa !11
  %10 = load i32, ptr @_ZN2rw8Material9s_plglistE, align 8, !tbaa !13
  %11 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %10)
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.4, ptr noundef %11) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br label %25

13:                                               ; preds = %1
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = getelementptr inbounds i8, ptr %3, i64 8
  %16 = load i32, ptr %14, align 8
  store i32 %16, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = getelementptr inbounds i8, ptr %3, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %18, ptr noundef nonnull align 4 dereferenceable(12) %17, i64 12, i1 false), !tbaa.struct !17
  %19 = load ptr, ptr %0, align 8, !tbaa !20
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %21, label %20

20:                                               ; preds = %13
  tail call void @_ZN2rw8Material10setTextureEPNS_7TextureE(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull %19)
  br label %21

21:                                               ; preds = %20, %13
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !24
  %24 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %23, ptr %24, align 8, !tbaa !24
  tail call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw8Material9s_plglistE, ptr noundef nonnull %3, ptr noundef nonnull %0)
  br label %25

25:                                               ; preds = %21, %5
  ret ptr %3
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw8Material10setTextureEPNS_7TextureE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #4 align 2

declare void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { cold 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 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTSN2rw10PluginListE", !7, i64 0, !7, i64 4, !15, i64 8}
!15 = !{!"_ZTSN2rw8LinkListE", !16, i64 0}
!16 = !{!"_ZTSN2rw6LLLinkE", !12, i64 0, !12, i64 8}
!17 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 4, !18}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !8, i64 0}
!20 = !{!21, !12, i64 0}
!21 = !{!"_ZTSN2rw8MaterialE", !12, i64 0, !22, i64 8, !23, i64 12, !12, i64 24, !7, i64 32}
!22 = !{!"_ZTSN2rw4RGBAE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!23 = !{!"_ZTSN2rw17SurfacePropertiesE", !19, i64 0, !19, i64 4, !19, i64 8}
!24 = !{!21, !12, i64 24}


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