; 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 }
%struct.fstCurrHier = type { ptr, ptr, i32 }

@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.fstReaderContext, ptr %8, i32 0, i32 49
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %59

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.fstReaderContext, ptr %13, i32 0, i32 49
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.fstReaderContext, ptr %16, i32 0, i32 49
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.fstCurrHier, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %35

22:                                               ; preds = %12
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.fstReaderContext, ptr %23, i32 0, i32 51
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.fstReaderContext, ptr %26, i32 0, i32 49
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.fstCurrHier, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds %struct.fstCurrHier, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %25, i64 %33
  store i8 0, ptr %34, align 1, !tbaa !18
  br label %39

35:                                               ; preds = %12
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.fstReaderContext, ptr %36, i32 0, i32 51
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  store i8 0, ptr %38, align 1, !tbaa !18
  br label %39

39:                                               ; preds = %35, %22
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.fstReaderContext, ptr %40, i32 0, i32 49
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.fstCurrHier, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.fstReaderContext, ptr %45, i32 0, i32 49
  store ptr %44, ptr %46, align 8, !tbaa !9
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %47) #3
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.fstReaderContext, ptr %48, i32 0, i32 51
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %56

52:                                               ; preds = %39
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.fstReaderContext, ptr %53, i32 0, i32 51
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  br label %57

56:                                               ; preds = %39
  br label %57

57:                                               ; preds = %56, %52
  %58 = phi ptr [ %55, %52 ], [ @.str.11, %56 ]
  store ptr %58, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %60

59:                                               ; preds = %7, %1
  store ptr null, ptr %2, align 8
  br label %60

60:                                               ; preds = %59, %57
  %61 = load ptr, ptr %2, align 8
  ret ptr %61
}

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

@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn uwtable
define dso_local ptr @fstReaderPopScope(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %19, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 632
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not17 = icmp eq ptr %4, null
  br i1 %.not17, label %19, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr %4, align 8, !tbaa !13
  %.not18 = icmp eq ptr %6, null
  %7 = getelementptr inbounds i8, ptr %0, i64 648
  %8 = load ptr, ptr %7, align 8, !tbaa !15
  br i1 %.not18, label %14, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !16
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i8, ptr %8, i64 %12
  br label %14

14:                                               ; preds = %5, %9
  %.sink = phi ptr [ %13, %9 ], [ %8, %5 ]
  store i8 0, ptr %.sink, align 1, !tbaa !17
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  store ptr %16, ptr %3, align 8, !tbaa !5
  tail call void @free(ptr noundef nonnull %4) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 648
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %.not19 = icmp eq ptr %18, null
  %spec.select = select i1 %.not19, ptr @.str.11, ptr %18
  br label %19

19:                                               ; preds = %1, %2, %14
  %.0 = phi ptr [ %spec.select, %14 ], [ null, %2 ], [ null, %1 ]
  ret ptr %.0
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn 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, !7, i64 632}
!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 = !{!14, !7, i64 0}
!14 = !{!"fstCurrHier", !7, i64 0, !7, i64 8, !11, i64 16}
!15 = !{!6, !7, i64 648}
!16 = !{!14, !11, i64 16}
!17 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass