; LLVM IR from kala13x/libxutils :: src/sys (xfs)

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

8:                                                ; preds = %50, %1
  %9 = load i64, ptr %3, align 8, !tbaa !9
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = icmp ult i64 %9, %10
  br i1 %11, label %12, label %53

12:                                               ; preds = %8
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !13
  %17 = sext i8 %16 to i32
  switch i32 %17, label %48 [
    i32 97, label %18
    i32 99, label %21
    i32 100, label %24
    i32 101, label %27
    i32 110, label %30
    i32 114, label %33
    i32 116, label %36
    i32 115, label %39
    i32 119, label %42
    i32 120, label %45
  ]

18:                                               ; preds = %12
  %19 = load i32, ptr %5, align 4, !tbaa !11
  %20 = or i32 %19, 1024
  store i32 %20, ptr %5, align 4, !tbaa !11
  br label %49

21:                                               ; preds = %12
  %22 = load i32, ptr %5, align 4, !tbaa !11
  %23 = or i32 %22, 64
  store i32 %23, ptr %5, align 4, !tbaa !11
  br label %49

24:                                               ; preds = %12
  %25 = load i32, ptr %5, align 4, !tbaa !11
  %26 = or i32 %25, 2048
  store i32 %26, ptr %5, align 4, !tbaa !11
  br label %49

27:                                               ; preds = %12
  %28 = load i32, ptr %5, align 4, !tbaa !11
  %29 = or i32 %28, 128
  store i32 %29, ptr %5, align 4, !tbaa !11
  br label %49

30:                                               ; preds = %12
  %31 = load i32, ptr %5, align 4, !tbaa !11
  %32 = or i32 %31, 2048
  store i32 %32, ptr %5, align 4, !tbaa !11
  br label %49

33:                                               ; preds = %12
  %34 = load i32, ptr %5, align 4, !tbaa !11
  %35 = or i32 %34, 0
  store i32 %35, ptr %5, align 4, !tbaa !11
  br label %49

36:                                               ; preds = %12
  %37 = load i32, ptr %5, align 4, !tbaa !11
  %38 = or i32 %37, 512
  store i32 %38, ptr %5, align 4, !tbaa !11
  br label %49

39:                                               ; preds = %12
  %40 = load i32, ptr %5, align 4, !tbaa !11
  %41 = or i32 %40, 1052672
  store i32 %41, ptr %5, align 4, !tbaa !11
  br label %49

42:                                               ; preds = %12
  %43 = load i32, ptr %5, align 4, !tbaa !11
  %44 = or i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !11
  br label %49

45:                                               ; preds = %12
  %46 = load i32, ptr %5, align 4, !tbaa !11
  %47 = or i32 %46, 2
  store i32 %47, ptr %5, align 4, !tbaa !11
  br label %49

48:                                               ; preds = %12
  br label %49

49:                                               ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18
  br label %50

50:                                               ; preds = %49
  %51 = load i64, ptr %3, align 8, !tbaa !9
  %52 = add i64 %51, 1
  store i64 %52, ptr %3, align 8, !tbaa !9
  br label %8, !llvm.loop !14

53:                                               ; preds = %8
  %54 = load i32, ptr %5, align 4, !tbaa !11
  %55 = and i32 %54, 0
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %68

57:                                               ; preds = %53
  %58 = load i32, ptr %5, align 4, !tbaa !11
  %59 = and i32 %58, 1
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %68

61:                                               ; preds = %57
  %62 = load i32, ptr %5, align 4, !tbaa !11
  %63 = and i32 %62, -1
  store i32 %63, ptr %5, align 4, !tbaa !11
  %64 = load i32, ptr %5, align 4, !tbaa !11
  %65 = and i32 %64, -2
  store i32 %65, ptr %5, align 4, !tbaa !11
  %66 = load i32, ptr %5, align 4, !tbaa !11
  %67 = or i32 %66, 2
  store i32 %67, ptr %5, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %61, %57, %53
  %69 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i32 %69
}

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

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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 nounwind memory(argmem: read) uwtable
define dso_local i32 @XFile_ParseFlags(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strnlen(ptr noundef nonnull dereferenceable(1) %0, i64 noundef 10) #2
  %.not24 = icmp eq i64 %2, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %23
  %.023 = phi i32 [ %.1, %23 ], [ 0, %1 ]
  %.02122 = phi i64 [ %24, %23 ], [ 0, %1 ]
  %3 = getelementptr inbounds i8, ptr %0, i64 %.02122
  %4 = load i8, ptr %3, align 1, !tbaa !5
  switch i8 %4, label %23 [
    i8 97, label %5
    i8 99, label %7
    i8 100, label %9
    i8 101, label %11
    i8 110, label %13
    i8 120, label %21
    i8 116, label %15
    i8 115, label %17
    i8 119, label %19
  ]

5:                                                ; preds = %.lr.ph
  %6 = or i32 %.023, 1024
  br label %23

7:                                                ; preds = %.lr.ph
  %8 = or i32 %.023, 64
  br label %23

9:                                                ; preds = %.lr.ph
  %10 = or i32 %.023, 2048
  br label %23

11:                                               ; preds = %.lr.ph
  %12 = or i32 %.023, 128
  br label %23

13:                                               ; preds = %.lr.ph
  %14 = or i32 %.023, 2048
  br label %23

15:                                               ; preds = %.lr.ph
  %16 = or i32 %.023, 512
  br label %23

17:                                               ; preds = %.lr.ph
  %18 = or i32 %.023, 1052672
  br label %23

19:                                               ; preds = %.lr.ph
  %20 = or i32 %.023, 1
  br label %23

21:                                               ; preds = %.lr.ph
  %22 = or i32 %.023, 2
  br label %23

23:                                               ; preds = %5, %7, %9, %11, %13, %15, %17, %19, %21, %.lr.ph
  %.1 = phi i32 [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %.023, %.lr.ph ]
  %24 = add nuw i64 %.02122, 1
  %exitcond.not = icmp eq i64 %24, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %23, %1
  %.0.lcssa = phi i32 [ 0, %1 ], [ %.1, %23 ]
  %25 = and i32 %.0.lcssa, 1
  %.not = icmp eq i32 %25, 0
  %26 = and i32 %.0.lcssa, -4
  %27 = or disjoint i32 %26, 2
  %.2 = select i1 %.not, i32 %.0.lcssa, i32 %27
  ret i32 %.2
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strnlen(ptr nocapture noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(argmem: read) 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 nounwind willreturn memory(argmem: 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 #2 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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