; LLVM IR from sylefeb/Silixel :: src/fstapi (fstapi)

; 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.fstReaderContext = type { ptr, ptr, i64, i64, i64, i64, i64, i32, i64, i64, ptr, ptr, ptr, i32, ptr, i8, i8, i8, [129 x i8], [120 x i8], i64, ptr, ptr, i64, i32, ptr, ptr, i64, i64, i8, ptr, i64, i64, ptr, i64, ptr, ptr, i64, i64, ptr, i32, i32, ptr, i32, i32, i32, i64, i8, %struct.fstHier, ptr, i32, ptr, i32, i8, [513 x i8], [513 x i8], ptr, i8, i32, i32, [65536 x i8], ptr, ptr }
%struct.fstHier = type { i8, %union.anon }
%union.anon = type { %struct.fstHierAttr }
%struct.fstHierAttr = type { i8, i8, ptr, i64, i64, i32 }

; 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 @fstReaderGetFacProcessMask(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %37

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = add i32 %11, -1
  store i32 %12, ptr %5, align 4, !tbaa !9
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.fstReaderContext, ptr %14, i32 0, i32 7
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %36

18:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = udiv i32 %19, 8
  store i32 %20, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = and i32 %21, 7
  store i32 %22, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.fstReaderContext, ptr %23, i32 0, i32 12
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !16
  %30 = zext i8 %29 to i32
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = shl i32 1, %31
  %33 = and i32 %30, %32
  %34 = icmp ne i32 %33, 0
  %35 = zext i1 %34 to i32
  store i32 %35, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %38

36:                                               ; preds = %10
  br label %37

37:                                               ; preds = %36, %2
  store i32 0, ptr %3, align 4
  br label %38

38:                                               ; preds = %37, %18
  %39 = load i32, ptr %3, align 4
  ret i32 %39
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 56}
!12 = !{!"fstReaderContext", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !10, i64 56, !13, i64 64, !13, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104, !6, i64 112, !7, i64 120, !7, i64 121, !10, i64 122, !10, i64 122, !10, i64 122, !10, i64 122, !10, i64 122, !10, i64 122, !10, i64 122, !10, i64 122, !7, i64 123, !7, i64 252, !13, i64 376, !6, i64 384, !6, i64 392, !13, i64 400, !10, i64 408, !6, i64 416, !6, i64 424, !13, i64 432, !13, i64 440, !10, i64 448, !6, i64 456, !13, i64 464, !13, i64 472, !6, i64 480, !13, i64 488, !6, i64 496, !6, i64 504, !13, i64 512, !13, i64 520, !6, i64 528, !10, i64 536, !10, i64 540, !6, i64 544, !10, i64 552, !10, i64 556, !10, i64 560, !13, i64 568, !10, i64 576, !14, i64 584, !6, i64 632, !10, i64 640, !6, i64 648, !10, i64 656, !10, i64 660, !7, i64 661, !7, i64 1174, !6, i64 1688, !10, i64 1696, !10, i64 1700, !10, i64 1704, !7, i64 1708, !6, i64 67248, !6, i64 67256}
!13 = !{!"long", !7, i64 0}
!14 = !{!"fstHier", !7, i64 0, !7, i64 8}
!15 = !{!12, !6, i64 96}
!16 = !{!7, !7, i64 0}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @fstReaderGetFacProcessMask(ptr noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %19, label %3

3:                                                ; preds = %2
  %4 = add i32 %1, -1
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp ult i32 %4, %6
  br i1 %7, label %8, label %19

8:                                                ; preds = %3
  %9 = lshr i32 %4, 3
  %10 = and i32 %4, 7
  %11 = getelementptr inbounds i8, ptr %0, i64 96
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = zext nneg i32 %9 to i64
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !14
  %16 = zext i8 %15 to i32
  %17 = lshr i32 %16, %10
  %18 = and i32 %17, 1
  br label %19

19:                                               ; preds = %2, %3, %8
  %.0 = phi i32 [ %18, %8 ], [ 0, %3 ], [ 0, %2 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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, !11, i64 56}
!6 = !{!"fstReaderContext", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !10, i64 64, !10, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !7, i64 112, !8, i64 120, !8, i64 121, !11, i64 122, !11, i64 122, !11, i64 122, !11, i64 122, !11, i64 122, !11, i64 122, !11, i64 122, !11, i64 122, !8, i64 123, !8, i64 252, !10, i64 376, !7, i64 384, !7, i64 392, !10, i64 400, !11, i64 408, !7, i64 416, !7, i64 424, !10, i64 432, !10, i64 440, !11, i64 448, !7, i64 456, !10, i64 464, !10, i64 472, !7, i64 480, !10, i64 488, !7, i64 496, !7, i64 504, !10, i64 512, !10, i64 520, !7, i64 528, !11, i64 536, !11, i64 540, !7, i64 544, !11, i64 552, !11, i64 556, !11, i64 560, !10, i64 568, !11, i64 576, !12, i64 584, !7, i64 632, !11, i64 640, !7, i64 648, !11, i64 656, !11, i64 660, !8, i64 661, !8, i64 1174, !7, i64 1688, !11, i64 1696, !11, i64 1700, !11, i64 1704, !8, i64 1708, !7, i64 67248, !7, i64 67256}
!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 = !{!"fstHier", !8, i64 0, !8, i64 8}
!13 = !{!6, !7, i64 96}
!14 = !{!8, !8, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass