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

; 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
declare dso_local void @fstWriterSetTimescale(ptr noundef, i32 noundef) #1

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

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %58

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 -9, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @atoi(ptr noundef %15) #4
  store i32 %16, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %17, ptr %8, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %39, %14
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = icmp ne i8 %20, 0
  br i1 %21, label %22, label %42

22:                                               ; preds = %18
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  switch i32 %25, label %34 [
    i32 109, label %26
    i32 117, label %27
    i32 110, label %28
    i32 112, label %29
    i32 102, label %30
    i32 97, label %31
    i32 122, label %32
    i32 115, label %33
  ]

26:                                               ; preds = %22
  store i32 -3, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

27:                                               ; preds = %22
  store i32 -6, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

28:                                               ; preds = %22
  store i32 -9, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

29:                                               ; preds = %22
  store i32 -12, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

30:                                               ; preds = %22
  store i32 -15, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

31:                                               ; preds = %22
  store i32 -18, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

32:                                               ; preds = %22
  store i32 -21, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

33:                                               ; preds = %22
  store i32 0, ptr %6, align 4, !tbaa !9
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

34:                                               ; preds = %22
  br label %35

35:                                               ; preds = %34, %33, %32, %31, %30, %29, %28, %27, %26
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %42

39:                                               ; preds = %35
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i32 1
  store ptr %41, ptr %8, align 8, !tbaa !5
  br label %18, !llvm.loop !12

42:                                               ; preds = %38, %18
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 10
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %6, align 4, !tbaa !9
  br label %55

48:                                               ; preds = %42
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 100
  br i1 %50, label %51, label %54

51:                                               ; preds = %48
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = add nsw i32 %52, 2
  store i32 %53, ptr %6, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %51, %48
  br label %55

55:                                               ; preds = %54, %45
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load i32, ptr %6, align 4, !tbaa !9
  call void @fstWriterSetTimescale(ptr noundef %56, i32 noundef %57)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %58

58:                                               ; preds = %55, %11, %2
  ret void
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

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 = { inlinehint nounwind willreturn memory(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 #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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: nounwind uwtable
declare dso_local void @fstWriterSetTimescale(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @fstWriterSetTimescaleFromString(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %18

5:                                                ; preds = %2
  %6 = tail call i32 @atoi(ptr nocapture noundef %1) #2
  br label %7

7:                                                ; preds = %10, %5
  %.0 = phi ptr [ %1, %5 ], [ %11, %10 ]
  %8 = load i8, ptr %.0, align 1, !tbaa !5
  switch i8 %8, label %10 [
    i8 0, label %.loopexit
    i8 109, label %.thread
    i8 117, label %.loopexit24
    i8 110, label %.loopexit
    i8 112, label %.loopexit25
    i8 102, label %.loopexit26
    i8 97, label %.loopexit27
    i8 122, label %12
    i8 115, label %9
  ]

9:                                                ; preds = %7
  br label %12

.thread:                                          ; preds = %7
  br label %12

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %.0, i64 1
  br label %7, !llvm.loop !8

.loopexit:                                        ; preds = %7, %7
  br label %12

.loopexit24:                                      ; preds = %7
  br label %12

.loopexit25:                                      ; preds = %7
  br label %12

.loopexit26:                                      ; preds = %7
  br label %12

.loopexit27:                                      ; preds = %7
  br label %12

12:                                               ; preds = %7, %.loopexit27, %.loopexit26, %.loopexit25, %.loopexit24, %.loopexit, %9, %.thread
  %.2 = phi i32 [ 0, %9 ], [ -3, %.thread ], [ -9, %.loopexit ], [ -6, %.loopexit24 ], [ -12, %.loopexit25 ], [ -15, %.loopexit26 ], [ -18, %.loopexit27 ], [ -21, %7 ]
  switch i32 %6, label %17 [
    i32 10, label %13
    i32 100, label %15
  ]

13:                                               ; preds = %12
  %14 = add nsw i32 %.2, 1
  br label %17

15:                                               ; preds = %12
  %16 = add nsw i32 %.2, 2
  br label %17

17:                                               ; preds = %12, %15, %13
  %.3 = phi i32 [ %14, %13 ], [ %16, %15 ], [ %.2, %12 ]
  tail call void @fstWriterSetTimescale(ptr noundef nonnull %0, i32 noundef %.3)
  br label %18

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #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 = { inlinehint mustprogress nofree nounwind willreturn memory(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 #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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass