; LLVM IR from joembedded/JesFs :: JesFs_main (conv_tstr_to_secs)

; 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.FS_DATE = type { i8, i8, i8, i8, i8, i16 }

@fs_date = external dso_local global %struct.FS_DATE, align 2

; Function Attrs: nounwind uwtable
define dso_local i32 @conv_tstr_to_secs(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 2 @fs_date, i8 0, i64 8, i1 false)
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = call i64 @strtoul(ptr noundef %4, ptr noundef %3, i32 noundef 0) #4
  %6 = trunc i64 %5 to i8
  store i8 %6, ptr getelementptr inbounds (%struct.FS_DATE, ptr @fs_date, i32 0, i32 3), align 1, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i32 1
  store ptr %8, ptr %3, align 8, !tbaa !5
  %9 = load i8, ptr %7, align 1, !tbaa !12
  %10 = sext i8 %9 to i32
  %11 = icmp ne i32 %10, 46
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %58

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call i64 @strtoul(ptr noundef %14, ptr noundef %3, i32 noundef 0) #4
  %16 = trunc i64 %15 to i8
  store i8 %16, ptr getelementptr inbounds (%struct.FS_DATE, ptr @fs_date, i32 0, i32 4), align 2, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i32 1
  store ptr %18, ptr %3, align 8, !tbaa !5
  %19 = load i8, ptr %17, align 1, !tbaa !12
  %20 = sext i8 %19 to i32
  %21 = icmp ne i32 %20, 46
  br i1 %21, label %22, label %23

22:                                               ; preds = %13
  store i32 0, ptr %2, align 4
  br label %58

23:                                               ; preds = %13
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call i64 @strtoul(ptr noundef %24, ptr noundef %3, i32 noundef 0) #4
  %26 = trunc i64 %25 to i16
  store i16 %26, ptr getelementptr inbounds (%struct.FS_DATE, ptr @fs_date, i32 0, i32 5), align 2, !tbaa !14
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i32 1
  store ptr %28, ptr %3, align 8, !tbaa !5
  %29 = load i8, ptr %27, align 1, !tbaa !12
  %30 = sext i8 %29 to i32
  %31 = icmp ne i32 %30, 32
  br i1 %31, label %32, label %33

32:                                               ; preds = %23
  store i32 0, ptr %2, align 4
  br label %58

33:                                               ; preds = %23
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call i64 @strtoul(ptr noundef %34, ptr noundef %3, i32 noundef 0) #4
  %36 = trunc i64 %35 to i8
  store i8 %36, ptr getelementptr inbounds (%struct.FS_DATE, ptr @fs_date, i32 0, i32 2), align 2, !tbaa !15
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 1
  store ptr %38, ptr %3, align 8, !tbaa !5
  %39 = load i8, ptr %37, align 1, !tbaa !12
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %40, 58
  br i1 %41, label %42, label %43

42:                                               ; preds = %33
  store i32 0, ptr %2, align 4
  br label %58

43:                                               ; preds = %33
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = call i64 @strtoul(ptr noundef %44, ptr noundef %3, i32 noundef 0) #4
  %46 = trunc i64 %45 to i8
  store i8 %46, ptr getelementptr inbounds (%struct.FS_DATE, ptr @fs_date, i32 0, i32 1), align 1, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i32 1
  store ptr %48, ptr %3, align 8, !tbaa !5
  %49 = load i8, ptr %47, align 1, !tbaa !12
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 58
  br i1 %51, label %52, label %56

52:                                               ; preds = %43
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = call i64 @strtoul(ptr noundef %53, ptr noundef null, i32 noundef 0) #4
  %55 = trunc i64 %54 to i8
  store i8 %55, ptr @fs_date, align 2, !tbaa !17
  br label %56

56:                                               ; preds = %52, %43
  %57 = call i32 @fs_date2sec1970(ptr noundef @fs_date)
  store i32 %57, ptr %2, align 4
  br label %58

58:                                               ; preds = %56, %42, %32, %22, %12
  %59 = load i32, ptr %2, align 4
  ret i32 %59
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare i32 @fs_date2sec1970(ptr noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { "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 }

!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, !7, i64 3}
!10 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !11, i64 6}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !7, i64 4}
!14 = !{!10, !11, i64 6}
!15 = !{!10, !7, i64 2}
!16 = !{!10, !7, i64 1}
!17 = !{!10, !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"

%struct.FS_DATE = type { i8, i8, i8, i8, i8, i16 }

@fs_date = external dso_local global %struct.FS_DATE, align 2

; Function Attrs: nounwind uwtable
define dso_local i32 @conv_tstr_to_secs(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  store i64 0, ptr @fs_date, align 2
  %3 = call i64 @strtoul(ptr noundef %0, ptr noundef nonnull %2, i32 noundef 0) #3
  %4 = trunc i64 %3 to i8
  store i8 %4, ptr getelementptr inbounds (i8, ptr @fs_date, i64 3), align 1, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  store ptr %6, ptr %2, align 8, !tbaa !5
  %7 = load i8, ptr %5, align 1, !tbaa !12
  %.not = icmp eq i8 %7, 46
  br i1 %.not, label %8, label %38

8:                                                ; preds = %1
  %9 = call i64 @strtoul(ptr noundef nonnull %6, ptr noundef nonnull %2, i32 noundef 0) #3
  %10 = trunc i64 %9 to i8
  store i8 %10, ptr getelementptr inbounds (i8, ptr @fs_date, i64 4), align 2, !tbaa !13
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 1
  store ptr %12, ptr %2, align 8, !tbaa !5
  %13 = load i8, ptr %11, align 1, !tbaa !12
  %.not1 = icmp eq i8 %13, 46
  br i1 %.not1, label %14, label %38

14:                                               ; preds = %8
  %15 = call i64 @strtoul(ptr noundef nonnull %12, ptr noundef nonnull %2, i32 noundef 0) #3
  %16 = trunc i64 %15 to i16
  store i16 %16, ptr getelementptr inbounds (i8, ptr @fs_date, i64 6), align 2, !tbaa !14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 1
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = load i8, ptr %17, align 1, !tbaa !12
  %.not2 = icmp eq i8 %19, 32
  br i1 %.not2, label %20, label %38

20:                                               ; preds = %14
  %21 = call i64 @strtoul(ptr noundef nonnull %18, ptr noundef nonnull %2, i32 noundef 0) #3
  %22 = trunc i64 %21 to i8
  store i8 %22, ptr getelementptr inbounds (i8, ptr @fs_date, i64 2), align 2, !tbaa !15
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 1
  store ptr %24, ptr %2, align 8, !tbaa !5
  %25 = load i8, ptr %23, align 1, !tbaa !12
  %.not3 = icmp eq i8 %25, 58
  br i1 %.not3, label %26, label %38

26:                                               ; preds = %20
  %27 = call i64 @strtoul(ptr noundef nonnull %24, ptr noundef nonnull %2, i32 noundef 0) #3
  %28 = trunc i64 %27 to i8
  store i8 %28, ptr getelementptr inbounds (i8, ptr @fs_date, i64 1), align 1, !tbaa !16
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load i8, ptr %29, align 1, !tbaa !12
  %31 = icmp eq i8 %30, 58
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = getelementptr inbounds i8, ptr %29, i64 1
  %34 = tail call i64 @strtoul(ptr nocapture noundef nonnull %33, ptr noundef null, i32 noundef 0) #3
  %35 = trunc i64 %34 to i8
  store i8 %35, ptr @fs_date, align 2, !tbaa !17
  br label %36

36:                                               ; preds = %32, %26
  %37 = tail call i32 @fs_date2sec1970(ptr noundef nonnull @fs_date) #3
  br label %38

38:                                               ; preds = %20, %14, %8, %1, %36
  %.0 = phi i32 [ %37, %36 ], [ 0, %1 ], [ 0, %8 ], [ 0, %14 ], [ 0, %20 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtoul(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #1

declare i32 @fs_date2sec1970(ptr noundef) local_unnamed_addr #2

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 = { mustprogress nofree nounwind willreturn "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 = { "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, !7, i64 3}
!10 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !11, i64 6}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !7, i64 4}
!14 = !{!10, !11, i64 6}
!15 = !{!10, !7, i64 2}
!16 = !{!10, !7, i64 1}
!17 = !{!10, !7, i64 0}


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