; LLVM IR from kacperks/Fractal_Engine :: Engine/Thirdparty/cmake/Engine/Thirdparty/cmake/openal-soft/common/alstring.l_653aae22 (m)

; 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: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN2al11strncasecmpEPKcS1_m(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = icmp ugt i64 %10, 0
  br i1 %11, label %12, label %51

12:                                               ; preds = %3
  br label %13

13:                                               ; preds = %48, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = invoke noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext %15)
          to label %17 unwind label %54

17:                                               ; preds = %13
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = invoke noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext %19)
          to label %21 unwind label %54

21:                                               ; preds = %17
  %22 = sub nsw i32 %16, %20
  store i32 %22, ptr %8, align 4, !tbaa !12
  %23 = load i32, ptr %8, align 4, !tbaa !12
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %31

26:                                               ; preds = %21
  %27 = load i32, ptr %8, align 4, !tbaa !12
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %31

30:                                               ; preds = %26
  store i32 0, ptr %9, align 4
  br label %31

31:                                               ; preds = %30, %29, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %32 = load i32, ptr %9, align 4
  switch i32 %32, label %57 [
    i32 0, label %33
    i32 1, label %52
  ]

33:                                               ; preds = %31
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = add i64 %35, -1
  store i64 %36, ptr %7, align 8, !tbaa !9
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %38, label %48

38:                                               ; preds = %34
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 1
  store ptr %40, ptr %5, align 8, !tbaa !5
  %41 = load i8, ptr %39, align 1, !tbaa !11
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %38
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %6, align 8, !tbaa !5
  %46 = load i8, ptr %44, align 1, !tbaa !11
  %47 = icmp ne i8 %46, 0
  br label %48

48:                                               ; preds = %43, %38, %34
  %49 = phi i1 [ false, %38 ], [ false, %34 ], [ %47, %43 ]
  br i1 %49, label %13, label %50, !llvm.loop !14

50:                                               ; preds = %48
  br label %51

51:                                               ; preds = %50, %3
  store i32 0, ptr %4, align 4
  br label %52

52:                                               ; preds = %51, %31
  %53 = load i32, ptr %4, align 4
  ret i32 %53

54:                                               ; preds = %17, %13
  %55 = landingpad { ptr, i32 }
          catch ptr null
  %56 = extractvalue { ptr, i32 } %55, 0
  call void @__clang_call_terminate(ptr %56) #4
  unreachable

57:                                               ; preds = %31
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { noinline noreturn nounwind uwtable "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 = { noreturn 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, !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: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN2al11strncasecmpEPKcS1_m(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %.critedge, label %.preheader

.preheader:                                       ; preds = %3, %13
  %.012 = phi ptr [ %14, %13 ], [ %0, %3 ]
  %.011 = phi ptr [ %15, %13 ], [ %1, %3 ]
  %.010 = phi i64 [ %10, %13 ], [ %2, %3 ]
  %.09 = phi i32 [ %.1, %13 ], [ undef, %3 ]
  %4 = load i8, ptr %.012, align 1, !tbaa !5
  %5 = tail call noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext %4)
  %6 = load i8, ptr %.011, align 1, !tbaa !5
  %7 = tail call noundef i32 @_ZN12_GLOBAL__N_18to_upperEc(i8 noundef signext %6)
  %8 = icmp slt i32 %5, %7
  %.not16.not = icmp eq i32 %5, %7
  %.09. = select i1 %.not16.not, i32 %.09, i32 1
  %.1 = select i1 %8, i32 -1, i32 %.09.
  br i1 %.not16.not, label %9, label %.critedge

9:                                                ; preds = %.preheader
  %10 = add i64 %.010, -1
  %.not17 = icmp eq i64 %10, 0
  br i1 %.not17, label %.critedge, label %11

11:                                               ; preds = %9
  %12 = load i8, ptr %.012, align 1, !tbaa !5
  %.not18 = icmp eq i8 %12, 0
  br i1 %.not18, label %.critedge, label %13

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %.012, i64 1
  %15 = getelementptr inbounds i8, ptr %.011, i64 1
  %16 = load i8, ptr %.011, align 1, !tbaa !5
  %.not19 = icmp eq i8 %16, 0
  br i1 %.not19, label %.critedge, label %.preheader, !llvm.loop !8

.critedge:                                        ; preds = %.preheader, %13, %9, %11, %3
  %.2 = phi i32 [ 0, %3 ], [ 0, %13 ], [ 0, %9 ], [ 0, %11 ], [ %.1, %.preheader ]
  ret i32 %.2
}

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass