; 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.fstWriterContext = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, ptr, i32, ptr, i32, i32, i32, i8, i64, i64, i32, i32, i64, i64, i32, i32, i32, i64, i32, double, ptr, ptr, i32, i64, i8, i8, i8, i8, i8, i64, i64, i64, i64, i64, i32, ptr, i32, i8, ptr, ptr, ptr, ptr, i32 }
%struct.fstBlackoutChain = type { ptr, i64, i8 }

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 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 void @fstWriterEmitDumpActive(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %51

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 24) #4
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.fstWriterContext, ptr %10, i32 0, i32 21
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.fstBlackoutChain, ptr %13, i32 0, i32 1
  store i64 %12, ptr %14, align 8, !tbaa !15
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  %17 = zext i1 %16 to i32
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.fstBlackoutChain, ptr %18, i32 0, i32 2
  %20 = trunc i32 %17 to i8
  %21 = load i8, ptr %19, align 8
  %22 = and i8 %20, 1
  %23 = and i8 %21, -2
  %24 = or i8 %23, %22
  store i8 %24, ptr %19, align 8
  %25 = zext i8 %22 to i32
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.fstWriterContext, ptr %26, i32 0, i32 31
  %28 = load i32, ptr %27, align 8, !tbaa !17
  %29 = add i32 %28, 1
  store i32 %29, ptr %27, align 8, !tbaa !17
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.fstWriterContext, ptr %30, i32 0, i32 30
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %43

34:                                               ; preds = %8
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.fstWriterContext, ptr %36, i32 0, i32 30
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = getelementptr inbounds %struct.fstBlackoutChain, ptr %38, i32 0, i32 0
  store ptr %35, ptr %39, align 8, !tbaa !19
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.fstWriterContext, ptr %41, i32 0, i32 30
  store ptr %40, ptr %42, align 8, !tbaa !18
  br label %50

43:                                               ; preds = %8
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.fstWriterContext, ptr %45, i32 0, i32 29
  store ptr %44, ptr %46, align 8, !tbaa !20
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.fstWriterContext, ptr %48, i32 0, i32 30
  store ptr %47, ptr %49, align 8, !tbaa !18
  br label %50

50:                                               ; preds = %43, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %51

51:                                               ; preds = %50, %2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,1) "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 }
attributes #4 = { nounwind allocsize(0,1) }

!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, !13, i64 144}
!12 = !{!"fstWriterContext", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !6, i64 96, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 116, !10, i64 116, !10, i64 116, !13, i64 120, !13, i64 128, !10, i64 136, !10, i64 140, !13, i64 144, !13, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !13, i64 176, !10, i64 184, !14, i64 192, !6, i64 200, !6, i64 208, !10, i64 216, !13, i64 224, !7, i64 232, !10, i64 233, !10, i64 233, !10, i64 233, !10, i64 233, !10, i64 233, !10, i64 233, !10, i64 233, !10, i64 233, !7, i64 234, !7, i64 235, !10, i64 236, !13, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272, !10, i64 280, !6, i64 288, !10, i64 296, !10, i64 300, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !10, i64 336}
!13 = !{!"long", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !13, i64 8}
!16 = !{!"fstBlackoutChain", !6, i64 0, !13, i64 8, !10, i64 16}
!17 = !{!12, !10, i64 216}
!18 = !{!12, !6, i64 208}
!19 = !{!16, !6, i64 0}
!20 = !{!12, !6, i64 200}


; 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 nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local void @fstWriterEmitDumpActive(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %17, label %3

3:                                                ; preds = %2
  %4 = tail call noalias dereferenceable_or_null(24) ptr @calloc(i64 noundef 1, i64 noundef 24) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %6, ptr %7, align 8, !tbaa !13
  %8 = icmp ne i32 %1, 0
  %9 = getelementptr inbounds i8, ptr %4, i64 16
  %10 = zext i1 %8 to i8
  store i8 %10, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 216
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = add i32 %12, 1
  store i32 %13, ptr %11, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 208
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %.not15 = icmp eq ptr %15, null
  %16 = getelementptr inbounds i8, ptr %0, i64 200
  %.sink = select i1 %.not15, ptr %16, ptr %15
  store ptr %4, ptr %.sink, align 8, !tbaa !17
  store ptr %4, ptr %14, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %3, %2
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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 allocsize(0,1) }

!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, !10, i64 144}
!6 = !{!"fstWriterContext", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !11, i64 88, !7, i64 96, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 116, !11, i64 116, !11, i64 116, !10, i64 120, !10, i64 128, !11, i64 136, !11, i64 140, !10, i64 144, !10, i64 152, !11, i64 160, !11, i64 164, !11, i64 168, !10, i64 176, !11, i64 184, !12, i64 192, !7, i64 200, !7, i64 208, !11, i64 216, !10, i64 224, !8, i64 232, !11, i64 233, !11, i64 233, !11, i64 233, !11, i64 233, !11, i64 233, !11, i64 233, !11, i64 233, !11, i64 233, !8, i64 234, !8, i64 235, !11, i64 236, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !11, i64 280, !7, i64 288, !11, i64 296, !11, i64 300, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !11, i64 336}
!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 = !{!"double", !8, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"fstBlackoutChain", !7, i64 0, !10, i64 8, !11, i64 16}
!15 = !{!6, !11, i64 216}
!16 = !{!6, !7, i64 208}
!17 = !{!7, !7, i64 0}


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