; 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.tagPKPixelInfo = type { ptr, i64, i32, i32, i32, i64, i32, i32, i32, i32 }

@pixelInfo = external hidden constant [68 x %struct.tagPKPixelInfo], align 16

; 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: nounwind uwtable
define dso_local i64 @PixelFormatLookup(ptr noundef %0, i8 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !10
  br label %7

7:                                                ; preds = %88, %2
  %8 = load i64, ptr %6, align 8, !tbaa !10
  %9 = icmp ult i64 %8, 68
  br i1 %9, label %10, label %91

10:                                               ; preds = %7
  %11 = load i8, ptr %4, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = icmp eq i32 0, %12
  br i1 %13, label %14, label %29

14:                                               ; preds = %10
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = load i64, ptr %6, align 8, !tbaa !10
  %19 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = call i32 @memcmp(ptr noundef %17, ptr noundef %21, i64 noundef 16) #5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %28, label %24

24:                                               ; preds = %14
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i64, ptr %6, align 8, !tbaa !10
  %27 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %26
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %27, i64 56, i1 false), !tbaa.struct !15
  br label %97

28:                                               ; preds = %14
  br label %87

29:                                               ; preds = %10
  %30 = load i8, ptr %4, align 1, !tbaa !9
  %31 = zext i8 %30 to i32
  %32 = icmp eq i32 1, %31
  br i1 %32, label %33, label %86

33:                                               ; preds = %29
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %34, i32 0, i32 7
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = load i64, ptr %6, align 8, !tbaa !10
  %38 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %38, i32 0, i32 7
  %40 = load i32, ptr %39, align 4, !tbaa !17
  %41 = icmp eq i32 %36, %40
  br i1 %41, label %42, label %85

42:                                               ; preds = %33
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %43, i32 0, i32 8
  %45 = load i32, ptr %44, align 8, !tbaa !18
  %46 = load i64, ptr %6, align 8, !tbaa !10
  %47 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %47, i32 0, i32 8
  %49 = load i32, ptr %48, align 8, !tbaa !18
  %50 = icmp eq i32 %45, %49
  br i1 %50, label %51, label %85

51:                                               ; preds = %42
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %52, i32 0, i32 9
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = load i64, ptr %6, align 8, !tbaa !10
  %56 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %55
  %57 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %56, i32 0, i32 9
  %58 = load i32, ptr %57, align 4, !tbaa !19
  %59 = icmp eq i32 %54, %58
  br i1 %59, label %60, label %85

60:                                               ; preds = %51
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %61, i32 0, i32 6
  %63 = load i32, ptr %62, align 8, !tbaa !20
  %64 = load i64, ptr %6, align 8, !tbaa !10
  %65 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %64
  %66 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %65, i32 0, i32 6
  %67 = load i32, ptr %66, align 8, !tbaa !20
  %68 = icmp eq i32 %63, %67
  br i1 %68, label %69, label %85

69:                                               ; preds = %60
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %70, i32 0, i32 5
  %72 = load i64, ptr %71, align 8, !tbaa !21
  %73 = and i64 %72, 48
  %74 = load i64, ptr %6, align 8, !tbaa !10
  %75 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %74
  %76 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %75, i32 0, i32 5
  %77 = load i64, ptr %76, align 8, !tbaa !21
  %78 = and i64 %77, 48
  %79 = icmp eq i64 %73, %78
  br i1 %79, label %80, label %84

80:                                               ; preds = %69
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load i64, ptr %6, align 8, !tbaa !10
  %83 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %82
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %81, ptr align 8 %83, i64 56, i1 false), !tbaa.struct !15
  br label %97

84:                                               ; preds = %69
  br label %85

85:                                               ; preds = %84, %60, %51, %42, %33
  br label %86

86:                                               ; preds = %85, %29
  br label %87

87:                                               ; preds = %86, %28
  br label %88

88:                                               ; preds = %87
  %89 = load i64, ptr %6, align 8, !tbaa !10
  %90 = add i64 %89, 1
  store i64 %90, ptr %6, align 8, !tbaa !10
  br label %7, !llvm.loop !22

91:                                               ; preds = %7
  store i64 -106, ptr %5, align 8, !tbaa !10
  br i1 true, label %92, label %94

92:                                               ; preds = %91
  %93 = load i64, ptr %5, align 8, !tbaa !10
  store i64 %93, ptr %5, align 8, !tbaa !10
  br label %97

94:                                               ; preds = %91
  %95 = load i64, ptr %5, align 8, !tbaa !10
  store i64 %95, ptr %5, align 8, !tbaa !10
  br label %96

96:                                               ; preds = %94
  br label %97

97:                                               ; preds = %96, %92, %80, %24
  %98 = load i64, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i64 %98
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #2

; 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

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

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"tagPKPixelInfo", !6, i64 0, !11, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !11, i64 32, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52}
!14 = !{!"int", !7, i64 0}
!15 = !{i64 0, i64 8, !5, i64 8, i64 8, !10, i64 16, i64 4, !16, i64 20, i64 4, !16, i64 24, i64 4, !16, i64 32, i64 8, !10, i64 40, i64 4, !16, i64 44, i64 4, !16, i64 48, i64 4, !16, i64 52, i64 4, !16}
!16 = !{!14, !14, i64 0}
!17 = !{!13, !14, i64 44}
!18 = !{!13, !14, i64 48}
!19 = !{!13, !14, i64 52}
!20 = !{!13, !14, i64 40}
!21 = !{!13, !11, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; 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.tagPKPixelInfo = type { ptr, i64, i32, i32, i32, i64, i32, i32, i32, i32 }

@pixelInfo = external hidden local_unnamed_addr constant [68 x %struct.tagPKPixelInfo], align 16

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i64 -106, 1) i64 @PixelFormatLookup(ptr nocapture noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = getelementptr inbounds i8, ptr %0, i64 52
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  switch i8 %1, label %.loopexit [
    i8 0, label %.split.us
    i8 1, label %.split.us27
  ]

.split.us:                                        ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %11, %.split.us
  %.024.us = phi i64 [ 0, %.split.us ], [ %12, %11 ]
  %9 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %.024.us
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %bcmp.us = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %7, ptr noundef nonnull dereferenceable(16) %10, i64 16)
  %.not.us = icmp eq i32 %bcmp.us, 0
  br i1 %.not.us, label %.loopexit.sink.split, label %11

11:                                               ; preds = %8
  %12 = add nuw nsw i64 %.024.us, 1
  %exitcond37.not = icmp eq i64 %12, 68
  br i1 %exitcond37.not, label %.loopexit, label %8, !llvm.loop !12

.split.us27:                                      ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 44
  %14 = load i32, ptr %13, align 4, !tbaa !14
  br label %15

15:                                               ; preds = %42, %.split.us27
  %.024.us28 = phi i64 [ 0, %.split.us27 ], [ %43, %42 ]
  %16 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %.024.us28
  %17 = getelementptr inbounds i8, ptr %16, i64 44
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = icmp eq i32 %14, %18
  br i1 %19, label %20, label %42

20:                                               ; preds = %15
  %21 = load i32, ptr %3, align 8, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %16, i64 48
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = icmp eq i32 %21, %23
  br i1 %24, label %25, label %42

25:                                               ; preds = %20
  %26 = load i32, ptr %4, align 4, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %16, i64 52
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp eq i32 %26, %28
  br i1 %29, label %30, label %42

30:                                               ; preds = %25
  %31 = load i32, ptr %5, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %16, i64 40
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = icmp eq i32 %31, %33
  br i1 %34, label %35, label %42

35:                                               ; preds = %30
  %36 = load i64, ptr %6, align 8, !tbaa !18
  %37 = getelementptr inbounds i8, ptr %16, i64 32
  %38 = load i64, ptr %37, align 8, !tbaa !18
  %39 = xor i64 %38, %36
  %40 = and i64 %39, 48
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %.loopexit.sink.split, label %42

42:                                               ; preds = %35, %30, %25, %20, %15
  %43 = add nuw nsw i64 %.024.us28, 1
  %exitcond.not = icmp eq i64 %43, 68
  br i1 %exitcond.not, label %.loopexit, label %15, !llvm.loop !12

.loopexit.sink.split:                             ; preds = %35, %8
  %.lcssa40.sink = phi ptr [ %9, %8 ], [ %16, %35 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(56) %.lcssa40.sink, i64 56, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %42, %11, %.loopexit.sink.split, %2
  %.021 = phi i64 [ -106, %2 ], [ 0, %.loopexit.sink.split ], [ -106, %11 ], [ -106, %42 ]
  ret i64 %.021
}

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind willreturn memory(argmem: read) }

!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 = !{!"tagPKPixelInfo", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !10, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !11, i64 44}
!15 = !{!6, !11, i64 48}
!16 = !{!6, !11, i64 52}
!17 = !{!6, !11, i64 40}
!18 = !{!6, !10, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass