; LLVM IR from aap/librw :: src/raster.ll (ZN2rw6Raster6createEiiiii)

; 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::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }
%"struct.rw::Engine" = type { ptr, ptr, %"struct.rw::LinkList", %"struct.rw::FileFunctions", [13 x ptr], %"struct.rw::Device", ptr }
%"struct.rw::FileFunctions" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Device" = type { float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Driver" = type { ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@_ZN2rw6Raster12numAllocatedE = external dso_local global i32, align 4
@_ZN2rw6Raster9s_plglistE = external global %"struct.rw::PluginList", align 8
@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw6Raster6createEiiiii = external hidden unnamed_addr constant [69 x i8], align 1
@_ZN2rw8platformE = external global i32, align 4
@_ZN2rw6engineE = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %12 = load i32, ptr @_ZN2rw6Raster9s_plglistE, align 8, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %13, i32 noundef 196608, ptr noundef @.str)
  store ptr %14, ptr %11, align 8, !tbaa !14
  %15 = load ptr, ptr %11, align 8, !tbaa !14
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %20

18:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 62, ptr noundef @__PRETTY_FUNCTION__._ZN2rw6Raster6createEiiiii) #6
  unreachable

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %17
  %21 = load i32, ptr @_ZN2rw6Raster12numAllocatedE, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr @_ZN2rw6Raster12numAllocatedE, align 4, !tbaa !5
  %23 = load ptr, ptr %11, align 8, !tbaa !14
  %24 = load ptr, ptr %11, align 8, !tbaa !14
  %25 = getelementptr inbounds %"struct.rw::Raster", ptr %24, i32 0, i32 15
  store ptr %23, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %11, align 8, !tbaa !14
  %27 = getelementptr inbounds %"struct.rw::Raster", ptr %26, i32 0, i32 16
  store i32 0, ptr %27, align 8, !tbaa !17
  %28 = load ptr, ptr %11, align 8, !tbaa !14
  %29 = getelementptr inbounds %"struct.rw::Raster", ptr %28, i32 0, i32 17
  store i32 0, ptr %29, align 4, !tbaa !18
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %20
  %33 = load i32, ptr %10, align 4, !tbaa !5
  br label %36

34:                                               ; preds = %20
  %35 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %34, %32
  %37 = phi i32 [ %33, %32 ], [ %35, %34 ]
  %38 = load ptr, ptr %11, align 8, !tbaa !14
  %39 = getelementptr inbounds %"struct.rw::Raster", ptr %38, i32 0, i32 0
  store i32 %37, ptr %39, align 8, !tbaa !19
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = and i32 %40, 7
  %42 = load ptr, ptr %11, align 8, !tbaa !14
  %43 = getelementptr inbounds %"struct.rw::Raster", ptr %42, i32 0, i32 1
  store i32 %41, ptr %43, align 4, !tbaa !20
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = and i32 %44, 248
  %46 = load ptr, ptr %11, align 8, !tbaa !14
  %47 = getelementptr inbounds %"struct.rw::Raster", ptr %46, i32 0, i32 2
  store i32 %45, ptr %47, align 8, !tbaa !21
  %48 = load ptr, ptr %11, align 8, !tbaa !14
  %49 = getelementptr inbounds %"struct.rw::Raster", ptr %48, i32 0, i32 3
  store i32 0, ptr %49, align 4, !tbaa !22
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = and i32 %50, 65280
  %52 = load ptr, ptr %11, align 8, !tbaa !14
  %53 = getelementptr inbounds %"struct.rw::Raster", ptr %52, i32 0, i32 4
  store i32 %51, ptr %53, align 8, !tbaa !23
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load ptr, ptr %11, align 8, !tbaa !14
  %56 = getelementptr inbounds %"struct.rw::Raster", ptr %55, i32 0, i32 5
  store i32 %54, ptr %56, align 4, !tbaa !24
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = load ptr, ptr %11, align 8, !tbaa !14
  %59 = getelementptr inbounds %"struct.rw::Raster", ptr %58, i32 0, i32 6
  store i32 %57, ptr %59, align 8, !tbaa !25
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load ptr, ptr %11, align 8, !tbaa !14
  %62 = getelementptr inbounds %"struct.rw::Raster", ptr %61, i32 0, i32 7
  store i32 %60, ptr %62, align 4, !tbaa !26
  %63 = load ptr, ptr %11, align 8, !tbaa !14
  %64 = getelementptr inbounds %"struct.rw::Raster", ptr %63, i32 0, i32 8
  store i32 0, ptr %64, align 8, !tbaa !27
  %65 = load ptr, ptr %11, align 8, !tbaa !14
  %66 = getelementptr inbounds %"struct.rw::Raster", ptr %65, i32 0, i32 10
  store ptr null, ptr %66, align 8, !tbaa !28
  %67 = load ptr, ptr %11, align 8, !tbaa !14
  %68 = getelementptr inbounds %"struct.rw::Raster", ptr %67, i32 0, i32 9
  store ptr null, ptr %68, align 8, !tbaa !29
  %69 = load ptr, ptr %11, align 8, !tbaa !14
  call void @_ZN2rw10PluginList9constructEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Raster9s_plglistE, ptr noundef %69)
  %70 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !14
  %71 = getelementptr inbounds %"struct.rw::Engine", ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %11, align 8, !tbaa !14
  %73 = getelementptr inbounds %"struct.rw::Raster", ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !19
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [13 x ptr], ptr %71, i64 0, i64 %75
  %77 = load ptr, ptr %76, align 8, !tbaa !14
  %78 = getelementptr inbounds %"struct.rw::Driver", ptr %77, i32 0, i32 2
  %79 = load ptr, ptr %78, align 8, !tbaa !30
  %80 = load ptr, ptr %11, align 8, !tbaa !14
  %81 = call noundef ptr %79(ptr noundef %80)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret ptr %81
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare void @_ZN2rw10PluginList9constructEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #4

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { noreturn 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 = { "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 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN2rw10PluginListE", !6, i64 0, !6, i64 4, !11, i64 8}
!11 = !{!"_ZTSN2rw8LinkListE", !12, i64 0}
!12 = !{!"_ZTSN2rw6LLLinkE", !13, i64 0, !13, i64 8}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !13, i64 80}
!16 = !{!"_ZTSN2rw6RasterE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !13, i64 80, !6, i64 88, !6, i64 92}
!17 = !{!16, !6, i64 88}
!18 = !{!16, !6, i64 92}
!19 = !{!16, !6, i64 0}
!20 = !{!16, !6, i64 4}
!21 = !{!16, !6, i64 8}
!22 = !{!16, !6, i64 12}
!23 = !{!16, !6, i64 16}
!24 = !{!16, !6, i64 20}
!25 = !{!16, !6, i64 24}
!26 = !{!16, !6, i64 28}
!27 = !{!16, !6, i64 32}
!28 = !{!16, !13, i64 48}
!29 = !{!16, !13, i64 40}
!30 = !{!31, !13, i64 16}
!31 = !{!"_ZTSN2rw6DriverE", !13, i64 0, !6, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80}


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

@_ZN2rw6Raster12numAllocatedE = external dso_local local_unnamed_addr global i32, align 4
@_ZN2rw6Raster9s_plglistE = external global %"struct.rw::PluginList", align 8
@.str = external hidden unnamed_addr constant [73 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw6Raster6createEiiiii = external hidden unnamed_addr constant [69 x i8], align 1
@_ZN2rw8platformE = external local_unnamed_addr global i32, align 4
@_ZN2rw6engineE = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = load i32, ptr @_ZN2rw6Raster9s_plglistE, align 8, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %7, i32 noundef 196608, ptr noundef nonnull @.str)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 62, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw6Raster6createEiiiii) #5
  unreachable

10:                                               ; preds = %5
  %11 = load i32, ptr @_ZN2rw6Raster12numAllocatedE, align 4, !tbaa !13
  %12 = add nsw i32 %11, 1
  store i32 %12, ptr @_ZN2rw6Raster12numAllocatedE, align 4, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %8, i64 80
  store ptr %8, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %8, i64 88
  store i32 0, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %8, i64 92
  store i32 0, ptr %15, align 4, !tbaa !17
  %.not26 = icmp eq i32 %4, 0
  %16 = load i32, ptr @_ZN2rw8platformE, align 4
  %17 = select i1 %.not26, i32 %16, i32 %4
  store i32 %17, ptr %8, align 8, !tbaa !18
  %18 = and i32 %3, 7
  %19 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %18, ptr %19, align 4, !tbaa !19
  %20 = and i32 %3, 248
  %21 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %20, ptr %21, align 8, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %8, i64 12
  store i32 0, ptr %22, align 4, !tbaa !21
  %23 = and i32 %3, 65280
  %24 = getelementptr inbounds i8, ptr %8, i64 16
  store i32 %23, ptr %24, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %8, i64 20
  store i32 %0, ptr %25, align 4, !tbaa !23
  %26 = getelementptr inbounds i8, ptr %8, i64 24
  store i32 %1, ptr %26, align 8, !tbaa !24
  %27 = getelementptr inbounds i8, ptr %8, i64 28
  store i32 %2, ptr %27, align 4, !tbaa !25
  %28 = getelementptr inbounds i8, ptr %8, i64 32
  store i32 0, ptr %28, align 8, !tbaa !26
  %29 = getelementptr inbounds i8, ptr %8, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %29, i8 0, i64 16, i1 false)
  tail call void @_ZN2rw10PluginList9constructEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Raster9s_plglistE, ptr noundef nonnull %8)
  %30 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !27
  %31 = getelementptr inbounds i8, ptr %30, i64 88
  %32 = load i32, ptr %8, align 8, !tbaa !18
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [13 x ptr], ptr %31, i64 0, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !27
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !28
  %38 = tail call noundef ptr %37(ptr noundef nonnull %8)
  ret ptr %38
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw10PluginList9constructEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) 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 = { 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 = { inlinehint 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 = { noreturn 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 = { "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 = { noreturn 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 = !{!"_ZTSN2rw10PluginListE", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2rw8LinkListE", !11, i64 0}
!11 = !{!"_ZTSN2rw6LLLinkE", !12, i64 0, !12, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 80}
!15 = !{!"_ZTSN2rw6RasterE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !12, i64 80, !7, i64 88, !7, i64 92}
!16 = !{!15, !7, i64 88}
!17 = !{!15, !7, i64 92}
!18 = !{!15, !7, i64 0}
!19 = !{!15, !7, i64 4}
!20 = !{!15, !7, i64 8}
!21 = !{!15, !7, i64 12}
!22 = !{!15, !7, i64 16}
!23 = !{!15, !7, i64 20}
!24 = !{!15, !7, i64 24}
!25 = !{!15, !7, i64 28}
!26 = !{!15, !7, i64 32}
!27 = !{!12, !12, i64 0}
!28 = !{!29, !12, i64 16}
!29 = !{!"_ZTSN2rw6DriverE", !12, i64 0, !7, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80}


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