; LLVM IR from corentinartaud/graphics :: ThirdParty/FreeImage-3170/Source/LibJXR/jxrgluelib (JXRGlue)

; 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._GUID = type { i32, i16, i16, [8 x i8] }
%struct.tagPKImageEncode = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, %struct._GUID, i32, i32, i32, float, float, i32, i32, i64, i64, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, %struct.DESCRIPTIVEMETADATA, i32, %struct.anon.0 }
%struct.DESCRIPTIVEMETADATA = type { %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT, %struct.DPKPROPVARIANT }
%struct.DPKPROPVARIANT = type { i32, %union.anon }
%union.anon = type { ptr }
%struct.anon.0 = type { %struct.tagWmpDEMisc, %struct.tagCWMImageInfo, %struct.tagCWMIStrCodecParam, ptr, %struct.tagCWMImageInfo, %struct.tagCWMIStrCodecParam, ptr, i32, i64, i64, i64, i64, i32, i32, ptr }
%struct.tagWmpDEMisc = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.tagCWMImageInfo = type { i64, i64, i32, i32, i64, i64, i32, i8, i8, i64, i64, i64, i64, i32, i64, i64, i32, i8, i32 }
%struct.tagCWMIStrCodecParam = type { i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i64, i8, i32, i8, ptr, i64, i32, [4096 x i32], i32, [4096 x i32], i8, i8, i32, i32, i32, i32, i32, i32 }
%struct.WMPStream = type { %union.anon.1, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%union.anon.1 = type { %struct.tagBuf }
%struct.tagBuf = type { ptr, i64, i64, i64 }

@GUID_PKPixelFormatDontCare = external dso_local constant %struct._GUID, align 4

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @PKImageEncode_Initialize(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %11, ptr %7, align 8, !tbaa !5
  %12 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %12, ptr %8, align 8, !tbaa !9
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.tagPKImageEncode, ptr %14, i32 0, i32 15
  store ptr %13, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.tagPKImageEncode, ptr %16, i32 0, i32 17
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 4 @GUID_PKPixelFormatDontCare, i64 16, i1 false), !tbaa.struct !23
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.tagPKImageEncode, ptr %18, i32 0, i32 21
  store float 9.600000e+01, ptr %19, align 4, !tbaa !27
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tagPKImageEncode, ptr %20, i32 0, i32 22
  store float 9.600000e+01, ptr %21, align 8, !tbaa !28
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tagPKImageEncode, ptr %22, i32 0, i32 23
  store i32 1, ptr %23, align 4, !tbaa !29
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.tagPKImageEncode, ptr %24, i32 0, i32 15
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.WMPStream, ptr %26, i32 0, i32 7
  %28 = load ptr, ptr %27, align 8, !tbaa !30
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tagPKImageEncode, ptr %29, i32 0, i32 15
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tagPKImageEncode, ptr %32, i32 0, i32 16
  %34 = call i64 %28(ptr noundef %31, ptr noundef %33)
  store i64 %34, ptr %9, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %4
  %37 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %37, ptr %9, align 8, !tbaa !9
  br label %41

38:                                               ; preds = %4
  %39 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %39, ptr %9, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40, %36
  %42 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i64 %42
}

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 120}
!12 = !{!"tagPKImageEncode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !13, i64 136, !14, i64 152, !14, i64 156, !14, i64 160, !16, i64 164, !16, i64 168, !14, i64 172, !14, i64 176, !10, i64 184, !10, i64 192, !6, i64 200, !14, i64 208, !6, i64 216, !14, i64 224, !6, i64 232, !14, i64 240, !6, i64 248, !14, i64 256, !6, i64 264, !14, i64 272, !6, i64 280, !14, i64 288, !17, i64 296, !14, i64 520, !19, i64 528}
!13 = !{!"_GUID", !14, i64 0, !15, i64 4, !15, i64 6, !7, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"DESCRIPTIVEMETADATA", !18, i64 0, !18, i64 16, !18, i64 32, !18, i64 48, !18, i64 64, !18, i64 80, !18, i64 96, !18, i64 112, !18, i64 128, !18, i64 144, !18, i64 160, !18, i64 176, !18, i64 192, !18, i64 208}
!18 = !{!"DPKPROPVARIANT", !14, i64 0, !7, i64 8}
!19 = !{!"", !20, i64 0, !21, i64 88, !22, i64 208, !6, i64 33088, !21, i64 33096, !22, i64 33216, !6, i64 66096, !14, i64 66104, !10, i64 66112, !10, i64 66120, !10, i64 66128, !10, i64 66136, !14, i64 66144, !14, i64 66148, !6, i64 66152}
!20 = !{!"tagWmpDEMisc", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84}
!21 = !{!"tagCWMImageInfo", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 20, !10, i64 24, !10, i64 32, !14, i64 40, !7, i64 44, !7, i64 45, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !14, i64 80, !10, i64 88, !10, i64 96, !14, i64 104, !7, i64 108, !14, i64 112}
!22 = !{!"tagCWMIStrCodecParam", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !10, i64 32, !7, i64 40, !14, i64 44, !7, i64 48, !6, i64 56, !10, i64 64, !14, i64 72, !7, i64 76, !14, i64 16460, !7, i64 16464, !7, i64 32848, !7, i64 32849, !14, i64 32852, !14, i64 32856, !14, i64 32860, !14, i64 32864, !14, i64 32868, !14, i64 32872}
!23 = !{i64 0, i64 4, !24, i64 4, i64 2, !25, i64 6, i64 2, !25, i64 8, i64 8, !26}
!24 = !{!14, !14, i64 0}
!25 = !{!15, !15, i64 0}
!26 = !{!7, !7, i64 0}
!27 = !{!12, !16, i64 164}
!28 = !{!12, !16, i64 168}
!29 = !{!12, !14, i64 172}
!30 = !{!31, !6, i64 80}
!31 = !{!"WMPStream", !7, i64 0, !14, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, 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._GUID = type { i32, i16, i16, [8 x i8] }

@GUID_PKPixelFormatDontCare = external dso_local local_unnamed_addr constant %struct._GUID, align 4

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

; Function Attrs: nounwind uwtable
define dso_local i64 @PKImageEncode_Initialize(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readnone %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 136
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 4 dereferenceable(16) @GUID_PKPixelFormatDontCare, i64 16, i1 false), !tbaa.struct !21
  %7 = getelementptr inbounds i8, ptr %0, i64 164
  store <2 x float> <float 9.600000e+01, float 9.600000e+01>, ptr %7, align 4, !tbaa !25
  %8 = getelementptr inbounds i8, ptr %0, i64 172
  store i32 1, ptr %8, align 4, !tbaa !26
  %9 = getelementptr inbounds i8, ptr %1, i64 80
  %10 = load ptr, ptr %9, align 8, !tbaa !27
  %11 = getelementptr inbounds i8, ptr %0, i64 128
  %12 = tail call i64 %10(ptr noundef %1, ptr noundef nonnull %11) #2
  ret i64 %12
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !7, i64 120}
!6 = !{!"tagPKImageEncode", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !10, i64 128, !11, i64 136, !12, i64 152, !12, i64 156, !12, i64 160, !14, i64 164, !14, i64 168, !12, i64 172, !12, i64 176, !10, i64 184, !10, i64 192, !7, i64 200, !12, i64 208, !7, i64 216, !12, i64 224, !7, i64 232, !12, i64 240, !7, i64 248, !12, i64 256, !7, i64 264, !12, i64 272, !7, i64 280, !12, i64 288, !15, i64 296, !12, i64 520, !17, i64 528}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_GUID", !12, i64 0, !13, i64 4, !13, i64 6, !8, i64 8}
!12 = !{!"int", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!"DESCRIPTIVEMETADATA", !16, i64 0, !16, i64 16, !16, i64 32, !16, i64 48, !16, i64 64, !16, i64 80, !16, i64 96, !16, i64 112, !16, i64 128, !16, i64 144, !16, i64 160, !16, i64 176, !16, i64 192, !16, i64 208}
!16 = !{!"DPKPROPVARIANT", !12, i64 0, !8, i64 8}
!17 = !{!"", !18, i64 0, !19, i64 88, !20, i64 208, !7, i64 33088, !19, i64 33096, !20, i64 33216, !7, i64 66096, !12, i64 66104, !10, i64 66112, !10, i64 66120, !10, i64 66128, !10, i64 66136, !12, i64 66144, !12, i64 66148, !7, i64 66152}
!18 = !{!"tagWmpDEMisc", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84}
!19 = !{!"tagCWMImageInfo", !10, i64 0, !10, i64 8, !12, i64 16, !12, i64 20, !10, i64 24, !10, i64 32, !12, i64 40, !8, i64 44, !8, i64 45, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !12, i64 80, !10, i64 88, !10, i64 96, !12, i64 104, !8, i64 108, !12, i64 112}
!20 = !{!"tagCWMIStrCodecParam", !12, i64 0, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !10, i64 32, !8, i64 40, !12, i64 44, !8, i64 48, !7, i64 56, !10, i64 64, !12, i64 72, !8, i64 76, !12, i64 16460, !8, i64 16464, !8, i64 32848, !8, i64 32849, !12, i64 32852, !12, i64 32856, !12, i64 32860, !12, i64 32864, !12, i64 32868, !12, i64 32872}
!21 = !{i64 0, i64 4, !22, i64 4, i64 2, !23, i64 6, i64 2, !23, i64 8, i64 8, !24}
!22 = !{!12, !12, i64 0}
!23 = !{!13, !13, i64 0}
!24 = !{!8, !8, i64 0}
!25 = !{!14, !14, i64 0}
!26 = !{!6, !12, i64 172}
!27 = !{!28, !7, i64 80}
!28 = !{!"WMPStream", !8, i64 0, !12, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80}


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