; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/Common (Bitmap)

; 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.Assimp::Bitmap::Header" = type { i16, i32, i16, i16, i32 }
%"struct.Assimp::Bitmap::DIB" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%struct.aiTexture = type <{ i32, i32, [9 x i8], [7 x i8], ptr, %struct.aiString, [4 x i8] }>
%struct.aiString = type { i32, [1024 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6Assimp6Bitmap4SaveEP9aiTexturePNS_8IOStreamE(ptr noundef %0, ptr noundef %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.Assimp::Bitmap::Header", align 4
  %7 = alloca %"struct.Assimp::Bitmap::DIB", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %54

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #2
  %12 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 0
  store i32 40, ptr %12, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.aiTexture, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 1
  store i32 %15, ptr %16, align 4, !tbaa !16
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.aiTexture, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 2
  store i32 %19, ptr %20, align 4, !tbaa !18
  %21 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 3
  store i16 1, ptr %21, align 4, !tbaa !19
  %22 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 4
  store i16 32, ptr %22, align 2, !tbaa !20
  %23 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 5
  store i32 0, ptr %23, align 4, !tbaa !21
  %24 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = sext i32 %25 to i64
  %27 = mul i64 %26, 4
  %28 = add i64 %27, 3
  %29 = and i64 %28, 65532
  %30 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 2
  %31 = load i32, ptr %30, align 4, !tbaa !18
  %32 = sext i32 %31 to i64
  %33 = mul i64 %29, %32
  %34 = trunc i64 %33 to i32
  %35 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 6
  store i32 %34, ptr %35, align 4, !tbaa !22
  %36 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 7
  store i32 0, ptr %36, align 4, !tbaa !23
  %37 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 8
  store i32 0, ptr %37, align 4, !tbaa !24
  %38 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 9
  store i32 0, ptr %38, align 4, !tbaa !25
  %39 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 10
  store i32 0, ptr %39, align 4, !tbaa !26
  %40 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 0
  store i16 19778, ptr %40, align 4, !tbaa !27
  %41 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 4
  store i32 54, ptr %41, align 4, !tbaa !29
  %42 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 4
  %43 = load i32, ptr %42, align 4, !tbaa !29
  %44 = getelementptr inbounds %"struct.Assimp::Bitmap::DIB", ptr %7, i32 0, i32 6
  %45 = load i32, ptr %44, align 4, !tbaa !22
  %46 = add i32 %43, %45
  %47 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 1
  store i32 %46, ptr %47, align 4, !tbaa !30
  %48 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 2
  store i16 0, ptr %48, align 4, !tbaa !31
  %49 = getelementptr inbounds %"struct.Assimp::Bitmap::Header", ptr %6, i32 0, i32 3
  store i16 0, ptr %49, align 2, !tbaa !32
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN6Assimp6Bitmap11WriteHeaderERNS0_6HeaderEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(16) %6, ptr noundef %50)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN6Assimp6Bitmap8WriteDIBERNS0_3DIBEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(40) %7, ptr noundef %51)
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN6Assimp6Bitmap9WriteDataEP9aiTexturePNS_8IOStreamE(ptr noundef %52, ptr noundef %53)
  store i1 true, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #2
  br label %54

54:                                               ; preds = %11, %10
  %55 = load i1, ptr %3, align 1
  ret i1 %55
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Assimp6Bitmap11WriteHeaderERNS0_6HeaderEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Assimp6Bitmap9WriteDataEP9aiTexturePNS_8IOStreamE(ptr noundef, ptr noundef) #0 align 2

; 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 = { 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 = !{!"_ZTSN6Assimp6Bitmap3DIBE", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !12, i64 14, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"_ZTS9aiTexture", !11, i64 0, !11, i64 4, !7, i64 8, !6, i64 24, !15, i64 32}
!15 = !{!"_ZTS8aiString", !11, i64 0, !7, i64 4}
!16 = !{!10, !11, i64 4}
!17 = !{!14, !11, i64 4}
!18 = !{!10, !11, i64 8}
!19 = !{!10, !12, i64 12}
!20 = !{!10, !12, i64 14}
!21 = !{!10, !11, i64 16}
!22 = !{!10, !11, i64 20}
!23 = !{!10, !11, i64 24}
!24 = !{!10, !11, i64 28}
!25 = !{!10, !11, i64 32}
!26 = !{!10, !11, i64 36}
!27 = !{!28, !12, i64 0}
!28 = !{!"_ZTSN6Assimp6Bitmap6HeaderE", !12, i64 0, !11, i64 4, !12, i64 8, !12, i64 10, !11, i64 12}
!29 = !{!28, !11, i64 12}
!30 = !{!28, !11, i64 4}
!31 = !{!28, !12, i64 8}
!32 = !{!28, !12, i64 10}


; 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.Assimp::Bitmap::Header" = type { i16, i32, i16, i16, i32 }
%"struct.Assimp::Bitmap::DIB" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6Assimp6Bitmap4SaveEP9aiTexturePNS_8IOStreamE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %"struct.Assimp::Bitmap::Header", align 4
  %4 = alloca %"struct.Assimp::Bitmap::DIB", align 4
  %5 = icmp ne ptr %1, null
  br i1 %5, label %6, label %25

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #3
  store i32 40, ptr %4, align 4, !tbaa !5
  %7 = load i32, ptr %0, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %7, ptr %8, align 4, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %10, ptr %11, align 4, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %4, i64 12
  store i16 1, ptr %12, align 4, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %4, i64 14
  store i16 32, ptr %13, align 2, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 0, ptr %14, align 4, !tbaa !20
  %15 = shl i32 %7, 2
  %16 = and i32 %15, 65532
  %17 = mul i32 %16, %10
  %18 = getelementptr inbounds i8, ptr %4, i64 20
  store i32 %17, ptr %18, align 4, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %4, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  store i16 19778, ptr %3, align 4, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 54, ptr %20, align 4, !tbaa !24
  %21 = add i32 %17, 54
  %22 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %21, ptr %22, align 4, !tbaa !25
  %23 = getelementptr inbounds i8, ptr %3, i64 8
  store i16 0, ptr %23, align 4, !tbaa !26
  %24 = getelementptr inbounds i8, ptr %3, i64 10
  store i16 0, ptr %24, align 2, !tbaa !27
  call void @_ZN6Assimp6Bitmap11WriteHeaderERNS0_6HeaderEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(16) %3, ptr noundef nonnull %1)
  call void @_ZN6Assimp6Bitmap8WriteDIBERNS0_3DIBEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(40) %4, ptr noundef nonnull %1)
  call void @_ZN6Assimp6Bitmap9WriteDataEP9aiTexturePNS_8IOStreamE(ptr noundef nonnull %0, ptr noundef nonnull %1)
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  br label %25

25:                                               ; preds = %2, %6
  ret i1 %5
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Assimp6Bitmap11WriteHeaderERNS0_6HeaderEPNS_8IOStreamE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Assimp6Bitmap9WriteDataEP9aiTexturePNS_8IOStreamE(ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTSN6Assimp6Bitmap3DIBE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 14, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTS9aiTexture", !7, i64 0, !7, i64 4, !8, i64 8, !13, i64 24, !14, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"_ZTS8aiString", !7, i64 0, !8, i64 4}
!15 = !{!6, !7, i64 4}
!16 = !{!12, !7, i64 4}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !10, i64 12}
!19 = !{!6, !10, i64 14}
!20 = !{!6, !7, i64 16}
!21 = !{!6, !7, i64 20}
!22 = !{!23, !10, i64 0}
!23 = !{!"_ZTSN6Assimp6Bitmap6HeaderE", !10, i64 0, !7, i64 4, !10, i64 8, !10, i64 10, !7, i64 12}
!24 = !{!23, !7, i64 12}
!25 = !{!23, !7, i64 4}
!26 = !{!23, !10, i64 8}
!27 = !{!23, !10, i64 10}


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