; 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 }
%struct._GUID = type { i32, i16, i16, [8 x i8] }

@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 ptr @GetPixelFormatFromHash(i8 noundef zeroext %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i8 %0, ptr %3, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !8
  br label %6

6:                                                ; preds = %30, %1
  %7 = load i32, ptr %4, align 4, !tbaa !8
  %8 = sext i32 %7 to i64
  %9 = icmp ult i64 %8, 68
  br i1 %9, label %10, label %33

10:                                               ; preds = %6
  %11 = load i32, ptr %4, align 4, !tbaa !8
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %12
  %14 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !10
  %16 = getelementptr inbounds %struct._GUID, ptr %15, i32 0, i32 3
  %17 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 7
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = zext i8 %18 to i32
  %20 = load i8, ptr %3, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = icmp eq i32 %19, %21
  br i1 %22, label %23, label %29

23:                                               ; preds = %10
  %24 = load i32, ptr %4, align 4, !tbaa !8
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.tagPKPixelInfo, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !10
  store ptr %28, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %34

29:                                               ; preds = %10
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %4, align 4, !tbaa !8
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !8
  br label %6, !llvm.loop !14

33:                                               ; preds = %6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %34

34:                                               ; preds = %33, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %35 = load ptr, ptr %2, align 8
  ret ptr %35
}

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 }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"tagPKPixelInfo", !12, i64 0, !13, i64 8, !9, i64 16, !9, i64 20, !9, i64 24, !13, i64 32, !9, i64 40, !9, i64 44, !9, i64 48, !9, i64 52}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!"long", !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @GetPixelFormatFromHash(i8 noundef zeroext %0) local_unnamed_addr #0 {
  br label %21

2:                                                ; preds = %21
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %3 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %indvars.iv.next
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 15
  %6 = load i8, ptr %5, align 1, !tbaa !12
  %7 = icmp eq i8 %6, %0
  br i1 %7, label %27, label %8

8:                                                ; preds = %2
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %9 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %indvars.iv.next.1
  %10 = load ptr, ptr %9, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 15
  %12 = load i8, ptr %11, align 1, !tbaa !12
  %13 = icmp eq i8 %12, %0
  br i1 %13, label %27, label %14

14:                                               ; preds = %8
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %15 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %indvars.iv.next.2
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 15
  %18 = load i8, ptr %17, align 1, !tbaa !12
  %19 = icmp eq i8 %18, %0
  br i1 %19, label %27, label %20

20:                                               ; preds = %14
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, 68
  br i1 %exitcond.not.3, label %27, label %21, !llvm.loop !13

21:                                               ; preds = %20, %1
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next.3, %20 ]
  %22 = getelementptr inbounds [68 x %struct.tagPKPixelInfo], ptr @pixelInfo, i64 0, i64 %indvars.iv
  %23 = load ptr, ptr %22, align 16, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 15
  %25 = load i8, ptr %24, align 1, !tbaa !12
  %26 = icmp eq i8 %25, %0
  br i1 %26, label %27, label %2

27:                                               ; preds = %20, %14, %8, %2, %21
  %.05 = phi ptr [ %23, %21 ], [ %4, %2 ], [ %10, %8 ], [ %16, %14 ], [ null, %20 ]
  ret ptr %.05
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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" }

!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 = !{!8, !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass