; LLVM IR from USDA-ARS-ACSL/MAIZSIM :: Crop source/cpmdate.ll (ZN7CPMDate9incrementEv)

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

%class.CPMDate = type { [20 x i8], [30 x i8], [20 x i8], [40 x i8], [9 x i8], i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7CPMDate7dn_to_dEv(ptr noundef nonnull align 4 dereferenceable(136)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8y_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8d_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8set_dateEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7CPMDate12is_leap_yearEv(ptr noundef nonnull align 4 dereferenceable(136)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7CPMDate9incrementEv(ptr noundef nonnull align 4 dereferenceable(136) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  %5 = call noundef i32 @_ZN7CPMDate12is_leap_yearEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %7, %1
  %9 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 5
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = add nsw i32 365, %11
  %13 = icmp eq i32 %10, %12
  br i1 %13, label %14, label %19

14:                                               ; preds = %8
  %15 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 5
  store i32 1, ptr %15, align 4, !tbaa !11
  %16 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 6
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %16, align 4, !tbaa !13
  br label %23

19:                                               ; preds = %8
  %20 = getelementptr inbounds %class.CPMDate, ptr %4, i32 0, i32 5
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !11
  br label %23

23:                                               ; preds = %19, %14
  call void @_ZN7CPMDate7dn_to_dEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @_ZN7CPMDate8y_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @_ZN7CPMDate8d_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @_ZN7CPMDate8set_dateEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

attributes #0 = { mustprogress 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 120}
!12 = !{!"_ZTS7CPMDate", !7, i64 0, !7, i64 20, !7, i64 50, !7, i64 70, !7, i64 110, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132}
!13 = !{!12, !10, i64 124}


; 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 uwtable
declare dso_local void @_ZN7CPMDate7dn_to_dEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8y_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8d_to_strEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate8set_dateEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7CPMDate12is_leap_yearEv(ptr noundef nonnull align 4 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7CPMDate9incrementEv(ptr noundef nonnull align 4 dereferenceable(136) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef i32 @_ZN7CPMDate12is_leap_yearEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  %.not = icmp eq i32 %2, 0
  %spec.select = select i1 %.not, i32 365, i32 366
  %3 = getelementptr inbounds i8, ptr %0, i64 120
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, %spec.select
  br i1 %5, label %6, label %10

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 124
  %8 = load i32, ptr %7, align 4, !tbaa !10
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr %7, align 4, !tbaa !10
  br label %12

10:                                               ; preds = %1
  %11 = add nsw i32 %4, 1
  br label %12

12:                                               ; preds = %10, %6
  %.sink = phi i32 [ 1, %6 ], [ %11, %10 ]
  store i32 %.sink, ptr %3, align 4
  tail call void @_ZN7CPMDate7dn_to_dEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  tail call void @_ZN7CPMDate8y_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  tail call void @_ZN7CPMDate8m_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  tail call void @_ZN7CPMDate8d_to_strEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  tail call void @_ZN7CPMDate8set_dateEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  tail call void @_ZN7CPMDate17make_digit_stringEv(ptr noundef nonnull align 4 dereferenceable(136) %0)
  ret void
}

attributes #0 = { mustprogress 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 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" }

!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, !9, i64 120}
!6 = !{!"_ZTS7CPMDate", !7, i64 0, !7, i64 20, !7, i64 50, !7, i64 70, !7, i64 110, !9, i64 120, !9, i64 124, !9, i64 128, !9, i64 132}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!6, !9, i64 124}


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