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

; 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 i32 @PKStrnicmp(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %49, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %12 = call ptr @__ctype_tolower_loc() #4
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr %13, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !12
  store i32 %19, ptr %7, align 4, !tbaa !12
  %20 = load i32, ptr %7, align 4, !tbaa !12
  store i32 %20, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %21 = load i32, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %22 = call ptr @__ctype_tolower_loc() #4
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %23, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !12
  store i32 %29, ptr %9, align 4, !tbaa !12
  %30 = load i32, ptr %9, align 4, !tbaa !12
  store i32 %30, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %31 = load i32, ptr %10, align 4, !tbaa !12
  %32 = icmp eq i32 %21, %31
  br i1 %32, label %33, label %46

33:                                               ; preds = %11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %46

38:                                               ; preds = %33
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %38
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = icmp ne i64 %44, 0
  br label %46

46:                                               ; preds = %43, %38, %33, %11
  %47 = phi i1 [ false, %38 ], [ false, %33 ], [ false, %11 ], [ %45, %43 ]
  br i1 %47, label %48, label %56

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i32 1
  store ptr %51, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i32 1
  store ptr %53, ptr %5, align 8, !tbaa !5
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = add i64 %54, -1
  store i64 %55, ptr %6, align 8, !tbaa !9
  br label %11, !llvm.loop !14

56:                                               ; preds = %46
  %57 = load i64, ptr %6, align 8, !tbaa !9
  %58 = icmp ne i64 %57, 0
  br i1 %58, label %59, label %67

59:                                               ; preds = %56
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = sext i8 %61 to i32
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i8, ptr %63, align 1, !tbaa !11
  %65 = sext i8 %64 to i32
  %66 = sub nsw i32 %62, %65
  br label %68

67:                                               ; preds = %56
  br label %68

68:                                               ; preds = %67, %59
  %69 = phi i32 [ %66, %59 ], [ 0, %67 ]
  ret i32 %69
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #2

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(none) "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 }
attributes #4 = { nounwind willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, 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"

; Function Attrs: nofree nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 -255, 256) i32 @PKStrnicmp(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @__ctype_tolower_loc() #2
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load i8, ptr %0, align 1, !tbaa !9
  %7 = sext i8 %6 to i64
  %8 = getelementptr inbounds i32, ptr %5, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = load i8, ptr %1, align 1, !tbaa !9
  %11 = sext i8 %10 to i64
  %12 = getelementptr inbounds i32, ptr %5, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !10
  %14 = icmp ne i32 %9, %13
  %.not20 = icmp eq i8 %6, 0
  %or.cond1821 = or i1 %.not20, %14
  br i1 %or.cond1821, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %15 = icmp ne i8 %10, 0
  %16 = icmp ne i64 %2, 0
  %or.cond31 = and i1 %15, %16
  br i1 %or.cond31, label %.lr.ph35, label %.critedge

.lr.ph:                                           ; preds = %.lr.ph35
  %17 = icmp ne i8 %26, 0
  %18 = icmp ne i64 %21, 0
  %or.cond = select i1 %17, i1 %18, i1 false
  br i1 %or.cond, label %.lr.ph35, label %.critedge, !llvm.loop !12

.lr.ph35:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0162234 = phi i64 [ %21, %.lr.ph ], [ %2, %.lr.ph.preheader ]
  %.0152333 = phi ptr [ %20, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  %.02432 = phi ptr [ %19, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %19 = getelementptr inbounds i8, ptr %.02432, i64 1
  %20 = getelementptr inbounds i8, ptr %.0152333, i64 1
  %21 = add i64 %.0162234, -1
  %22 = load i8, ptr %19, align 1, !tbaa !9
  %23 = sext i8 %22 to i64
  %24 = getelementptr inbounds i32, ptr %5, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = load i8, ptr %20, align 1, !tbaa !9
  %27 = sext i8 %26 to i64
  %28 = getelementptr inbounds i32, ptr %5, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !10
  %30 = icmp ne i32 %25, %29
  %.not = icmp eq i8 %22, 0
  %or.cond18 = or i1 %.not, %30
  br i1 %or.cond18, label %.critedge, label %.lr.ph, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph, %.lr.ph35, %.lr.ph.preheader, %3
  %.016.lcssa = phi i64 [ %2, %3 ], [ %2, %.lr.ph.preheader ], [ %21, %.lr.ph35 ], [ %21, %.lr.ph ]
  %.lcssa19 = phi i8 [ %6, %3 ], [ %6, %.lr.ph.preheader ], [ %22, %.lr.ph35 ], [ %22, %.lr.ph ]
  %.lcssa = phi i8 [ %10, %3 ], [ %10, %.lr.ph.preheader ], [ %26, %.lr.ph35 ], [ %26, %.lr.ph ]
  %.not17 = icmp eq i64 %.016.lcssa, 0
  %31 = sext i8 %.lcssa19 to i32
  %32 = sext i8 %.lcssa to i32
  %33 = sub nsw i32 %31, %32
  %34 = select i1 %.not17, i32 0, i32 %33
  ret i32 %34
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #1

attributes #0 = { nofree 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" }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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(none) }

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


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