; 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 }

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #0

declare i32 @fputc(i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @fstWriterVarint(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
define dso_local void @fstWriterSetAttrBegin(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !11
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %95

13:                                               ; preds = %5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.fstWriterContext, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = call i32 @fputc(i32 noundef 252, ptr noundef %16)
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = icmp ugt i32 %18, 3
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 8, ptr %8, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %20, %13
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.fstWriterContext, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = call i32 @fputc(i32 noundef %22, ptr noundef %25)
  %27 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %27, label %53 [
    i32 1, label %28
    i32 2, label %36
    i32 3, label %44
    i32 0, label %52
  ]

28:                                               ; preds = %21
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %34, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp sgt i32 %32, 3
  br i1 %33, label %34, label %35

34:                                               ; preds = %31, %28
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %34, %31
  br label %54

36:                                               ; preds = %21
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %42, label %39

39:                                               ; preds = %36
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = icmp sgt i32 %40, 15
  br i1 %41, label %42, label %43

42:                                               ; preds = %39, %36
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %42, %39
  br label %54

44:                                               ; preds = %21
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %50, label %47

47:                                               ; preds = %44
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp sgt i32 %48, 3
  br i1 %49, label %50, label %51

50:                                               ; preds = %47, %44
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %50, %47
  br label %54

52:                                               ; preds = %21
  br label %53

53:                                               ; preds = %52, %21
  br label %54

54:                                               ; preds = %53, %51, %43, %35
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.fstWriterContext, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = call i32 @fputc(i32 noundef %55, ptr noundef %58)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.fstWriterContext, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %67

65:                                               ; preds = %54
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  br label %68

67:                                               ; preds = %54
  br label %68

68:                                               ; preds = %67, %65
  %69 = phi ptr [ %66, %65 ], [ @.str.11, %67 ]
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.13, ptr noundef %69, i32 noundef 0) #4
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = icmp ne ptr %71, null
  br i1 %72, label %73, label %80

73:                                               ; preds = %68
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = call i64 @strlen(ptr noundef %74) #5
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.fstWriterContext, ptr %76, i32 0, i32 7
  %78 = load i64, ptr %77, align 8, !tbaa !16
  %79 = add i64 %78, %75
  store i64 %79, ptr %77, align 8, !tbaa !16
  br label %80

80:                                               ; preds = %73, %68
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.fstWriterContext, ptr %81, i32 0, i32 7
  %83 = load i64, ptr %82, align 8, !tbaa !16
  %84 = add nsw i64 %83, 4
  store i64 %84, ptr %82, align 8, !tbaa !16
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.fstWriterContext, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !13
  %88 = load i64, ptr %10, align 8, !tbaa !11
  %89 = call i32 @fstWriterVarint(ptr noundef %87, i64 noundef %88)
  %90 = sext i32 %89 to i64
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.fstWriterContext, ptr %91, i32 0, i32 7
  %93 = load i64, ptr %92, align 8, !tbaa !16
  %94 = add nsw i64 %93, %90
  store i64 %94, ptr %92, align 8, !tbaa !16
  br label %95

95:                                               ; preds = %80, %5
  ret void
}

attributes #0 = { 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 #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 "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 #4 = { nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"fstWriterContext", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, 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, !12, i64 120, !12, i64 128, !10, i64 136, !10, i64 140, !12, i64 144, !12, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !12, i64 176, !10, i64 184, !15, i64 192, !6, i64 200, !6, i64 208, !10, i64 216, !12, 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, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !12, 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}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !12, i64 56}


; 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
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fputc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @fstWriterVarint(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @fstWriterSetAttrBegin(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %6

6:                                                ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call i32 @fputc(i32 noundef 252, ptr noundef %8)
  %10 = icmp ugt i32 %1, 3
  %spec.select = select i1 %10, i32 8, i32 %2
  %spec.select35 = select i1 %10, i32 0, i32 %1
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = tail call i32 @fputc(i32 noundef %spec.select35, ptr noundef %11)
  switch i32 %spec.select35, label %.unreachabledefault [
    i32 1, label %13
    i32 2, label %14
    i32 3, label %15
    i32 0, label %16
  ]

13:                                               ; preds = %6
  %or.cond = icmp ugt i32 %spec.select, 3
  %spec.store.select = select i1 %or.cond, i32 0, i32 %spec.select
  br label %16

14:                                               ; preds = %6
  %or.cond3 = icmp ugt i32 %spec.select, 15
  %spec.store.select6 = select i1 %or.cond3, i32 0, i32 %spec.select
  br label %16

15:                                               ; preds = %6
  %or.cond5 = icmp ugt i32 %spec.select, 3
  %spec.store.select7 = select i1 %or.cond5, i32 0, i32 %spec.select
  br label %16

.unreachabledefault:                              ; preds = %6
  unreachable

16:                                               ; preds = %6, %15, %14, %13
  %.1 = phi i32 [ %spec.select, %6 ], [ %spec.store.select7, %15 ], [ %spec.store.select6, %14 ], [ %spec.store.select, %13 ]
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = tail call i32 @fputc(i32 noundef %.1, ptr noundef %17)
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %.not34 = icmp eq ptr %3, null
  %20 = select i1 %.not34, ptr @.str.11, ptr %3
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.13, ptr noundef nonnull %20, i32 noundef 0) #3
  br i1 %.not34, label %._crit_edge, label %22

._crit_edge:                                      ; preds = %16
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 56
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %27

22:                                               ; preds = %16
  %23 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %3) #4
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = load i64, ptr %24, align 8, !tbaa !13
  %26 = add i64 %25, %23
  br label %27

27:                                               ; preds = %._crit_edge, %22
  %28 = phi i64 [ %.pre, %._crit_edge ], [ %26, %22 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 56
  %30 = add nsw i64 %28, 4
  store i64 %30, ptr %29, align 8, !tbaa !13
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = tail call i32 @fstWriterVarint(ptr noundef %31, i64 noundef %4)
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr %29, align 8, !tbaa !13
  %35 = add nsw i64 %34, %33
  store i64 %35, ptr %29, align 8, !tbaa !13
  br label %36

36:                                               ; preds = %27, %5
  ret void
}

attributes #0 = { 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 #1 = { nofree 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 }
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, !7, i64 8}
!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 = !{!6, !10, i64 56}


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